|
Groovy 2.0.0-rc-2 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor
public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
The main class code visitor responsible for static type checking. It will perform various inspections like checking assignment types, type inference, ... Eventually, class nodes may be annotated with inferred type information.
Nested Class Summary | |
---|---|
protected static interface |
StaticTypeCheckingVisitor.SignatureCodec
|
protected static class |
StaticTypeCheckingVisitor.SignatureCodecFactory
|
Field Summary | |
---|---|
static MethodNode |
CLOSURE_CALL_NO_ARG
|
static MethodNode |
CLOSURE_CALL_ONE_ARG
|
static MethodNode |
CLOSURE_CALL_VARGS
|
Constructor Summary | |
StaticTypeCheckingVisitor(SourceUnit source, ClassNode cn, TypeCheckerPluginFactory pluginFactory)
|
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
public static final MethodNode CLOSURE_CALL_NO_ARG
public static final MethodNode CLOSURE_CALL_ONE_ARG
public static final MethodNode CLOSURE_CALL_VARGS
Constructor Detail |
---|
public StaticTypeCheckingVisitor(SourceUnit source, ClassNode cn, TypeCheckerPluginFactory pluginFactory)
Method Detail |
---|
} else { protected void addError(String msg, ASTNode expr)
protected void addStaticTypeError(String msg, ASTNode expr)
protected void addTypeCheckingInfoAnnotation(MethodNode node)
protected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode... args)
protected SourceUnit getSourceUnit()
protected ClassNode getType(ASTNode exp)
protected ClassNode[] getTypeCheckingAnnotations()
public static ClassNode inferLoopElementType(ClassNode collectionType)
public boolean isSkipMode(AnnotatedNode node)
public void performSecondPass()
public void setErrorCollector(ErrorCollector errorCollector)
public void setMethodsToBeVisited(Set methodsToBeVisited)
protected boolean shouldSkipClassNode(ClassNode node)
if (Integer_TYPE.equals(fromType) && Integer_TYPE.equals(toType)) { public void visitAttributeExpression(AttributeExpression expression)
} public void visitBinaryExpression(BinaryExpression expression)
storeTargetMethod(expression, node); public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)
// is an empty list expression ([]). In that case and only in that case, the inferred type public void visitCastExpression(CastExpression expression)
IteratorinnerClasses = classNode.getInnerClasses(); public void visitClass(ClassNode node)
public void visitVariableExpression(VariableExpression vexp) { public void visitClassExpression(ClassExpression expression)
private void saveVariableExpressionMetadata(final SetclosureSharedExpressions, final Map typesBeforeVisit) { public void visitClosureExpression(ClosureExpression expression)
@Override public void visitConstructorCallExpression(ConstructorCallExpression call)
if (node != null) { protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
super.visitForLoop(forLoop); public void visitField(FieldNode node)
componentType = genericsTypes[0].getType(); public void visitForLoop(ForStatement forLoop)
collectionType
- the type of the collection
storeType(exp, getOriginalDeclarationType(exp)); public void visitIfElse(IfStatement ifElse)
} public void visitMethod(MethodNode node)
public void visitMethodCallExpression(MethodCallExpression call)
} else if (typeRe == ArrayList_TYPE) { public void visitPostfixExpression(PostfixExpression expression)
@Override public void visitPrefixExpression(PrefixExpression expression)
addStaticTypeError("No such property: " + expression.getPropertyAsString() + public void visitPropertyExpression(PropertyExpression pexp)
final Expression leftExpression = expression.getLeftExpression(); public void visitRangeExpression(RangeExpression expression)
node.setDeclaringClass(receiver); public void visitReturnStatement(ReturnStatement statement)
addStaticTypeError("Cannot find matching method " + receiver.getText() + "#" + toMethodParametersString(name, args), call); public void visitStaticMethodCallExpression(StaticMethodCallExpression call)
if (isDouble(leftRedirect) && isDouble(rightRedirect)) return double_TYPE; public void visitTernaryExpression(TernaryExpression expression)
private void negativeOrPositiveUnary(Expression expression, String name) { public void visitUnaryMinusExpression(UnaryMinusExpression expression)
MethodNode node = findMethodOrFail(inner, exprType, name); public void visitUnaryPlusExpression(UnaryPlusExpression expression)
// or a member of a class used in a 'with' public void visitVariableExpression(VariableExpression vexp)
String name = type == PLUS_PLUS ? "next" : type == MINUS_MINUS ? "previous" : null; public void visitWhileLoop(WhileStatement loop)
Copyright © 2003-2012 The Codehaus. All rights reserved.