Search in sources :

Example 1 with ArrayTypeTreeImpl

use of org.sonar.java.model.JavaTree.ArrayTypeTreeImpl in project sonar-java by SonarSource.

the class TreeFactory method newVariableDeclaratorId.

public VariableTreeImpl newVariableDeclaratorId(InternalSyntaxToken identifierToken, Optional<List<Tuple<Optional<List<AnnotationTreeImpl>>, Tuple<InternalSyntaxToken, InternalSyntaxToken>>>> dims) {
    IdentifierTreeImpl identifier = new IdentifierTreeImpl(identifierToken);
    ArrayTypeTreeImpl nestedDimensions = newArrayTypeTreeWithAnnotations(dims);
    return new VariableTreeImpl(identifier, nestedDimensions);
}
Also used : IdentifierTreeImpl(org.sonar.java.model.expression.IdentifierTreeImpl) ArrayTypeTreeImpl(org.sonar.java.model.JavaTree.ArrayTypeTreeImpl) VariableTreeImpl(org.sonar.java.model.declaration.VariableTreeImpl)

Example 2 with ArrayTypeTreeImpl

use of org.sonar.java.model.JavaTree.ArrayTypeTreeImpl in project sonar-java by SonarSource.

the class TreeFactory method completeVariableDeclarator.

public VariableTreeImpl completeVariableDeclarator(InternalSyntaxToken identifierToken, Optional<List<Tuple<Optional<List<AnnotationTreeImpl>>, Tuple<InternalSyntaxToken, InternalSyntaxToken>>>> dimensions, Optional<VariableTreeImpl> partial) {
    IdentifierTreeImpl identifier = new IdentifierTreeImpl(identifierToken);
    ArrayTypeTreeImpl nestedDimensions = newArrayTypeTreeWithAnnotations(dimensions);
    if (partial.isPresent()) {
        return partial.get().completeIdentifierAndDims(identifier, nestedDimensions);
    } else {
        return new VariableTreeImpl(identifier, nestedDimensions);
    }
}
Also used : IdentifierTreeImpl(org.sonar.java.model.expression.IdentifierTreeImpl) ArrayTypeTreeImpl(org.sonar.java.model.JavaTree.ArrayTypeTreeImpl) VariableTreeImpl(org.sonar.java.model.declaration.VariableTreeImpl)

Example 3 with ArrayTypeTreeImpl

use of org.sonar.java.model.JavaTree.ArrayTypeTreeImpl in project sonar-java by SonarSource.

the class TreeFactory method newDotClassSelector.

public ExpressionTree newDotClassSelector(Optional<List<Tuple<InternalSyntaxToken, InternalSyntaxToken>>> dimensions, InternalSyntaxToken dotToken, InternalSyntaxToken classToken) {
    IdentifierTreeImpl identifier = new IdentifierTreeImpl(classToken);
    ArrayTypeTreeImpl nestedDimensions = newArrayTypeTree(dimensions);
    return new MemberSelectExpressionTreeImpl(nestedDimensions, dotToken, identifier);
}
Also used : IdentifierTreeImpl(org.sonar.java.model.expression.IdentifierTreeImpl) ArrayTypeTreeImpl(org.sonar.java.model.JavaTree.ArrayTypeTreeImpl) MemberSelectExpressionTreeImpl(org.sonar.java.model.expression.MemberSelectExpressionTreeImpl)

Example 4 with ArrayTypeTreeImpl

use of org.sonar.java.model.JavaTree.ArrayTypeTreeImpl in project sonar-java by SonarSource.

the class TreeFactory method newArrayTypeTreeWithAnnotations.

private static ArrayTypeTreeImpl newArrayTypeTreeWithAnnotations(TypeTree type, Tuple<Optional<List<AnnotationTreeImpl>>, Tuple<InternalSyntaxToken, InternalSyntaxToken>> dim) {
    List<AnnotationTreeImpl> annotations = dim.first().or(ImmutableList.<AnnotationTreeImpl>of());
    InternalSyntaxToken openBracketToken = dim.second().first();
    InternalSyntaxToken closeBracketToken = dim.second().second();
    return new ArrayTypeTreeImpl(type, annotations, openBracketToken, closeBracketToken);
}
Also used : AnnotationTreeImpl(org.sonar.java.model.declaration.AnnotationTreeImpl) ArrayTypeTreeImpl(org.sonar.java.model.JavaTree.ArrayTypeTreeImpl) InternalSyntaxToken(org.sonar.java.model.InternalSyntaxToken)

Example 5 with ArrayTypeTreeImpl

use of org.sonar.java.model.JavaTree.ArrayTypeTreeImpl in project sonar-java by SonarSource.

the class TreeFactory method basicClassExpression.

public ExpressionTree basicClassExpression(PrimitiveTypeTreeImpl basicType, Optional<List<Tuple<InternalSyntaxToken, InternalSyntaxToken>>> dimensions, InternalSyntaxToken dotToken, InternalSyntaxToken classToken) {
    // 15.8.2. Class Literals
    // int.class
    // int[].class
    IdentifierTreeImpl classIdentifier = new IdentifierTreeImpl(classToken);
    ArrayTypeTreeImpl nestedDimensions = newArrayTypeTree(dimensions);
    TypeTree typeTree = applyDim(basicType, nestedDimensions);
    return new MemberSelectExpressionTreeImpl((ExpressionTree) typeTree, dotToken, classIdentifier);
}
Also used : ParameterizedTypeTree(org.sonar.plugins.java.api.tree.ParameterizedTypeTree) TypeTree(org.sonar.plugins.java.api.tree.TypeTree) IdentifierTreeImpl(org.sonar.java.model.expression.IdentifierTreeImpl) ArrayTypeTreeImpl(org.sonar.java.model.JavaTree.ArrayTypeTreeImpl) MemberSelectExpressionTreeImpl(org.sonar.java.model.expression.MemberSelectExpressionTreeImpl)

Aggregations

ArrayTypeTreeImpl (org.sonar.java.model.JavaTree.ArrayTypeTreeImpl)7 IdentifierTreeImpl (org.sonar.java.model.expression.IdentifierTreeImpl)5 InternalSyntaxToken (org.sonar.java.model.InternalSyntaxToken)3 AnnotationTreeImpl (org.sonar.java.model.declaration.AnnotationTreeImpl)2 VariableTreeImpl (org.sonar.java.model.declaration.VariableTreeImpl)2 MemberSelectExpressionTreeImpl (org.sonar.java.model.expression.MemberSelectExpressionTreeImpl)2 ParameterizedTypeTree (org.sonar.plugins.java.api.tree.ParameterizedTypeTree)2 TypeTree (org.sonar.plugins.java.api.tree.TypeTree)2 CheckForNull (javax.annotation.CheckForNull)1 MethodTreeImpl (org.sonar.java.model.declaration.MethodTreeImpl)1 BlockTreeImpl (org.sonar.java.model.statement.BlockTreeImpl)1