Search in sources :

Example 31 with TypeTree

use of org.sonar.plugins.java.api.tree.TypeTree in project sonar-java by SonarSource.

the class TreeFactory method newExpression.

public ExpressionTree newExpression(InternalSyntaxToken newToken, Optional<List<AnnotationTreeImpl>> annotations, ExpressionTree partial) {
    TypeTree typeTree;
    if (partial.is(Tree.Kind.NEW_CLASS)) {
        NewClassTreeImpl newClassTree = (NewClassTreeImpl) partial;
        newClassTree.completeWithNewKeyword(newToken);
        typeTree = newClassTree.identifier();
    } else {
        NewArrayTreeImpl newArrayTree = (NewArrayTreeImpl) partial;
        newArrayTree.completeWithNewKeyword(newToken);
        typeTree = newArrayTree.type();
    }
    completeTypeTreeWithAnnotations(typeTree, annotations);
    return partial;
}
Also used : ParameterizedTypeTree(org.sonar.plugins.java.api.tree.ParameterizedTypeTree) TypeTree(org.sonar.plugins.java.api.tree.TypeTree) NewArrayTreeImpl(org.sonar.java.model.expression.NewArrayTreeImpl) NewClassTreeImpl(org.sonar.java.model.expression.NewClassTreeImpl)

Aggregations

TypeTree (org.sonar.plugins.java.api.tree.TypeTree)31 ParameterizedTypeTree (org.sonar.plugins.java.api.tree.ParameterizedTypeTree)11 Type (org.sonar.plugins.java.api.semantic.Type)8 ArrayTypeTree (org.sonar.plugins.java.api.tree.ArrayTypeTree)6 MethodTree (org.sonar.plugins.java.api.tree.MethodTree)6 NewClassTree (org.sonar.plugins.java.api.tree.NewClassTree)6 VariableTree (org.sonar.plugins.java.api.tree.VariableTree)6 ClassTree (org.sonar.plugins.java.api.tree.ClassTree)5 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)5 MemberSelectExpressionTree (org.sonar.plugins.java.api.tree.MemberSelectExpressionTree)4 PrimitiveTypeTree (org.sonar.plugins.java.api.tree.PrimitiveTypeTree)4 UnionTypeTree (org.sonar.plugins.java.api.tree.UnionTypeTree)4 Test (org.junit.Test)3 IdentifierTreeImpl (org.sonar.java.model.expression.IdentifierTreeImpl)3 Symbol (org.sonar.plugins.java.api.semantic.Symbol)3 ExpressionTree (org.sonar.plugins.java.api.tree.ExpressionTree)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 HashSet (java.util.HashSet)2 CheckForNull (javax.annotation.CheckForNull)2