【问题标题】:What is the language of Live Templates in IntelliJ?IntelliJ 中实时模板的语言是什么?
【发布时间】:2016-07-29 15:04:12
【问题描述】:

IntelliJ 中 Live Templates 的语言是什么?

这个Velocity 和其他模板一样吗?

这种语言有条件运算符吗?

我在 IntelliJ 中有以下默认设置器模板代码:

#set($paramName = $helper.getParamName($field, $project))
public ##
#if($field.modifierStatic)
  static ##
#end
void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) {
  #if ($field.name == $paramName)
    #if (!$field.modifierStatic)
      this.##
    #else
      $classname.##
    #end
  #end
  $field.name = $paramName;
}

我可以在 Live Template 语言中使用相同的语言吗?

【问题讨论】:

    标签: intellij-idea velocity live-templates


    【解决方案1】:

    实时模板的语言不是 Velocity,它更简单:只是变量(及其值的表达式)。实时模板中没有控制结构(条件/循环)。

    所以你不能在实时模板中拥有“相同”,这似乎没有意义,因为实时模板和生成模板是为不同的上下文设计的,并且可以访问不同的信息。例如,当您生成一个 setter 时,您之前已经选择了一个相应的字段,因此定义了 $field 变量。但在实时模板中没有这样的隐式上下文。

    【讨论】:

      猜你喜欢
      • 2011-04-30
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 2010-10-17
      • 1970-01-01
      • 1970-01-01
      • 2010-09-12
      相关资源
      最近更新 更多