use of org.sonar.plugins.java.api.tree.MethodInvocationTree in project sonar-java by SonarSource.
the class MethodInvocationTreeImplTest method first_token.
@Test
public void first_token() {
CompilationUnitTree cut = createTree("class A {\n" + " void bar(){\n" + " foo();\n" + " }" + "}");
ClassTree classTree = (ClassTree) cut.types().get(0);
MethodInvocationTree mit = (MethodInvocationTree) ((ExpressionStatementTree) ((MethodTree) (classTree.members().get(0))).block().body().get(0)).expression();
SyntaxToken firstToken = mit.firstToken();
assertThat(firstToken.text()).isEqualTo("foo");
}
use of org.sonar.plugins.java.api.tree.MethodInvocationTree in project sonar-java by SonarSource.
the class MethodInvocationTreeImplTest method first_token_with_type_arguments.
@Test
public void first_token_with_type_arguments() {
CompilationUnitTree cut = createTree("class A {\n" + " void bar(){\n" + " new A().<String>foo();\n" + " }" + " <T> void foo() {}" + "}");
ClassTree classTree = (ClassTree) cut.types().get(0);
MethodInvocationTree mit = (MethodInvocationTree) ((ExpressionStatementTree) ((MethodTree) (classTree.members().get(0))).block().body().get(0)).expression();
SyntaxToken firstToken = mit.firstToken();
assertThat(firstToken.text()).isEqualTo("new");
}
Aggregations