Class MethodNode

All Implemented Interfaces:
GroovydocHolder<AnnotatedNode>, NodeMetaDataHandler
Direct Known Subclasses:
ConstructorNode, ExtensionMethodNode

public class MethodNode extends AnnotatedNode
Represents a method declaration.
  • Constructor Details

  • Method Details

    • getTypeDescriptor

      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.
    • getTypeDescriptor

      @Deprecated public String getTypeDescriptor(boolean pretty)
    • getCode

      public Statement getCode()
    • setCode

      public void setCode(Statement code)
    • getModifiers

      public int getModifiers()
    • setModifiers

      public void setModifiers(int modifiers)
    • getName

      public String getName()
    • getParameters

      public Parameter[] getParameters()
    • setParameters

      public void setParameters(Parameter[] parameters)
    • hasDefaultValue

      public boolean hasDefaultValue()
      Returns:
      true if any parameter has a default value
    • getReturnType

      public ClassNode getReturnType()
    • setReturnType

      public void setReturnType(ClassNode returnType)
    • isDynamicReturnType

      public boolean isDynamicReturnType()
    • isVoidMethod

      public boolean isVoidMethod()
    • getVariableScope

      public VariableScope getVariableScope()
    • setVariableScope

      public void setVariableScope(VariableScope variableScope)
    • isAbstract

      public boolean isAbstract()
    • isDefault

      public boolean isDefault()
    • isFinal

      public boolean isFinal()
    • isStatic

      public boolean isStatic()
    • isPublic

      public boolean isPublic()
    • isPrivate

      public boolean isPrivate()
    • isProtected

      public boolean isProtected()
    • isPackageScope

      public boolean isPackageScope()
    • getExceptions

      public ClassNode[] getExceptions()
    • getFirstStatement

      public Statement getFirstStatement()
    • getGenericsTypes

      public GenericsType[] getGenericsTypes()
    • setGenericsTypes

      public void setGenericsTypes(GenericsType[] genericsTypes)
    • hasAnnotationDefault

      public boolean hasAnnotationDefault()
      Returns:
      true if annotation method has a default value
    • setAnnotationDefault

      public void setAnnotationDefault(boolean hasDefaultValue)
    • isScriptBody

      public boolean isScriptBody()
      Returns:
      true if this method is the run method from a script
    • setIsScriptBody

      public void setIsScriptBody()
      Sets the flag for this method to indicate it is a script body implementation.
      See Also:
    • isStaticConstructor

      public boolean isStaticConstructor()
    • isConstructor

      public boolean isConstructor()
      Since:
      4.0.0
    • isSyntheticPublic

      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:
      true if this class is public but had no explicit public modifier
    • setSyntheticPublic

      public void setSyntheticPublic(boolean syntheticPublic)
    • getText

      public String getText()
      Overrides:
      getText in class ASTNode
    • toString

      public String toString()
      Overrides:
      toString in class Object