use of org.sonar.java.model.declaration.ModifiersTreeImpl in project sonar-java by SonarSource.
the class TreeFactory method newAnnotationType.
public ClassTreeImpl newAnnotationType(InternalSyntaxToken openBraceToken, Optional<List<JavaTree>> annotationTypeElementDeclarations, InternalSyntaxToken closeBraceToken) {
// TODO
ModifiersTreeImpl emptyModifiers = ModifiersTreeImpl.emptyModifiers();
ImmutableList.Builder<Tree> members = ImmutableList.builder();
if (annotationTypeElementDeclarations.isPresent()) {
for (JavaTree annotationTypeElementDeclaration : annotationTypeElementDeclarations.get()) {
if (annotationTypeElementDeclaration.getGrammarRuleKey().equals(JavaLexer.VARIABLE_DECLARATORS)) {
for (VariableTreeImpl variable : (VariableDeclaratorListTreeImpl) annotationTypeElementDeclaration) {
members.add(variable);
}
} else if (!annotationTypeElementDeclaration.is(Kind.TOKEN)) {
members.add(annotationTypeElementDeclaration);
}
}
}
return new ClassTreeImpl(emptyModifiers, openBraceToken, members.build(), closeBraceToken);
}
use of org.sonar.java.model.declaration.ModifiersTreeImpl in project sonar-java by SonarSource.
the class TreeFactory method newRequiresModuleDirective.
public ModuleDirectiveTree newRequiresModuleDirective(InternalSyntaxToken requiresToken, Optional<List<InternalSyntaxToken>> modifiers, ModuleNameTree moduleName, InternalSyntaxToken semicolonToken) {
ModifiersTreeImpl newModifiers = ModifiersTreeImpl.emptyModifiers();
if (modifiers.isPresent()) {
List<ModifierTree> modifierKeywords = new ArrayList<>();
// JLS9 - ยง7.7.1 'requires' only 'static' and 'transitive' modifiers are allowed
for (InternalSyntaxToken modifierAsSyntaxToken : modifiers.get()) {
if (JavaRestrictedKeyword.TRANSITIVE.getValue().equals(modifierAsSyntaxToken.text())) {
modifierKeywords.add(new ModifierKeywordTreeImpl(Modifier.TRANSITIVE, modifierAsSyntaxToken));
} else {
modifierKeywords.add(new ModifierKeywordTreeImpl(Modifier.STATIC, modifierAsSyntaxToken));
}
}
newModifiers = new ModifiersTreeImpl(modifierKeywords);
}
return new RequiresDirectiveTreeImpl(requiresToken, newModifiers, moduleName, semicolonToken);
}
use of org.sonar.java.model.declaration.ModifiersTreeImpl in project sonar-java by SonarSource.
the class TreeFactory method newRequiresModuleDirective.
public ModuleDirectiveTree newRequiresModuleDirective(InternalSyntaxToken requiresToken, InternalSyntaxToken staticModifier, InternalSyntaxToken transitiveTokenAsModuleName, InternalSyntaxToken semicolonToken) {
ModifierKeywordTreeImpl staticModifierTree = new ModifierKeywordTreeImpl(Modifier.STATIC, staticModifier);
ModifiersTreeImpl modifiers = new ModifiersTreeImpl(Collections.singletonList(staticModifierTree));
return new RequiresDirectiveTreeImpl(requiresToken, modifiers, transitiveModuleName(transitiveTokenAsModuleName), semicolonToken);
}
Aggregations