private static boolean isSynchronized(MethodSymbol sym) { return sym.getModifiers().contains(Modifier.SYNCHRONIZED); }
Sets.intersection(constructorSymbol.getModifiers(), VISIBILITY_MODIFIERS); Set<Modifier> replacementVisibility = Sets.intersection(proposedConstructor.getModifiers(), VISIBILITY_MODIFIERS); if (constructor.getClassBody() == null && !constructorVisibility.equals(replacementVisibility)) {
if (methodSymbol.getModifiers().contains(Modifier.ABSTRACT)) { LOG( VERBOSE,
private static boolean canBeUsedByGetChecked(MethodSymbol constructor, VisitorState state) { Type stringType = state.getSymtab().stringType; Type throwableType = state.getSymtab().throwableType; // TODO(cpovirk): Check visibility of enclosing types (assuming that it matters to getChecked). if (!constructor.getModifiers().contains(PUBLIC)) { return false; } for (VarSymbol param : constructor.getParameters()) { if (!isSameType(param.asType(), stringType, state) && !isSameType(param.asType(), throwableType, state)) { return false; } } return true; }
private static boolean isSynchronized(MethodSymbol sym) { return sym.getModifiers().contains(Modifier.SYNCHRONIZED); }
if (!s.getEnclosingElement().equals(classdecl.sym)) { if (!(s.isDefault() || (!context.isInterface((TypeSymbol) s.getEnclosingElement()) && !s.getModifiers().contains(Modifier.ABSTRACT)))) { printAbstractDeclaration = true;
addCoreMethod = !overload.printed && overload.coreMethod.sym.getEnclosingElement() != parent.sym && (!overload.coreMethod.sym.getModifiers().contains(Modifier.ABSTRACT) || isInterfaceMethod(parent, methodDecl) || !context.types.isSubtype(parent.sym.type,
/** * Returns true if the given class declares an abstract method. */ public static boolean hasAbstractMethod(ClassSymbol classSymbol) { for (Element member : classSymbol.getEnclosedElements()) { if (member instanceof MethodSymbol && ((MethodSymbol) member).getModifiers().contains(Modifier.ABSTRACT)) { return true; } } return false; }
if (!methodSymbol.getModifiers().equals(superMethod.getModifiers())) { return NO_MATCH; if (methodSymbol.getModifiers().contains(Modifier.PROTECTED) && !Objects.equals(superMethod.packge(), methodSymbol.packge())) { return NO_MATCH;
if (!methodSym.getModifiers().contains(Modifier.PRIVATE)) { return Description.NO_MATCH;
Set<Modifier> modifiers = symbol.getModifiers(); if ((symbol.isPrivate() || modifiers.contains(Modifier.FINAL)) && !symbol.isStatic()
if (symbol.getModifiers().contains(Modifier.PRIVATE)) { return buildDescription(tree) .setMessage("A private method that should not be called should simply be removed.") .build(); if (symbol.getModifiers().contains(Modifier.ABSTRACT)) { return NO_MATCH; if (symbol.getModifiers().contains(Modifier.FINAL)) { return NO_MATCH;
return true; if (sym.isConstructor() || sym.getModifiers().contains(Modifier.NATIVE)) { return true;
if (methodSym.getModifiers().contains(Modifier.ABSTRACT)) { return Description.NO_MATCH;
sym.getSimpleName(), override.enclClass().isInterface() || override.getModifiers().contains(Modifier.ABSTRACT) ? "implements" : "overrides",
if (!methodSym.getModifiers().contains(Modifier.ABSTRACT)) { return Description.NO_MATCH;
/** * Determines whether a method can be overridden. * * @return true if the method can be overridden. */ public static boolean methodCanBeOverridden(MethodSymbol methodSymbol) { if (methodSymbol.getModifiers().contains(Modifier.ABSTRACT)) { return true; } if (methodSymbol.isStatic() || methodSymbol.isPrivate() || isFinal(methodSymbol) || methodSymbol.isConstructor()) { return false; } ClassSymbol classSymbol = (ClassSymbol) methodSymbol.owner; return !isFinal(classSymbol) && !classSymbol.isAnonymous(); }
@Override public Description matchMethod(MethodTree tree, VisitorState state) { MethodSymbol method = ASTHelpers.getSymbol(tree); if (method.isStatic() || method.isConstructor()) { return Description.NO_MATCH; } if (method.getModifiers().contains(Modifier.PUBLIC) || method.getModifiers().contains(Modifier.PRIVATE)) { List<MethodSymbol> overriddenMethods = getOverriddenMethods(state, method); if (!overriddenMethods.isEmpty()) { String customMessage = MESSAGE_BASE + "must have protected or package-private visibility"; return buildDescription(tree).setMessage(customMessage).build(); } } return Description.NO_MATCH; }
private static boolean canBeUsedByGetChecked(MethodSymbol constructor, VisitorState state) { Type stringType = state.getSymtab().stringType; Type throwableType = state.getSymtab().throwableType; // TODO(cpovirk): Check visibility of enclosing types (assuming that it matters to getChecked). if (!constructor.getModifiers().contains(PUBLIC)) { return false; } for (VarSymbol param : constructor.getParameters()) { if (!isSameType(param.asType(), stringType, state) && !isSameType(param.asType(), throwableType, state)) { return false; } } return true; }
@Override public Void visitMethodInvocation(MethodInvocationTree node, Void data) { MethodSymbol method = ASTHelpers.getSymbol(node); if (method != null && !method.isConstructor() && !method.isStatic() && !method.isPrivate() && !method.getModifiers().contains(Modifier.FINAL) && isOnThis(node) && method.isMemberOf(classSym, state.getTypes())) { state.reportMatch(describeMatch(node)); } return super.visitMethodInvocation(node, data); } },