Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.transform.sc
[Java] Class StaticCompilationVisitor

    java.lang.Object
      org.codehaus.groovy.ast.CodeVisitorSupport
          org.codehaus.groovy.ast.ClassCodeVisitorSupport
              org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor
                  org.codehaus.groovy.transform.sc.StaticCompilationVisitor

    public class StaticCompilationVisitor
    extends StaticTypeCheckingVisitor

This visitor is responsible for amending the AST with static compilation metadata or transform the AST so that a class or a method can be statically compiled. It may also throw errors specific to static compilation which are not considered as an error at the type check pass. For example, usage of spread operator is not allowed in statically compiled portions of code, while it may be statically checked. Static compilation relies on static type checking, which explains why this visitor extends the type checker visitor.

Authors:
  Cedric Champeau

Field Summary
`static MethodNode` | `ARRAYLIST_ADD_METHOD`
`static ClassNode` | `ARRAYLIST_CLASSNODE`
`static MethodNode` | `ARRAYLIST_CONSTRUCTOR`

Fields inherited from class StaticTypeCheckingVisitor
CLOSURE_CALL_NO_ARG, CLOSURE_CALL_ONE_ARG, CLOSURE_CALL_VARGS

Constructor Summary
`StaticCompilationVisitor(SourceUnit unit, ClassNode node, TypeCheckerPluginFactory pluginFactory)`

Method Summary
`protected boolean` | `existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)`
`protected MethodNode` | `findMethodOrFail(Expression expr, ClassNode receiver, java.lang.String name, ClassNode... args)`
`protected ClassNode[]` | `getTypeCheckingAnnotations()`
`static boolean` | `isStaticallyCompiled(AnnotatedNode node)`
`void` | `visitBinaryExpression(BinaryExpression expression)`
`void` | `visitClass(ClassNode node)`
`void` | `visitConstructorCallExpression(ConstructorCallExpression call)`
`void` | `visitForLoop(ForStatement forLoop)`
`void` | `visitMethod(MethodNode node)`
`void` | `visitMethodCallExpression(MethodCallExpression call)`
`void` | `visitSpreadExpression(SpreadExpression expression)`

Methods inherited from class StaticTypeCheckingVisitor
addError, addStaticTypeError, addTypeCheckingInfoAnnotation, existsProperty, findMethodOrFail, getSourceUnit, getType, getTypeCheckingAnnotations, hasSetter, inferComponentType, inferLoopElementType, isSkipMode, performSecondPass, setErrorCollector, setMethodsToBeVisited, shouldSkipClassNode, shouldSkipMethodNode, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitCastExpression, visitClass, visitClassExpression, visitClosureExpression, visitConstructorCallExpression, visitConstructorOrMethod, visitField, visitForLoop, visitIfElse, visitMethod, visitMethodCallExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitStaticMethodCallExpression, visitTernaryExpression, visitTryCatchFinally, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop

Methods inherited from class ClassCodeVisitorSupport
addError, getSourceUnit, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop

Methods inherited from class CodeVisitorSupport
visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### ARRAYLIST_ADD_METHOD

    public static final MethodNode ARRAYLIST_ADD_METHOD

### ARRAYLIST_CLASSNODE

    public static final ClassNode ARRAYLIST_CLASSNODE

### ARRAYLIST_CONSTRUCTOR

    public static final MethodNode ARRAYLIST_CONSTRUCTOR

Constructor Detail

### StaticCompilationVisitor

    public StaticCompilationVisitor(SourceUnit unit, ClassNode node, TypeCheckerPluginFactory pluginFactory)

Method Detail

### existsProperty

    if (objectExpressionType.implementsInterface(ClassHelper.LIST_TYPE)) {
    protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)

### findMethodOrFail

    return methodNode;
    protected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, java.lang.String name, ClassNode... args)

### getTypeCheckingAnnotations

    @Override
    protected ClassNode[] getTypeCheckingAnnotations()

### isStaticallyCompiled

    public static boolean isStaticallyCompiled(AnnotatedNode node)

### visitBinaryExpression

    public void visitBinaryExpression(BinaryExpression expression)

### visitClass

    @Override
    public void visitClass(ClassNode node)

### visitConstructorCallExpression

    if (target==null && call.getLineNumber()>0) {
    public void visitConstructorCallExpression(ConstructorCallExpression call)

### visitForLoop

    ClassNode componentType = inferLoopElementType(collectionType);
    public void visitForLoop(ForStatement forLoop)

### visitMethod

    @Override
    public void visitMethod(MethodNode node)

### visitMethodCallExpression

    public void visitMethodCallExpression(MethodCallExpression call)

### visitSpreadExpression

    }
    public void visitSpreadExpression(SpreadExpression expression)

Groovy Documentation