Live Template - "New Method"
I am trying to get to grips with Live Template so I decided to try and create one to make new methods.
I'm struggling a bit though.
This is what I have so far.
public void $NAME$($VAR_TYPE$ $VAR$){
$END$
}
//Variable definitions
//NAME "methodName" "methodName"
//VAR_TYPE typeOfVariable(VAR) String
//VAR variableOfType(Type)
It returns
public void methodName( ){
}
How do I get it to suggest a variable type and name for the args?
Please sign in to leave a comment.
Hello opticyclic,
The variableOfType() macro matches an existing variable within scope. No
variables are in scope when you're entering a method declaration.
What exactly would you like IDEA to suggest?
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
I want it to return something like
public void methodName(String arg1)
{
}
Then methodName, String and arg1 would all be highlighted with the red box thing that lets me change them to what I want.
Hello opticyclic,
Then you needn't use any macros at all. Simply define variables with initial
values of "String" and "arg1".
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Ahh OK. Thanks.
I am now practising on if and for blocks.
I'm surprised that these 3 aren't included by default though.
there are a lot of different templates for "loops"
Look under "iterations"
There's also an intention : surround with ... if