Class AbstractTypeCheckingExtension

java.lang.Object
org.codehaus.groovy.transform.stc.TypeCheckingExtension
org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension
Direct Known Subclasses:
GroovyTypeCheckingExtensionSupport, TraitTypeCheckingExtension

public class AbstractTypeCheckingExtension
extends TypeCheckingExtension

Custom type checking extensions may extend this method in order to benefit from a lot of support methods.

The methods found in this class are made directly available in type checking scripts through the GroovyTypeCheckingExtensionSupport class.

Since:
2.3.0
  • Field Details

    • context

      protected final TypeCheckingContext context
    • handled

      protected boolean handled
    • debug

      protected boolean debug
  • Constructor Details

  • Method Details

    • setHandled

      public void setHandled​(boolean handled)
    • newScope

      public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope newScope()
    • newScope

      public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope newScope​(Closure code)
    • scopeExit

      public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope scopeExit()
    • getCurrentScope

      public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope getCurrentScope()
    • scopeExit

      public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope scopeExit​(Closure code)
    • isGenerated

      public boolean isGenerated​(MethodNode node)
    • unique

      public java.util.List<MethodNode> unique​(MethodNode node)
    • newMethod

      public MethodNode newMethod​(java.lang.String name, java.lang.Class returnType)
    • newMethod

      public MethodNode newMethod​(java.lang.String name, ClassNode returnType)
    • newMethod

      public MethodNode newMethod​(java.lang.String name, java.util.concurrent.Callable<ClassNode> returnType)
    • delegatesTo

      public void delegatesTo​(ClassNode type)
    • delegatesTo

      public void delegatesTo​(ClassNode type, int strategy)
    • delegatesTo

      public void delegatesTo​(ClassNode type, int strategy, org.codehaus.groovy.transform.stc.DelegationMetadata parent)
    • isAnnotatedBy

      public boolean isAnnotatedBy​(ASTNode node, java.lang.Class annotation)
    • isAnnotatedBy

      public boolean isAnnotatedBy​(ASTNode node, ClassNode annotation)
    • isDynamic

      public boolean isDynamic​(VariableExpression var)
    • isExtensionMethod

      public boolean isExtensionMethod​(MethodNode node)
    • getArguments

      public ArgumentListExpression getArguments​(MethodCall call)
    • safeCall

      protected java.lang.Object safeCall​(Closure closure, java.lang.Object... args)
    • isMethodCall

      public boolean isMethodCall​(java.lang.Object o)
    • argTypesMatches

      public boolean argTypesMatches​(ClassNode[] argTypes, java.lang.Class... classes)
    • argTypesMatches

      public boolean argTypesMatches​(MethodCall call, java.lang.Class... classes)
    • firstArgTypesMatches

      public boolean firstArgTypesMatches​(ClassNode[] argTypes, java.lang.Class... classes)
    • firstArgTypesMatches

      public boolean firstArgTypesMatches​(MethodCall call, java.lang.Class... classes)
    • argTypeMatches

      public boolean argTypeMatches​(ClassNode[] argTypes, int index, java.lang.Class clazz)
    • argTypeMatches

      public boolean argTypeMatches​(MethodCall call, int index, java.lang.Class clazz)
    • withTypeChecker

      public <R> R withTypeChecker​(Closure<R> code)
    • makeDynamic

      public MethodNode makeDynamic​(MethodCall call)
      Used to instruct the type checker that the call is a dynamic method call. Calling this method automatically sets the handled flag to true. The expected return type of the dynamic method call is Object.
      Parameters:
      call - the method call which is a dynamic method call
      Returns:
      a virtual method node with the same name as the expected call
    • makeDynamic

      public MethodNode makeDynamic​(MethodCall call, ClassNode returnType)
      Used to instruct the type checker that the call is a dynamic method call. Calling this method automatically sets the handled flag to true.
      Parameters:
      call - the method call which is a dynamic method call
      returnType - the expected return type of the dynamic call
      Returns:
      a virtual method node with the same name as the expected call
    • makeDynamic

      public void makeDynamic​(PropertyExpression pexp)
      Instructs the type checker that a property access is dynamic, returning an instance of an Object. Calling this method automatically sets the handled flag to true.
      Parameters:
      pexp - the property or attribute expression
    • makeDynamic

      public void makeDynamic​(PropertyExpression pexp, ClassNode returnType)
      Instructs the type checker that a property access is dynamic. Calling this method automatically sets the handled flag to true.
      Parameters:
      pexp - the property or attribute expression
      returnType - the type of the property
    • makeDynamic

      public void makeDynamic​(VariableExpression vexp)
      Instructs the type checker that an unresolved variable is a dynamic variable of type Object. Calling this method automatically sets the handled flag to true.
      Parameters:
      vexp - the dynamic variable
    • makeDynamic

      public void makeDynamic​(VariableExpression vexp, ClassNode returnType)
      Instructs the type checker that an unresolved variable is a dynamic variable.
      Parameters:
      returnType - the type of the dynamic variable Calling this method automatically sets the handled flag to true.
      vexp - the dynamic variable
    • log

      public void log​(java.lang.String message)
    • getEnclosingBinaryExpression

      public BinaryExpression getEnclosingBinaryExpression()
    • pushEnclosingBinaryExpression

      public void pushEnclosingBinaryExpression​(BinaryExpression binaryExpression)
    • pushEnclosingClosureExpression

      public void pushEnclosingClosureExpression​(ClosureExpression closureExpression)
    • getEnclosingMethodCall

      public Expression getEnclosingMethodCall()
    • popEnclosingMethodCall

      public Expression popEnclosingMethodCall()
    • popEnclosingMethod

      public MethodNode popEnclosingMethod()
    • getEnclosingClassNode

      public ClassNode getEnclosingClassNode()
    • getEnclosingMethods

      public java.util.List<MethodNode> getEnclosingMethods()
    • getEnclosingMethod

      public MethodNode getEnclosingMethod()
    • popTemporaryTypeInfo

      public void popTemporaryTypeInfo()
    • pushEnclosingClassNode

      public void pushEnclosingClassNode​(ClassNode classNode)
    • popEnclosingBinaryExpression

      public BinaryExpression popEnclosingBinaryExpression()
    • getEnclosingClassNodes

      public java.util.List<ClassNode> getEnclosingClassNodes()
    • getEnclosingClosureStack

      public java.util.List<TypeCheckingContext.EnclosingClosure> getEnclosingClosureStack()
    • popEnclosingClassNode

      public ClassNode popEnclosingClassNode()
    • pushEnclosingMethod

      public void pushEnclosingMethod​(MethodNode methodNode)
    • getGeneratedMethods

      public java.util.Set<MethodNode> getGeneratedMethods()
    • getEnclosingBinaryExpressionStack

      public java.util.List<BinaryExpression> getEnclosingBinaryExpressionStack()
    • getEnclosingClosure

      public TypeCheckingContext.EnclosingClosure getEnclosingClosure()
    • getEnclosingMethodCalls

      public java.util.List<Expression> getEnclosingMethodCalls()
    • pushEnclosingMethodCall

      public void pushEnclosingMethodCall​(Expression call)
    • popEnclosingClosure

      public TypeCheckingContext.EnclosingClosure popEnclosingClosure()
    • pushTemporaryTypeInfo

      public void pushTemporaryTypeInfo()