use of org.sonar.java.model.declaration.RequiresDirectiveTreeImpl 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.RequiresDirectiveTreeImpl 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