use of org.sonar.java.model.expression.IdentifierTreeImpl 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.expression.IdentifierTreeImpl 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.expression.IdentifierTreeImpl 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);
}
use of org.sonar.java.model.expression.IdentifierTreeImpl 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;
}
use of org.sonar.java.model.expression.IdentifierTreeImpl 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