private static Collection<MethodSymbol> filterMethods(Collection<Symbol> symbols) {
   List<MethodSymbol> methods = Lists.newArrayList();
   for (Symbol symbol : symbols) {
     if (symbol.isMethodSymbol() && !isConstructor(symbol)) {
       methods.add((MethodSymbol) symbol);
     }
   }
   return methods;
 }
Exemplo n.º 2
0
 private int referenceInstance(Symbol symbol) {
   Symbol owner = symbol.owner();
   if (owner != null && owner.isMethodSymbol()) {
     // local variable, use owner of the method
     owner = owner.owner();
   }
   int result = -1;
   if (owner != null && !outerClasses.peek().equals(owner)) {
     if (symbol.isUnknown()) {
       result = atLeastOneReference.size() - 1;
     } else if (!symbol.isStatic()) {
       result = fromInstance(symbol, owner);
     }
   }
   return result;
 }
 private void visitMethodInvocationTree(MethodInvocationTree methodInvocationTree) {
   if (isValueOfInvocation(methodInvocationTree)) {
     checkForUnboxing(methodInvocationTree.arguments().get(0));
   } else if (isUnboxingMethodInvocation(methodInvocationTree)) {
     ExpressionTree methodSelect = methodInvocationTree.methodSelect();
     if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) {
       MemberSelectExpressionTree memberSelectExpressionTree =
           (MemberSelectExpressionTree) methodSelect;
       checkForBoxing(memberSelectExpressionTree.expression());
     }
   } else {
     Symbol symbol = methodInvocationTree.symbol();
     if (symbol.isMethodSymbol()) {
       List<Type> parametersTypes = ((Symbol.MethodSymbol) symbol).parameterTypes();
       checkMethodInvocationArguments(methodInvocationTree, parametersTypes);
     }
   }
 }
 private static boolean isMethodToExtract(Symbol symbol) {
   return symbol.isMethodSymbol() && !"<init>".equals(symbol.name());
 }
 private static String getSymbolTypeName(Symbol symbol) {
   return symbol.isMethodSymbol() ? "method" : "field";
 }
 private static boolean variableAndMethod(Symbol s1, Symbol s2) {
   return s1.isVariableSymbol() && s2.isMethodSymbol();
 }
 private static boolean isOverriding(Symbol symbol) {
   return symbol.isMethodSymbol()
       && BooleanUtils.isTrue(((MethodTreeImpl) symbol.declaration()).isOverriding());
 }
 private static boolean isMethodMatchingName(Symbol symbol, String matchName) {
   return symbol.isMethodSymbol() && matchName.equals(symbol.name());
 }
Exemplo n.º 9
0
 private static boolean isObjectsMethod(Symbol symbol, String methodName) {
   return symbol.isMethodSymbol()
       && symbol.owner().type().is("java.util.Objects")
       && methodName.equals(symbol.name());
 }