Search in sources :

Example 21 with NewArrayTree

use of com.sun.source.tree.NewArrayTree in project checker-framework by typetools.

the class CFGTranslationPhaseOne method visitNewArray.

@Override
public Node visitNewArray(NewArrayTree tree, Void p) {
    // see JLS 15.10
    ArrayType type = (ArrayType) TreeUtils.typeOf(tree);
    TypeMirror elemType = type.getComponentType();
    List<? extends ExpressionTree> dimensions = tree.getDimensions();
    List<? extends ExpressionTree> initializers = tree.getInitializers();
    assert dimensions != null;
    List<Node> dimensionNodes = CollectionsPlume.mapList(dim -> unaryNumericPromotion(scan(dim, p)), dimensions);
    List<Node> initializerNodes;
    if (initializers == null) {
        initializerNodes = Collections.emptyList();
    } else {
        initializerNodes = CollectionsPlume.mapList(init -> assignConvert(scan(init, p), elemType), initializers);
    }
    Node node = new ArrayCreationNode(tree, type, dimensionNodes, initializerNodes);
    extendWithNodeWithExceptions(node, newArrayExceptionTypes);
    return node;
}
Also used : ArrayType(javax.lang.model.type.ArrayType) CompoundAssignmentTree(com.sun.source.tree.CompoundAssignmentTree) LiteralTree(com.sun.source.tree.LiteralTree) NumericalMultiplicationNode(org.checkerframework.dataflow.cfg.node.NumericalMultiplicationNode) ArrayCreationNode(org.checkerframework.dataflow.cfg.node.ArrayCreationNode) TypeElement(javax.lang.model.element.TypeElement) ValueLiteralNode(org.checkerframework.dataflow.cfg.node.ValueLiteralNode) IdentityMostlySingleton(org.checkerframework.dataflow.util.IdentityMostlySingleton) ReferenceType(javax.lang.model.type.ReferenceType) Elements(javax.lang.model.util.Elements) StringConversionNode(org.checkerframework.dataflow.cfg.node.StringConversionNode) MethodInvocationTree(com.sun.source.tree.MethodInvocationTree) UnsignedRightShiftNode(org.checkerframework.dataflow.cfg.node.UnsignedRightShiftNode) AssignmentTree(com.sun.source.tree.AssignmentTree) LeftShiftNode(org.checkerframework.dataflow.cfg.node.LeftShiftNode) TypeCastTree(com.sun.source.tree.TypeCastTree) LambdaExpressionTree(com.sun.source.tree.LambdaExpressionTree) PrimitiveTypeNode(org.checkerframework.dataflow.cfg.node.PrimitiveTypeNode) Map(java.util.Map) ForLoopTree(com.sun.source.tree.ForLoopTree) Trees(com.sun.source.util.Trees) FloatLiteralNode(org.checkerframework.dataflow.cfg.node.FloatLiteralNode) InstanceOfTree(com.sun.source.tree.InstanceOfTree) ParenthesizedTree(com.sun.source.tree.ParenthesizedTree) ArrayType(javax.lang.model.type.ArrayType) ConditionalExpressionTree(com.sun.source.tree.ConditionalExpressionTree) TreePath(com.sun.source.util.TreePath) UnderlyingAST(org.checkerframework.dataflow.cfg.UnderlyingAST) Set(java.util.Set) LessThanNode(org.checkerframework.dataflow.cfg.node.LessThanNode) Element(javax.lang.model.element.Element) MemberSelectTree(com.sun.source.tree.MemberSelectTree) BitwiseOrNode(org.checkerframework.dataflow.cfg.node.BitwiseOrNode) TreeUtils(org.checkerframework.javacutil.TreeUtils) ExpressionStatementTree(com.sun.source.tree.ExpressionStatementTree) LocalVariableNode(org.checkerframework.dataflow.cfg.node.LocalVariableNode) NarrowingConversionNode(org.checkerframework.dataflow.cfg.node.NarrowingConversionNode) TreeScanner(com.sun.source.util.TreeScanner) ThrowTree(com.sun.source.tree.ThrowTree) EqualToNode(org.checkerframework.dataflow.cfg.node.EqualToNode) NumericalPlusNode(org.checkerframework.dataflow.cfg.node.NumericalPlusNode) BlockTree(com.sun.source.tree.BlockTree) ConditionalAndNode(org.checkerframework.dataflow.cfg.node.ConditionalAndNode) VariableDeclarationNode(org.checkerframework.dataflow.cfg.node.VariableDeclarationNode) EnhancedForLoopTree(com.sun.source.tree.EnhancedForLoopTree) ClassDeclarationNode(org.checkerframework.dataflow.cfg.node.ClassDeclarationNode) TypesUtils(org.checkerframework.javacutil.TypesUtils) ReturnTree(com.sun.source.tree.ReturnTree) ArrayTypeTree(com.sun.source.tree.ArrayTypeTree) LabeledStatementTree(com.sun.source.tree.LabeledStatementTree) IntegerDivisionNode(org.checkerframework.dataflow.cfg.node.IntegerDivisionNode) UnaryTree(com.sun.source.tree.UnaryTree) AssertionErrorNode(org.checkerframework.dataflow.cfg.node.AssertionErrorNode) VariableElement(javax.lang.model.element.VariableElement) InstanceOfNode(org.checkerframework.dataflow.cfg.node.InstanceOfNode) VariableTree(com.sun.source.tree.VariableTree) BooleanLiteralNode(org.checkerframework.dataflow.cfg.node.BooleanLiteralNode) ThisNode(org.checkerframework.dataflow.cfg.node.ThisNode) TypeParameterTree(com.sun.source.tree.TypeParameterTree) ArrayList(java.util.ArrayList) AssignmentNode(org.checkerframework.dataflow.cfg.node.AssignmentNode) LinkedHashMap(java.util.LinkedHashMap) NullLiteralNode(org.checkerframework.dataflow.cfg.node.NullLiteralNode) ArrayTypeNode(org.checkerframework.dataflow.cfg.node.ArrayTypeNode) LambdaResultExpressionNode(org.checkerframework.dataflow.cfg.node.LambdaResultExpressionNode) Kind(com.sun.source.tree.Tree.Kind) NewClassTree(com.sun.source.tree.NewClassTree) IntegerRemainderNode(org.checkerframework.dataflow.cfg.node.IntegerRemainderNode) ParameterizedTypeTree(com.sun.source.tree.ParameterizedTypeTree) FindDistinct(org.checkerframework.checker.interning.qual.FindDistinct) FieldAccessNode(org.checkerframework.dataflow.cfg.node.FieldAccessNode) DeclaredType(javax.lang.model.type.DeclaredType) TreePathUtil(org.checkerframework.javacutil.TreePathUtil) ConditionalOrNode(org.checkerframework.dataflow.cfg.node.ConditionalOrNode) BreakTree(com.sun.source.tree.BreakTree) FlowRule(org.checkerframework.dataflow.analysis.Store.FlowRule) NotEqualNode(org.checkerframework.dataflow.cfg.node.NotEqualNode) ImportTree(com.sun.source.tree.ImportTree) Tree(com.sun.source.tree.Tree) LinkedHashSet(java.util.LinkedHashSet) BitwiseXorNode(org.checkerframework.dataflow.cfg.node.BitwiseXorNode) ArrayAccessNode(org.checkerframework.dataflow.cfg.node.ArrayAccessNode) ExplicitThisNode(org.checkerframework.dataflow.cfg.node.ExplicitThisNode) StringConcatenateNode(org.checkerframework.dataflow.cfg.node.StringConcatenateNode) ExpressionTree(com.sun.source.tree.ExpressionTree) NullChkNode(org.checkerframework.dataflow.cfg.node.NullChkNode) CharacterLiteralNode(org.checkerframework.dataflow.cfg.node.CharacterLiteralNode) FloatingDivisionNode(org.checkerframework.dataflow.cfg.node.FloatingDivisionNode) FunctionalInterfaceNode(org.checkerframework.dataflow.cfg.node.FunctionalInterfaceNode) StringConcatenateAssignmentNode(org.checkerframework.dataflow.cfg.node.StringConcatenateAssignmentNode) WildcardTree(com.sun.source.tree.WildcardTree) UnionTypeTree(com.sun.source.tree.UnionTypeTree) ElementUtils(org.checkerframework.javacutil.ElementUtils) CollectionsPlume(org.plumelib.util.CollectionsPlume) ArrayAccessTree(com.sun.source.tree.ArrayAccessTree) BugInCF(org.checkerframework.javacutil.BugInCF) TypeCastNode(org.checkerframework.dataflow.cfg.node.TypeCastNode) AnnotatedTypeTree(com.sun.source.tree.AnnotatedTypeTree) MethodAccessNode(org.checkerframework.dataflow.cfg.node.MethodAccessNode) IdentifierTree(com.sun.source.tree.IdentifierTree) CatchTree(com.sun.source.tree.CatchTree) NewArrayTree(com.sun.source.tree.NewArrayTree) WideningConversionNode(org.checkerframework.dataflow.cfg.node.WideningConversionNode) LongLiteralNode(org.checkerframework.dataflow.cfg.node.LongLiteralNode) MarkerNode(org.checkerframework.dataflow.cfg.node.MarkerNode) Pair(org.checkerframework.javacutil.Pair) ImplicitThisNode(org.checkerframework.dataflow.cfg.node.ImplicitThisNode) FloatingRemainderNode(org.checkerframework.dataflow.cfg.node.FloatingRemainderNode) ClassNameNode(org.checkerframework.dataflow.cfg.node.ClassNameNode) IdentityHashMap(java.util.IdentityHashMap) ObjectCreationNode(org.checkerframework.dataflow.cfg.node.ObjectCreationNode) PackageNameNode(org.checkerframework.dataflow.cfg.node.PackageNameNode) ContinueTree(com.sun.source.tree.ContinueTree) DoubleLiteralNode(org.checkerframework.dataflow.cfg.node.DoubleLiteralNode) SuperNode(org.checkerframework.dataflow.cfg.node.SuperNode) CaseTree(com.sun.source.tree.CaseTree) Types(javax.lang.model.util.Types) IntegerLiteralNode(org.checkerframework.dataflow.cfg.node.IntegerLiteralNode) SignedRightShiftNode(org.checkerframework.dataflow.cfg.node.SignedRightShiftNode) CompilationUnitTree(com.sun.source.tree.CompilationUnitTree) SwitchTree(com.sun.source.tree.SwitchTree) TypeKind(javax.lang.model.type.TypeKind) List(java.util.List) PrimitiveTypeTree(com.sun.source.tree.PrimitiveTypeTree) SynchronizedTree(com.sun.source.tree.SynchronizedTree) AssertTree(com.sun.source.tree.AssertTree) StatementTree(com.sun.source.tree.StatementTree) ThrowNode(org.checkerframework.dataflow.cfg.node.ThrowNode) ModifiersTree(com.sun.source.tree.ModifiersTree) GreaterThanOrEqualNode(org.checkerframework.dataflow.cfg.node.GreaterThanOrEqualNode) WhileLoopTree(com.sun.source.tree.WhileLoopTree) StringLiteralNode(org.checkerframework.dataflow.cfg.node.StringLiteralNode) TypeKindUtils(org.checkerframework.javacutil.TypeKindUtils) TernaryExpressionNode(org.checkerframework.dataflow.cfg.node.TernaryExpressionNode) TreeBuilder(org.checkerframework.javacutil.trees.TreeBuilder) AnnotationTree(com.sun.source.tree.AnnotationTree) MethodTree(com.sun.source.tree.MethodTree) BitwiseAndNode(org.checkerframework.dataflow.cfg.node.BitwiseAndNode) BinaryTree(com.sun.source.tree.BinaryTree) TerminatesExecution(org.checkerframework.dataflow.qual.TerminatesExecution) EmptyStatementTree(com.sun.source.tree.EmptyStatementTree) HashMap(java.util.HashMap) ParameterizedTypeNode(org.checkerframework.dataflow.cfg.node.ParameterizedTypeNode) CaseNode(org.checkerframework.dataflow.cfg.node.CaseNode) HashSet(java.util.HashSet) SwitchExpressionNode(org.checkerframework.dataflow.cfg.node.SwitchExpressionNode) NumericalAdditionNode(org.checkerframework.dataflow.cfg.node.NumericalAdditionNode) ClassTree(com.sun.source.tree.ClassTree) Nullable(org.checkerframework.checker.nullness.qual.Nullable) Name(javax.lang.model.element.Name) NumericalSubtractionNode(org.checkerframework.dataflow.cfg.node.NumericalSubtractionNode) BitwiseComplementNode(org.checkerframework.dataflow.cfg.node.BitwiseComplementNode) IfTree(com.sun.source.tree.IfTree) ConditionalNotNode(org.checkerframework.dataflow.cfg.node.ConditionalNotNode) ElementKind(javax.lang.model.element.ElementKind) NumericalMinusNode(org.checkerframework.dataflow.cfg.node.NumericalMinusNode) MemberReferenceTree(com.sun.source.tree.MemberReferenceTree) ExecutableElement(javax.lang.model.element.ExecutableElement) ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) MethodInvocationNode(org.checkerframework.dataflow.cfg.node.MethodInvocationNode) GreaterThanNode(org.checkerframework.dataflow.cfg.node.GreaterThanNode) LessThanOrEqualNode(org.checkerframework.dataflow.cfg.node.LessThanOrEqualNode) SynchronizedNode(org.checkerframework.dataflow.cfg.node.SynchronizedNode) TypeMirror(javax.lang.model.type.TypeMirror) AnnotationProvider(org.checkerframework.javacutil.AnnotationProvider) ErroneousTree(com.sun.source.tree.ErroneousTree) DoWhileLoopTree(com.sun.source.tree.DoWhileLoopTree) ProcessingEnvironment(javax.annotation.processing.ProcessingEnvironment) TryTree(com.sun.source.tree.TryTree) PrimitiveType(javax.lang.model.type.PrimitiveType) Collections(java.util.Collections) Node(org.checkerframework.dataflow.cfg.node.Node) TypeMirror(javax.lang.model.type.TypeMirror) NumericalMultiplicationNode(org.checkerframework.dataflow.cfg.node.NumericalMultiplicationNode) ArrayCreationNode(org.checkerframework.dataflow.cfg.node.ArrayCreationNode) ValueLiteralNode(org.checkerframework.dataflow.cfg.node.ValueLiteralNode) StringConversionNode(org.checkerframework.dataflow.cfg.node.StringConversionNode) UnsignedRightShiftNode(org.checkerframework.dataflow.cfg.node.UnsignedRightShiftNode) LeftShiftNode(org.checkerframework.dataflow.cfg.node.LeftShiftNode) PrimitiveTypeNode(org.checkerframework.dataflow.cfg.node.PrimitiveTypeNode) FloatLiteralNode(org.checkerframework.dataflow.cfg.node.FloatLiteralNode) LessThanNode(org.checkerframework.dataflow.cfg.node.LessThanNode) BitwiseOrNode(org.checkerframework.dataflow.cfg.node.BitwiseOrNode) LocalVariableNode(org.checkerframework.dataflow.cfg.node.LocalVariableNode) NarrowingConversionNode(org.checkerframework.dataflow.cfg.node.NarrowingConversionNode) EqualToNode(org.checkerframework.dataflow.cfg.node.EqualToNode) NumericalPlusNode(org.checkerframework.dataflow.cfg.node.NumericalPlusNode) ConditionalAndNode(org.checkerframework.dataflow.cfg.node.ConditionalAndNode) VariableDeclarationNode(org.checkerframework.dataflow.cfg.node.VariableDeclarationNode) ClassDeclarationNode(org.checkerframework.dataflow.cfg.node.ClassDeclarationNode) IntegerDivisionNode(org.checkerframework.dataflow.cfg.node.IntegerDivisionNode) AssertionErrorNode(org.checkerframework.dataflow.cfg.node.AssertionErrorNode) InstanceOfNode(org.checkerframework.dataflow.cfg.node.InstanceOfNode) BooleanLiteralNode(org.checkerframework.dataflow.cfg.node.BooleanLiteralNode) ThisNode(org.checkerframework.dataflow.cfg.node.ThisNode) AssignmentNode(org.checkerframework.dataflow.cfg.node.AssignmentNode) NullLiteralNode(org.checkerframework.dataflow.cfg.node.NullLiteralNode) ArrayTypeNode(org.checkerframework.dataflow.cfg.node.ArrayTypeNode) LambdaResultExpressionNode(org.checkerframework.dataflow.cfg.node.LambdaResultExpressionNode) IntegerRemainderNode(org.checkerframework.dataflow.cfg.node.IntegerRemainderNode) FieldAccessNode(org.checkerframework.dataflow.cfg.node.FieldAccessNode) ConditionalOrNode(org.checkerframework.dataflow.cfg.node.ConditionalOrNode) NotEqualNode(org.checkerframework.dataflow.cfg.node.NotEqualNode) BitwiseXorNode(org.checkerframework.dataflow.cfg.node.BitwiseXorNode) ArrayAccessNode(org.checkerframework.dataflow.cfg.node.ArrayAccessNode) ExplicitThisNode(org.checkerframework.dataflow.cfg.node.ExplicitThisNode) StringConcatenateNode(org.checkerframework.dataflow.cfg.node.StringConcatenateNode) NullChkNode(org.checkerframework.dataflow.cfg.node.NullChkNode) CharacterLiteralNode(org.checkerframework.dataflow.cfg.node.CharacterLiteralNode) FloatingDivisionNode(org.checkerframework.dataflow.cfg.node.FloatingDivisionNode) FunctionalInterfaceNode(org.checkerframework.dataflow.cfg.node.FunctionalInterfaceNode) StringConcatenateAssignmentNode(org.checkerframework.dataflow.cfg.node.StringConcatenateAssignmentNode) TypeCastNode(org.checkerframework.dataflow.cfg.node.TypeCastNode) MethodAccessNode(org.checkerframework.dataflow.cfg.node.MethodAccessNode) WideningConversionNode(org.checkerframework.dataflow.cfg.node.WideningConversionNode) LongLiteralNode(org.checkerframework.dataflow.cfg.node.LongLiteralNode) MarkerNode(org.checkerframework.dataflow.cfg.node.MarkerNode) ImplicitThisNode(org.checkerframework.dataflow.cfg.node.ImplicitThisNode) FloatingRemainderNode(org.checkerframework.dataflow.cfg.node.FloatingRemainderNode) ClassNameNode(org.checkerframework.dataflow.cfg.node.ClassNameNode) ObjectCreationNode(org.checkerframework.dataflow.cfg.node.ObjectCreationNode) PackageNameNode(org.checkerframework.dataflow.cfg.node.PackageNameNode) DoubleLiteralNode(org.checkerframework.dataflow.cfg.node.DoubleLiteralNode) SuperNode(org.checkerframework.dataflow.cfg.node.SuperNode) IntegerLiteralNode(org.checkerframework.dataflow.cfg.node.IntegerLiteralNode) SignedRightShiftNode(org.checkerframework.dataflow.cfg.node.SignedRightShiftNode) ThrowNode(org.checkerframework.dataflow.cfg.node.ThrowNode) GreaterThanOrEqualNode(org.checkerframework.dataflow.cfg.node.GreaterThanOrEqualNode) StringLiteralNode(org.checkerframework.dataflow.cfg.node.StringLiteralNode) TernaryExpressionNode(org.checkerframework.dataflow.cfg.node.TernaryExpressionNode) BitwiseAndNode(org.checkerframework.dataflow.cfg.node.BitwiseAndNode) ParameterizedTypeNode(org.checkerframework.dataflow.cfg.node.ParameterizedTypeNode) CaseNode(org.checkerframework.dataflow.cfg.node.CaseNode) SwitchExpressionNode(org.checkerframework.dataflow.cfg.node.SwitchExpressionNode) NumericalAdditionNode(org.checkerframework.dataflow.cfg.node.NumericalAdditionNode) NumericalSubtractionNode(org.checkerframework.dataflow.cfg.node.NumericalSubtractionNode) BitwiseComplementNode(org.checkerframework.dataflow.cfg.node.BitwiseComplementNode) ConditionalNotNode(org.checkerframework.dataflow.cfg.node.ConditionalNotNode) NumericalMinusNode(org.checkerframework.dataflow.cfg.node.NumericalMinusNode) ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) MethodInvocationNode(org.checkerframework.dataflow.cfg.node.MethodInvocationNode) GreaterThanNode(org.checkerframework.dataflow.cfg.node.GreaterThanNode) LessThanOrEqualNode(org.checkerframework.dataflow.cfg.node.LessThanOrEqualNode) SynchronizedNode(org.checkerframework.dataflow.cfg.node.SynchronizedNode) Node(org.checkerframework.dataflow.cfg.node.Node) ArrayCreationNode(org.checkerframework.dataflow.cfg.node.ArrayCreationNode)

Aggregations

NewArrayTree (com.sun.source.tree.NewArrayTree)21 ExpressionTree (com.sun.source.tree.ExpressionTree)19 MethodInvocationTree (com.sun.source.tree.MethodInvocationTree)12 Tree (com.sun.source.tree.Tree)11 AssignmentTree (com.sun.source.tree.AssignmentTree)10 CompoundAssignmentTree (com.sun.source.tree.CompoundAssignmentTree)10 MemberSelectTree (com.sun.source.tree.MemberSelectTree)10 BinaryTree (com.sun.source.tree.BinaryTree)9 ArrayAccessTree (com.sun.source.tree.ArrayAccessTree)8 ConditionalExpressionTree (com.sun.source.tree.ConditionalExpressionTree)8 IdentifierTree (com.sun.source.tree.IdentifierTree)8 LiteralTree (com.sun.source.tree.LiteralTree)8 MethodTree (com.sun.source.tree.MethodTree)8 NewClassTree (com.sun.source.tree.NewClassTree)8 TypeCastTree (com.sun.source.tree.TypeCastTree)8 VariableTree (com.sun.source.tree.VariableTree)8 ClassTree (com.sun.source.tree.ClassTree)7 ParameterizedTypeTree (com.sun.source.tree.ParameterizedTypeTree)6 ReturnTree (com.sun.source.tree.ReturnTree)6 ExecutableElement (javax.lang.model.element.ExecutableElement)6