use of org.sonar.java.model.InternalSyntaxToken in project sonar-java by SonarSource.
the class TreeFactory method newArrayCreatorWithDimension.
public NewArrayTreeImpl newArrayCreatorWithDimension(InternalSyntaxToken openBracketToken, ExpressionTree expression, InternalSyntaxToken closeBracketToken, Optional<List<ArrayAccessExpressionTreeImpl>> arrayAccesses, Optional<List<Tuple<Optional<List<AnnotationTreeImpl>>, Tuple<InternalSyntaxToken, InternalSyntaxToken>>>> dims) {
ImmutableList.Builder<ArrayDimensionTree> dimensions = ImmutableList.builder();
dimensions.add(new ArrayDimensionTreeImpl(openBracketToken, expression, closeBracketToken));
if (arrayAccesses.isPresent()) {
for (ArrayAccessExpressionTreeImpl arrayAccess : arrayAccesses.get()) {
dimensions.add(arrayAccess.dimension());
}
}
if (dims.isPresent()) {
for (Tuple<Optional<List<AnnotationTreeImpl>>, Tuple<InternalSyntaxToken, InternalSyntaxToken>> dim : dims.get()) {
Tuple<InternalSyntaxToken, InternalSyntaxToken> brackets = dim.second();
List<AnnotationTreeImpl> annotations = dim.first().or(ImmutableList.<AnnotationTreeImpl>of());
dimensions.add(new ArrayDimensionTreeImpl(annotations, brackets.first(), null, brackets.second()));
}
}
return new NewArrayTreeImpl(dimensions.build(), InitializerListTreeImpl.emptyList());
}
use of org.sonar.java.model.InternalSyntaxToken in project sonar-java by SonarSource.
the class TreeFactory method newModuleName.
public ModuleNameTree newModuleName(InternalSyntaxToken firstIdentifier, Optional<List<Tuple<InternalSyntaxToken, InternalSyntaxToken>>> rest) {
List<IdentifierTree> identifiers = new ArrayList<>();
List<SyntaxToken> separators = new ArrayList<>();
identifiers.add(new IdentifierTreeImpl(firstIdentifier));
if (rest.isPresent()) {
for (Tuple<InternalSyntaxToken, InternalSyntaxToken> modulePart : rest.get()) {
separators.add(modulePart.first());
identifiers.add(new IdentifierTreeImpl(modulePart.second()));
}
}
return new ModuleNameTreeImpl(Collections.unmodifiableList(identifiers), Collections.unmodifiableList(separators));
}
use of org.sonar.java.model.InternalSyntaxToken in project sonar-java by SonarSource.
the class TreeFactory method completeInterfaceDeclaration.
public ClassTreeImpl completeInterfaceDeclaration(InternalSyntaxToken interfaceToken, InternalSyntaxToken identifierToken, Optional<TypeParameterListTreeImpl> typeParameters, Optional<Tuple<InternalSyntaxToken, QualifiedIdentifierListTreeImpl>> extendsClause, ClassTreeImpl partial) {
IdentifierTreeImpl identifier = new IdentifierTreeImpl(identifierToken);
partial.completeDeclarationKeyword(interfaceToken);
partial.completeIdentifier(identifier);
if (typeParameters.isPresent()) {
partial.completeTypeParameters(typeParameters.get());
}
if (extendsClause.isPresent()) {
InternalSyntaxToken extendsKeyword = extendsClause.get().first();
QualifiedIdentifierListTreeImpl interfaces = extendsClause.get().second();
partial.completeInterfaces(extendsKeyword, interfaces);
}
return partial;
}
use of org.sonar.java.model.InternalSyntaxToken in project sonar-java by SonarSource.
the class TreeFactory method newImportDeclaration.
public ImportTreeImpl newImportDeclaration(InternalSyntaxToken importToken, Optional<InternalSyntaxToken> staticToken, ExpressionTree qualifiedIdentifier, Optional<Tuple<InternalSyntaxToken, InternalSyntaxToken>> dotStar, InternalSyntaxToken semicolonToken) {
ExpressionTree target = qualifiedIdentifier;
if (dotStar.isPresent()) {
IdentifierTreeImpl identifier = new IdentifierTreeImpl(dotStar.get().second());
InternalSyntaxToken dotToken = dotStar.get().first();
target = new MemberSelectExpressionTreeImpl(qualifiedIdentifier, dotToken, identifier);
}
InternalSyntaxToken staticKeyword = staticToken.orNull();
return new ImportTreeImpl(importToken, staticKeyword, target, semicolonToken);
}
use of org.sonar.java.model.InternalSyntaxToken in project sonar-java by SonarSource.
the class TreeFactory method completeClassDeclaration.
// End of types
// Classes, enums and interfaces
public ClassTreeImpl completeClassDeclaration(InternalSyntaxToken classSyntaxToken, InternalSyntaxToken identifierToken, Optional<TypeParameterListTreeImpl> typeParameters, Optional<Tuple<InternalSyntaxToken, TypeTree>> extendsClause, Optional<Tuple<InternalSyntaxToken, QualifiedIdentifierListTreeImpl>> implementsClause, ClassTreeImpl partial) {
IdentifierTreeImpl identifier = new IdentifierTreeImpl(identifierToken);
partial.completeDeclarationKeyword(classSyntaxToken);
partial.completeIdentifier(identifier);
if (typeParameters.isPresent()) {
partial.completeTypeParameters(typeParameters.get());
}
if (extendsClause.isPresent()) {
partial.completeSuperclass(extendsClause.get().first(), extendsClause.get().second());
}
if (implementsClause.isPresent()) {
InternalSyntaxToken implementsKeyword = implementsClause.get().first();
QualifiedIdentifierListTreeImpl interfaces = implementsClause.get().second();
partial.completeInterfaces(implementsKeyword, interfaces);
}
return partial;
}
Aggregations