private void reportIssueOnMethod(@Nullable MethodTree declaration, Symbol.TypeSymbol classSymbol) { if (declaration != null) { String message = "Move this method into "; if (classSymbol.name().isEmpty()) { message += "the anonymous class declared at line " + ((JavaTree) classSymbol.declaration()).getLine()+"."; } else { message += "\"" + classSymbol.name() + "\"."; } reportIssue(declaration.simpleName(), message); } }
private void reportIssueOnMethod(@Nullable MethodTree declaration, Symbol.TypeSymbol classSymbol) { if (declaration != null) { String message = "Move this method into "; if (classSymbol.name().isEmpty()) { message += "the anonymous class declared at line " + ((JavaTree) classSymbol.declaration()).getLine()+"."; } else { message += "\"" + classSymbol.name() + "\"."; } reportIssue(declaration.simpleName(), message); } }
@Override public void visitNode(Tree tree) { if (!hasSemantic()) { return; } MethodTree methodTree = (MethodTree) tree; Symbol.TypeSymbol enclosingClass = methodTree.symbol().enclosingClass(); String className = enclosingClass.type().fullyQualifiedName(); MethodMatcher writeObjectMatcher = SerializableContract.writeObjectMatcher(className); if (writeObjectMatcher.matches(methodTree) && hasModifier(methodTree.modifiers(), SYNCHRONIZED)) { SynchronizationVisitor visitor = new SynchronizationVisitor(methodTree); enclosingClass.declaration().accept(visitor); if (!visitor.moreThanSingleLock) { reportIssue(ModifiersUtils.getModifier(methodTree.modifiers(), SYNCHRONIZED), "Remove this \"synchronized\" keyword."); } } }
@Override public void visitNode(Tree tree) { if (!hasSemantic()) { return; } MethodTree methodTree = (MethodTree) tree; Symbol.TypeSymbol enclosingClass = methodTree.symbol().enclosingClass(); String className = enclosingClass.type().fullyQualifiedName(); MethodMatcher writeObjectMatcher = SerializableContract.writeObjectMatcher(className); if (writeObjectMatcher.matches(methodTree) && hasModifier(methodTree.modifiers(), SYNCHRONIZED)) { SynchronizationVisitor visitor = new SynchronizationVisitor(methodTree); enclosingClass.declaration().accept(visitor); if (!visitor.moreThanSingleLock) { reportIssue(ModifiersUtils.getModifier(methodTree.modifiers(), SYNCHRONIZED), "Remove this \"synchronized\" keyword."); } } }