How to use variable value in live templates in Intellij IDEA?

你说的曾经没有我的故事 提交于 2019-12-21 07:07:30

问题


I want to create live template for setter.

I've created this template

How can I use value of par variable to generate value of var variable? Basically, I want to avoid redundancy here and put name of variable only once and other one will be generated automatically by some algorithm.

UPDATE

I want to clarify a little bit what I want to achieve.

Suppose I want to create setter with name setTime which has parameter time.

public void setTime(long time)
{
    // ...
}

I don't want to type "time" twice - capitalized and non-capitalized. I want to type just parameter name so method name will be generated automatically.

UPDATE (Answer)

Turned out that variable order is important. This is final result of what I want


回答1:


You can use the soutv as an example, notice how it defines a copy of a variable:

It's also possible to define custom expression for live templates via plugins or Groovy code: How can i add custom expression functions for Live templates in Intellij.



来源:https://stackoverflow.com/questions/14053301/how-to-use-variable-value-in-live-templates-in-intellij-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!