processClassPath(); Symbol.ClassSymbol classSymbol = methodSymbol.enclClass(); String className = classSymbol.getQualifiedName().toString(); if (methodSymbol.getModifiers().contains(Modifier.ABSTRACT)) {
ClassSymbol classSymbol = getSymbol(tree).enclClass(); Set<ComparisonSite> suspiciousComparisons = new HashSet<>();
private boolean isReturnAnnotatedNullable(Symbol.MethodSymbol methodSymbol) { if (config.isJarInferUseReturnAnnotations()) { Preconditions.checkNotNull(methodSymbol); Symbol.ClassSymbol classSymbol = methodSymbol.enclClass(); String className = classSymbol.getQualifiedName().toString(); if (lookupAndBuildCache(classSymbol)) { String methodSign = getMethodSignature(methodSymbol); Map<Integer, Set<String>> methodArgAnnotations = lookupMethodInCache(className, methodSign); if (methodArgAnnotations != null) { Set<String> methodAnnotations = methodArgAnnotations.get(RETURN); if (methodAnnotations != null) { if (methodAnnotations.contains("javax.annotation.Nullable")) { LOG(DEBUG, "DEBUG", "Nullable return for method: " + methodSign); return true; } } } } } return false; }
/** Definition for this$n field. * @param pos The source code position of the definition. * @param owner The method in which the definition goes. */ JCVariableDecl outerThisDef(int pos, MethodSymbol owner) { ClassSymbol c = owner.enclClass(); boolean isMandated = // Anonymous constructors (owner.isConstructor() && owner.isAnonymous()) || // Constructors of non-private inner member classes (owner.isConstructor() && c.isInner() && !c.isPrivate() && !c.isStatic()); long flags = FINAL | (isMandated ? MANDATED : SYNTHETIC) | PARAMETER; VarSymbol outerThis = makeOuterThisVarSymbol(owner, flags); owner.extraParams = owner.extraParams.prepend(outerThis); return makeOuterThisVarDecl(pos, outerThis); }
private static boolean isAnnotationTypeElement(MethodSymbol meth) { return ClassDocImpl.isAnnotationType(meth.enclClass()); }
/** * Get the name. * * @return the qualified name of the member. */ public String qualifiedName() { return sym.enclClass().getQualifiedName().toString(); }
/** * Returns a string representation of this method. Includes the * qualified signature, the qualified method name, and any type * parameters. Type parameters follow the class name, as they do * in the syntax for invoking methods with explicit type parameters. */ public String toString() { return sym.enclClass().getQualifiedName() + "." + typeParametersString() + name() + signature(); } }
/** * Identify the containing class */ protected ClassSymbol getContainingClass() { return sym.enclClass(); }
public String qualifiedName() { if (qualifiedName == null) { qualifiedName = sym.enclClass().getQualifiedName() + "." + sym.name; } return qualifiedName; }
/** * Get the name. * * @return the name of the member. */ public String name() { ClassSymbol c = sym.enclClass(); return c.name.toString(); }
/** * Processes all the overload of a given compilation unit list. */ public void process(List<JCCompilationUnit> cuList) { for (JCCompilationUnit cu : cuList) { scan(cu); } pass++; for (JCCompilationUnit cu : cuList) { scan(cu); } for (Overload overload : context.getAllOverloads()) { overload.calculate(types, context.symtab); if (overload.methods.size() > 1 && !overload.isValid) { if (overload.coreMethod.sym.isConstructor()) { context.classesWithWrongConstructorOverload.add(overload.coreMethod.sym.enclClass()); } } } // context.dumpOverloads(System.out); }
EnumSet.of(TypeKind.INT, TypeKind.LONG) .contains(state.getTypes().unboxedTypeOrType(x.asType()).getKind())) .noneMatch(arg -> arg.isMemberOf(enclosing.enclClass(), state.getTypes()))) { arg -> arg.getSimpleName().contentEquals("this") && arg.isMemberOf(enclosing.enclClass(), state.getTypes()))) { Symbol finalizeSym = getFinalizer(state, enclosing.enclClass()); if (finalizeSym == null || finalizeSym.equals(enclosing)) {
ClassSymbol methodClass = method.enclClass(); if (argumentClass.isSubClass(methodClass, types) && !methodClass.equals(state.getSymtab().objectType.tsym)
private Symbol.MethodSymbol getClosestOverriddenMethod(Symbol.MethodSymbol method, Types types) { Symbol.ClassSymbol owner = method.enclClass(); for (Type s : types.closure(owner.type)) { if (s.equals(owner.type)) {
return Description.NO_MATCH; ClassSymbol classSym = method.enclClass(); if (classSym == null) { return Description.NO_MATCH;
@Override public Description matchMethod(MethodTree methodTree, VisitorState state) { MethodSymbol methodSymbol = ASTHelpers.getSymbol(methodTree); if (isSynchronized(methodSymbol)) { return NO_MATCH; } for (MethodSymbol s : ASTHelpers.findSuperMethods(methodSymbol, state.getTypes())) { if (isSynchronized(s)) { // Input streams are typically not used across threads, so this case isn't // worth enforcing. if (isSameType(s.owner.type, state.getTypeFromString("java.io.InputStream"), state)) { continue; } if (ignore(methodTree, state)) { return NO_MATCH; } return buildDescription(methodTree) .addFix(SuggestedFixes.addModifiers(methodTree, state, Modifier.SYNCHRONIZED)) .setMessage( String.format( "Unsynchronized method %s overrides synchronized method in %s", methodSymbol.getSimpleName(), s.enclClass().getSimpleName())) .build(); } } return NO_MATCH; }
@Override public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) { if (!MATCHER.matches(tree, state)) { return NO_MATCH; } if (state.getTypes().closure(ASTHelpers.getSymbol(tree).enclClass().asType()).stream() .anyMatch( s -> s.asElement() .packge() .getQualifiedName() .toString() .startsWith("java.util.concurrent"))) { return NO_MATCH; } if (blockEndsInBreakOrReturn(state)) { return NO_MATCH; } ExpressionTree collection = getReceiver(tree); if (collection == null) { return NO_MATCH; } if (!enclosingLoop(state.getPath(), collection)) { return NO_MATCH; } return describeMatch(tree); }
private String getMethodSignature(Symbol.MethodSymbol method) { // Generate method signature String methodSign = method.enclClass().getQualifiedName().toString() + ":" + (method.isStaticOrInstanceInit() ? "" : getSimpleTypeName(method.getReturnType()) + " ") + method.getSimpleName() + "("; if (!method.getParameters().isEmpty()) { for (Symbol.VarSymbol var : method.getParameters()) { methodSign += getSimpleTypeName(var.type) + ", "; } methodSign = methodSign.substring(0, methodSign.lastIndexOf(',')); } methodSign += ")"; LOG(DEBUG, "DEBUG", "@ method sign: " + methodSign); return methodSign; }