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?

5 comments

Hello opticyclic,

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?


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!"


0

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.

0

Hello opticyclic,

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.


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!"


0

Ahh OK. Thanks.
I am now practising on if and for blocks.
I'm surprised that these 3 aren't included by default though.

0

there are a lot of different templates for "loops"

Look under "iterations"

There's also an intention : surround with ... if

0

Please sign in to leave a comment.