private static boolean isEqualsMethod(MethodInvocationTree syntaxNode) { if (syntaxNode.arguments().size() == 1) { ExpressionTree methodSelect = syntaxNode.methodSelect(); if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) { MemberSelectExpressionTree expression = (MemberSelectExpressionTree) methodSelect; if ("equals".equals(expression.identifier().name()) && syntaxNode.symbol().isMethodSymbol()) { Symbol.MethodSymbol symbol = (Symbol.MethodSymbol) syntaxNode.symbol(); return symbol.parameterTypes().get(0).is("java.lang.Object"); } } } return false; }
@Override public void visitIdentifier(IdentifierTree tree) { if (methodSymbol.equals(tree.symbol().owner())) { used.add(tree.symbol()); } super.visitIdentifier(tree); }