ExpressionUtils { public static IdentifierTree methodName(MethodInvocationTree mit) { ExpressionTree methodSelect = mit.methodSelect(); IdentifierTree id; if (methodSelect.is(Tree.Kind.IDENTIFIER)) { id = (IdentifierTree) methodSelect; } else { id = ((MemberSelectExpressionTree) methodSelect).identifier(); } return id; } private  ExpressionUtils(); static boolean isSimpleAssignment(AssignmentExpressionTree tree); static boolean isSelectOnThisOrSuper(AssignmentExpressionTree tree); static boolean isSelectOnThisOrSuper(MemberSelectExpressionTree tree); static IdentifierTree extractIdentifier(AssignmentExpressionTree tree); static Optional<Symbol> extractIdentifierSymbol(ExpressionTree tree); static boolean isInvocationOnVariable(MethodInvocationTree mit, @Nullable Symbol variable, boolean defaultReturn); static ExpressionTree skipParentheses(ExpressionTree tree); static boolean isNullLiteral(ExpressionTree tree); static boolean isSecuringByte(ExpressionTree expression); static IdentifierTree methodName(MethodInvocationTree mit); @CheckForNull static MethodTree getEnclosingMethod(ExpressionTree expr); static Optional<Symbol> getAssignedSymbol(ExpressionTree exp); static boolean isThis(ExpressionTree expression); @CheckForNull static Object resolveAsConstant(ExpressionTree tree);  }
@Test void method_name() throws Exception { File file = new File("src/test/files/model/ExpressionUtilsMethodNameTest.java"); CompilationUnitTree tree = JParserTestUtils.parse(file); MethodTree methodTree = (MethodTree) ((ClassTree) tree.types().get(0)).members().get(0); MethodInvocationTree firstMIT = (MethodInvocationTree) ((ExpressionStatementTree) methodTree.block().body().get(0)).expression(); MethodInvocationTree secondMIT = (MethodInvocationTree) ((ExpressionStatementTree) methodTree.block().body().get(1)).expression(); assertThat(ExpressionUtils.methodName(firstMIT).name()).isEqualTo("foo"); assertThat(ExpressionUtils.methodName(secondMIT).name()).isEqualTo("foo"); }