MethodInvocationTreeImpl extends AssessableExpressionTree implements MethodInvocationTree { @Override public SyntaxToken firstToken() { if (typeArguments() != null && methodSelect.is(Tree.Kind.MEMBER_SELECT)) { ExpressionTree expression = ((MemberSelectExpressionTree) methodSelect).expression(); SyntaxToken firstToken = expression.firstToken(); if (firstToken != null) { return firstToken; } } return super.firstToken(); } MethodInvocationTreeImpl(ExpressionTree methodSelect, @Nullable TypeArguments typeArguments, ArgumentListTreeImpl arguments); @Override Kind kind(); @Nullable @Override TypeArguments typeArguments(); @Override SyntaxToken firstToken(); @Override ExpressionTree methodSelect(); @Override Arguments arguments(); @Override Symbol symbol(); @Override void accept(TreeVisitor visitor); @Override Iterable<Tree> children(); @Nullable
  public IMethodBinding methodBinding; }
@Test 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"); }
@Test 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"); }