use of org.sonar.java.model.JavaTree.ArrayTypeTreeImpl in project sonar-java by SonarSource.
the class TreeFactory method newMethodOrConstructor.
private static MethodTreeImpl newMethodOrConstructor(Optional<TypeTree> type, InternalSyntaxToken identifierToken, FormalParametersListTreeImpl parameters, Optional<List<Tuple<Optional<List<AnnotationTreeImpl>>, Tuple<InternalSyntaxToken, InternalSyntaxToken>>>> annotatedDimensions, Optional<Tuple<InternalSyntaxToken, QualifiedIdentifierListTreeImpl>> throwsClause, JavaTree blockOrSemicolon) {
IdentifierTreeImpl identifier = new IdentifierTreeImpl(identifierToken);
ArrayTypeTreeImpl nestedDimensions = newArrayTypeTreeWithAnnotations(annotatedDimensions);
TypeTree actualType;
if (type.isPresent()) {
actualType = applyDim(type.get(), nestedDimensions);
} else {
actualType = null;
}
BlockTreeImpl block = null;
InternalSyntaxToken semicolonToken = null;
if (blockOrSemicolon.is(Tree.Kind.BLOCK)) {
block = (BlockTreeImpl) blockOrSemicolon;
} else {
semicolonToken = (InternalSyntaxToken) blockOrSemicolon;
}
InternalSyntaxToken throwsToken = null;
ListTree<TypeTree> throwsClauses = QualifiedIdentifierListTreeImpl.emptyList();
if (throwsClause.isPresent()) {
throwsToken = throwsClause.get().first();
throwsClauses = throwsClause.get().second();
}
return new MethodTreeImpl(actualType, identifier, parameters, throwsToken, throwsClauses, block, semicolonToken);
}
use of org.sonar.java.model.JavaTree.ArrayTypeTreeImpl in project sonar-java by SonarSource.
the class TreeFactory method newArrayTypeTree.
@CheckForNull
private static ArrayTypeTreeImpl newArrayTypeTree(Optional<List<Tuple<InternalSyntaxToken, InternalSyntaxToken>>> dims) {
ArrayTypeTreeImpl result = null;
if (dims.isPresent()) {
for (Tuple<InternalSyntaxToken, InternalSyntaxToken> dim : dims.get()) {
InternalSyntaxToken openBracketToken = dim.first();
InternalSyntaxToken closeBracketToken = dim.second();
result = new ArrayTypeTreeImpl(result, ImmutableList.<AnnotationTreeImpl>of(), openBracketToken, closeBracketToken);
}
}
return result;
}
Aggregations