use of org.sonar.java.model.statement.BlockTreeImpl 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);
}
Aggregations