Search in sources :

Example 6 with ListHashMap

use of org.codehaus.groovy.util.ListHashMap in project groovy by apache.

the class StaticTypeCheckingVisitor method saveVariableExpressionMetadata.

protected void saveVariableExpressionMetadata(final Set<VariableExpression> closureSharedExpressions, final Map<VariableExpression, ListHashMap> typesBeforeVisit) {
    for (VariableExpression ve : closureSharedExpressions) {
        // GROOVY-6921: We must force a call to getType in order to update closure shared variable which types are
        // inferred thanks to closure parameter type inference
        getType(ve);
        ListHashMap<StaticTypesMarker, Object> metadata = new ListHashMap<StaticTypesMarker, Object>();
        for (StaticTypesMarker marker : StaticTypesMarker.values()) {
            Object value = ve.getNodeMetaData(marker);
            if (value != null) {
                metadata.put(marker, value);
            }
        }
        typesBeforeVisit.put(ve, metadata);
        Variable accessedVariable = ve.getAccessedVariable();
        if (accessedVariable != ve && accessedVariable instanceof VariableExpression) {
            saveVariableExpressionMetadata(Collections.singleton((VariableExpression) accessedVariable), typesBeforeVisit);
        }
    }
}
Also used : Variable(org.codehaus.groovy.ast.Variable) DynamicVariable(org.codehaus.groovy.ast.DynamicVariable) ListHashMap(org.codehaus.groovy.util.ListHashMap)

Aggregations

ListHashMap (org.codehaus.groovy.util.ListHashMap)6 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 ClassNode (org.codehaus.groovy.ast.ClassNode)3 InnerClassNode (org.codehaus.groovy.ast.InnerClassNode)3 LowestUpperBoundClassNode (org.codehaus.groovy.ast.tools.WideningCategories.LowestUpperBoundClassNode)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 DynamicVariable (org.codehaus.groovy.ast.DynamicVariable)2 MethodNode (org.codehaus.groovy.ast.MethodNode)2 Parameter (org.codehaus.groovy.ast.Parameter)2 Variable (org.codehaus.groovy.ast.Variable)2 CaseStatement (org.codehaus.groovy.ast.stmt.CaseStatement)2 CatchStatement (org.codehaus.groovy.ast.stmt.CatchStatement)2 EmptyStatement (org.codehaus.groovy.ast.stmt.EmptyStatement)2 ForStatement (org.codehaus.groovy.ast.stmt.ForStatement)2 IfStatement (org.codehaus.groovy.ast.stmt.IfStatement)2 ReturnStatement (org.codehaus.groovy.ast.stmt.ReturnStatement)2