use of org.sonar.plugins.java.api.tree.UsesDirectiveTree in project sonar-java by SonarSource.
the class UsesDirectiveTreeImplTest method moduleDirective.
private UsesDirectiveTree moduleDirective(String exportsDirective) {
CompilationUnitTree compilationUnitTree = createTree("module org.foo {\n " + exportsDirective + "\n}");
SemanticModel.createFor(compilationUnitTree, new SquidClassLoader(Collections.emptyList()));
return (UsesDirectiveTree) compilationUnitTree.moduleDeclaration().moduleDirectives().get(0);
}
use of org.sonar.plugins.java.api.tree.UsesDirectiveTree in project sonar-java by SonarSource.
the class UsesDirectiveTreeImplTest method simple_uses.
@Test
public void simple_uses() {
UsesDirectiveTree exports = moduleDirective("uses foo.MyInterface;");
assertThat(exports.kind()).isEqualTo(Tree.Kind.USES_DIRECTIVE);
assertThat(exports.directiveKeyword().text()).isEqualTo("uses");
TypeTree typeName = exports.typeName();
assertThat(typeName.is(Tree.Kind.MEMBER_SELECT)).isTrue();
assertThat(((MemberSelectExpressionTree) typeName).identifier().name()).isEqualTo("MyInterface");
assertThat(exports.semicolonToken().text()).isEqualTo(";");
}
Aggregations