Top Description Fields Constructors Methods
org.codehaus.groovy.ast

public Class MethodNode

extends AnnotatedNode
implements Opcodes
Class Inheritance
All Implemented Interfaces
org.objectweb.asm.Opcodes
Known Direct Subclasses
org.codehaus.groovy.ast.decompiled.LazyMethodNode, org.codehaus.groovy.transform.stc.ExtensionMethodNode, org.codehaus.groovy.ast.ConstructorNode
Imports
org.apache.groovy.ast.tools.ClassNodeUtils, .MethodNodeUtils, org.codehaus.groovy.ast.stmt.BlockStatement, .Statement, org.objectweb.asm.Opcodes, java.lang.reflect.Modifier, java.util.List, .Optional

Represents a method declaration.

Field Summary

Modifier and TypeField and Description
private Statement
private boolean
private final ClassNode[]
private GenericsType[]
private boolean
private int
private final String
private Parameter[]
private ClassNode
private final boolean
private boolean
private String
private VariableScope

Constructor Summary

AccessConstructor and Description
protected
public
MethodNode(final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Method Summary

Modifier and TypeMethod and Description
public Statement
public ClassNode[]
public Statement
public GenericsType[]
public int
public String
public Parameter[]
public ClassNode
public String

Returns:

string form of node with some generic elements suppressed
getText
()

Overrides org.codehaus.groovy.ast.ASTNode.getText.

Provides a nicely formatted string of the method definition.
public String
getTypeDescriptor()

The type descriptor for a method node is a string containing the name of the method, its return type, and its parameter types in a canonical form.

public VariableScope
public boolean

Returns:

true if annotation method has a default value
hasAnnotationDefault
()

public boolean

Returns:

true if any parameter has a default value
hasDefaultValue
()

private void
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean

Returns:

true if this method is the run method from a script
isScriptBody
()

public boolean
public boolean
public boolean

Returns:

true if this class is public but had no explicit public modifier
isSyntheticPublic
()

Indicates that this method has been "promoted" to public by Groovy when in fact there was no public modifier explicitly in the source code.

public boolean
public void
setAnnotationDefault(boolean hasDefaultValue)

public void
public void
setGenericsTypes(GenericsType[] genericsTypes)

public void
setIsScriptBody()

Sets the flag for this method to indicate it is a script body implementation.

public void
setModifiers(int modifiers)

public void
setParameters(Parameter[] parameters)

public void
public void
setSyntheticPublic(boolean syntheticPublic)

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.codehaus.groovy.ast.AnnotatedNode:
addAnnotationaddAnnotationsgetAnnotationsgetAnnotationsgetDeclaringClassgetGroovydocgetInstancehasNoRealSourcePositionisSyntheticsetDeclaringClasssetHasNoRealSourcePositionsetSynthetic

Field Detail

codeback to summary
private Statement code
dynamicReturnTypeback to summary
private boolean dynamicReturnType
exceptionsback to summary
private final ClassNode[] exceptions
genericsTypesback to summary
private GenericsType[] genericsTypes
hasDefaultValueback to summary
private boolean hasDefaultValue
modifiersback to summary
private int modifiers
nameback to summary
private final String name
parametersback to summary
private Parameter[] parameters
returnTypeback to summary
private ClassNode returnType
staticConstructorback to summary
private final boolean staticConstructor
syntheticPublicback to summary
private boolean syntheticPublic
typeDescriptorback to summary
private String typeDescriptor
variableScopeback to summary
private VariableScope variableScope

Constructor Detail

MethodNodeback to summary
protected MethodNode()
MethodNodeback to summary
public MethodNode(final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Method Detail

getCodeback to summary
public Statement getCode()
getExceptionsback to summary
public ClassNode[] getExceptions()
getFirstStatementback to summary
public Statement getFirstStatement()
getGenericsTypesback to summary
public GenericsType[] getGenericsTypes()
getModifiersback to summary
public int getModifiers()
getNameback to summary
public String getName()
getParametersback to summary
public Parameter[] getParameters()
getReturnTypeback to summary
public ClassNode getReturnType()
getTextback to summary
public String getText()

Overrides org.codehaus.groovy.ast.ASTNode.getText.

Provides a nicely formatted string of the method definition. For simplicity, generic types on some of the elements are not displayed.

Returns:String

string form of node with some generic elements suppressed

Annotations
@Override
getTypeDescriptorback to summary
public String getTypeDescriptor()

The type descriptor for a method node is a string containing the name of the method, its return type, and its parameter types in a canonical form. For simplicity, we use the format of a Java declaration without parameter names or generics.

getVariableScopeback to summary
public VariableScope getVariableScope()
hasAnnotationDefaultback to summary
public boolean hasAnnotationDefault()
Returns:boolean

true if annotation method has a default value

hasDefaultValueback to summary
public boolean hasDefaultValue()
Returns:boolean

true if any parameter has a default value

invalidateCachedDataback to summary
private void invalidateCachedData()
isAbstractback to summary
public boolean isAbstract()
isDefaultback to summary
public boolean isDefault()
isDynamicReturnTypeback to summary
public boolean isDynamicReturnType()
isFinalback to summary
public boolean isFinal()
isPackageScopeback to summary
public boolean isPackageScope()
isPrivateback to summary
public boolean isPrivate()
isProtectedback to summary
public boolean isProtected()
isPublicback to summary
public boolean isPublic()
isScriptBodyback to summary
public boolean isScriptBody()
Returns:boolean

true if this method is the run method from a script

isStaticback to summary
public boolean isStatic()
isStaticConstructorback to summary
public boolean isStaticConstructor()
isSyntheticPublicback to summary
public boolean isSyntheticPublic()

Indicates that this method has been "promoted" to public by Groovy when in fact there was no public modifier explicitly in the source code. I.e. it remembers that it has applied Groovy's "public methods by default" rule. This property is typically only of interest to AST transform writers.

Returns:boolean

true if this class is public but had no explicit public modifier

isVoidMethodback to summary
public boolean isVoidMethod()
setAnnotationDefaultback to summary
public void setAnnotationDefault(boolean hasDefaultValue)
setCodeback to summary
public void setCode(Statement code)
setGenericsTypesback to summary
public void setGenericsTypes(GenericsType[] genericsTypes)
setIsScriptBodyback to summary
public void setIsScriptBody()

Sets the flag for this method to indicate it is a script body implementation.

See Also
ModuleNode#createStatementsClass()
setModifiersback to summary
public void setModifiers(int modifiers)
setParametersback to summary
public void setParameters(Parameter[] parameters)
setReturnTypeback to summary
public void setReturnType(ClassNode returnType)
setSyntheticPublicback to summary
public void setSyntheticPublic(boolean syntheticPublic)
setVariableScopeback to summary
public void setVariableScope(VariableScope variableScope)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override