public class MethodNodeUtils extends Object
Utility class for working with MethodNodes
Type Params | Return Type | Name and description |
---|---|---|
|
public static BlockStatement |
getCodeAsBlock(MethodNode node) Gets the code for a method (or constructor) as a block. |
|
public static String |
getPropertyName(MethodNode mNode) For a method node potentially representing a property, returns the name of the property. |
|
public static boolean |
isGetterCandidate(MethodNode m) Check if the MethodNode instance is getter candidate |
|
public static String |
methodDescriptor(MethodNode mNode) Return the method node's descriptor which includes its return type, name and parameter types without generics. |
|
public static String |
methodDescriptor(MethodNode mNode, boolean pretty) Return the method node's descriptor which includes its return type, name and parameter types without generics. |
|
public static String |
methodDescriptorWithoutReturnType(MethodNode mNode) Return the method node's descriptor including its name and parameter types without generics. |
Gets the code for a method (or constructor) as a block.
If no code is found, an empty block will be returned.
If a single non-block statement is found, a block containing that statement will be returned.
Otherwise the existing block statement will be returned.
The original node
is not modified.
node
- the method (or constructor) nodeFor a method node potentially representing a property, returns the name of the property.
mNode
- a MethodNodeCheck if the MethodNode instance is getter candidate
m
- the MethodNode instancetrue
if the instance is getter candidateReturn the method node's descriptor which includes its return type, name and parameter types without generics.
mNode
- the method nodeReturn the method node's descriptor which includes its return type, name and parameter types without generics.
mNode
- the method nodepretty
- whether to quote a name with spacesReturn the method node's descriptor including its name and parameter types without generics.
mNode
- the method node