private int fromInstance(Symbol symbol, Symbol owner) { int i = -1; Type ownerType = owner.type(); for (Symbol outerClass : outerClasses) { i++; if (symbol.equals(outerClass) || (ownerType != null && owner.isTypeSymbol() && outerClass.type().isSubtypeOf(ownerType))) { return i; } } return -1; }
private static boolean isField(Symbol symbol) { return symbol.owner().isTypeSymbol() && !"this".equals(symbol.name()) && symbol.isVariableSymbol(); }
private static boolean isMethodRefOnType(Tree expression) { if (expression.is(Tree.Kind.MEMBER_SELECT)) { return ((MemberSelectExpressionTree) expression).identifier().symbol().isTypeSymbol(); } else if (expression.is(Tree.Kind.IDENTIFIER)) { return ((IdentifierTree) expression).symbol().isTypeSymbol(); } return false; }
@CheckForNull private static String nonNullFieldAnnotation(Symbol symbol) { if (symbol.isVariableSymbol() && symbol.owner().isTypeSymbol() && !isUsingNullable(symbol) && valuesForGlobalAnnotation((JavaSymbol) symbol, ORG_SPRINGFRAMEWORK_LANG_NON_NULL_FIELDS) != null) { return ORG_SPRINGFRAMEWORK_LANG_NON_NULL_FIELDS; } return null; }
private static boolean isFinalField(Symbol symbol) { return symbol.isVariableSymbol() && symbol.isFinal() && symbol.owner().isTypeSymbol(); }
private static boolean isAnnotationMethod(MethodInvocationTree tree) { Symbol owner = tree.symbol().owner(); return owner.isTypeSymbol() && ((JavaSymbol.TypeJavaSymbol) owner).isAnnotation(); }
private static boolean isStaticField(Symbol symbol) { return symbol.isVariableSymbol() && symbol.owner().isTypeSymbol() && symbol.isStatic(); }
@CheckForNull private static String nonNullFieldAnnotation(Symbol symbol) { if (symbol.isVariableSymbol() && symbol.owner().isTypeSymbol() && !isUsingNullable(symbol) && valuesForGlobalAnnotation((JavaSymbol) symbol, ORG_SPRINGFRAMEWORK_LANG_NON_NULL_FIELDS) != null) { return ORG_SPRINGFRAMEWORK_LANG_NON_NULL_FIELDS; } return null; }
private static boolean isStaticField(Symbol symbol) { return symbol.isVariableSymbol() && symbol.owner().isTypeSymbol() && symbol.isStatic(); }
private static boolean isTypeInDefaultPackage(Symbol symbol) { if (!symbol.isTypeSymbol()) { return false; } Symbol parent = symbol.owner(); while (!parent.isPackageSymbol()) { parent = parent.owner(); } return parent.name().isEmpty(); }
private static boolean isAnnotationMethod(MethodInvocationTree tree) { Symbol owner = tree.symbol().owner(); return owner.isTypeSymbol() && ((JavaSymbol.TypeJavaSymbol) owner).isAnnotation(); }
private static boolean doesOverrideFinalize(Symbol classSymbol) { if (classSymbol.isTypeSymbol()) { Type superClassType = ((Symbol.TypeSymbol) classSymbol).superClass(); while (superClassType != null && !superClassType.is("java.lang.Object")) { Symbol.TypeSymbol currentClass = superClassType.symbol(); if (currentClass.lookupSymbols(FINALIZE).stream().anyMatch(FINALIZE_MATCHER::matches)) { return true; } superClassType = currentClass.superClass(); } } return false; }
private boolean isStaticField(Symbol symbol) { return symbol.isVariableSymbol() && symbol.owner().isTypeSymbol() && symbol.isStatic(); }
private boolean isFinalFieldWithInitializer(@Nullable Symbol symbol) { if (symbol != null && symbol.isVariableSymbol() && symbol.owner().isTypeSymbol() && symbol.isFinal()) { VariableTree declaration = ((Symbol.VariableSymbol) symbol).declaration(); return declaration != null && declaration.initializer() != null; } return false; }
private boolean isFinalFieldWithInitializer(@Nullable Symbol symbol) { if (symbol != null && symbol.isVariableSymbol() && symbol.owner().isTypeSymbol() && symbol.isFinal()) { VariableTree declaration = ((Symbol.VariableSymbol) symbol).declaration(); return declaration != null && declaration.initializer() != null; } return false; }
MethodReference(Symbol.MethodSymbol symbol) { methodSymbol = symbol; methodScopeOwner = methodSymbol.owner(); if (methodScopeOwner != null && methodScopeOwner.isTypeSymbol()) { nonStaticReference = !methodScopeOwner.isStatic() && !methodScopeOwner.owner().isPackageSymbol(); } }
private static boolean isInStaticInnerClass(VariableTree hiddenVariable, VariableTree variableTree) { Symbol hiddenVariableOwner = hiddenVariable.symbol().owner(); Symbol owner = variableTree.symbol().owner(); while (!owner.equals(hiddenVariableOwner)) { if (owner.isTypeSymbol() && owner.isStatic()) { return true; } owner = owner.owner(); } return false; }
private static boolean isInStaticInnerClass(VariableTree hiddenVariable, VariableTree variableTree) { Symbol hiddenVariableOwner = hiddenVariable.symbol().owner(); Symbol owner = variableTree.symbol().owner(); while (!owner.equals(hiddenVariableOwner)) { if (owner.isTypeSymbol() && owner.isStatic()) { return true; } owner = owner.owner(); } return false; }
private static boolean nonLocalAssignment(Tree syntaxNode) { if (syntaxNode.is(Tree.Kind.ASSIGNMENT)) { ExpressionTree variable = ((AssignmentExpressionTree) syntaxNode).variable(); return !variable.is(Tree.Kind.IDENTIFIER) || ((IdentifierTree) variable).symbol().owner().isTypeSymbol(); } return false; }
private boolean isOwnedByAServlet(VariableTree variable) { Symbol owner = variable.symbol().owner(); if (owner.isTypeSymbol()) { return owner.type().isSubtypeOf("javax.servlet.http.HttpServlet") || owner.type().isSubtypeOf("org.apache.struts.action.Action"); } return false; }