@Override public boolean visit(MethodDeclaration node) { if (node.getBody() == null) { return VISIT_SUBTREE; } List<Statement> bodyStmts = statements(node.getBody()); if (bodyStmts.size() == 1) { SuperMethodInvocation bodyMi = asExpression(bodyStmts.get(0), SuperMethodInvocation.class); if (bodyMi != null) { IMethodBinding bodyMethodBinding = bodyMi.resolveMethodBinding(); IMethodBinding declMethodBinding = node.resolveBinding(); if (declMethodBinding != null && bodyMethodBinding != null && declMethodBinding.overrides(bodyMethodBinding) && !hasSignificantAnnotations(declMethodBinding) && haveSameModifiers(bodyMethodBinding, declMethodBinding)) { if (Modifier.isProtected(declMethodBinding.getModifiers()) && !declaredInSamePackage(bodyMethodBinding, declMethodBinding)) { // protected also means package visibility, so check if it is required if (!isMethodUsedInItsPackage(declMethodBinding, node)) { this.ctx.getRefactorings().remove(node); return DO_NOT_VISIT_SUBTREE; } } else { this.ctx.getRefactorings().remove(node); return DO_NOT_VISIT_SUBTREE; } } } } return VISIT_SUBTREE; }
// Método para configurar os modificadores @SuppressWarnings("unchecked") private void setModifiers(ApiElement apiElement, BodyDeclaration node) { for (Object o : node.modifiers()) { if (o instanceof Modifier) { Modifier modifier = (Modifier) o; if (modifier.isAbstract()) { apiElement.setAbstract(true); } else if (modifier.isFinal()) { apiElement.setFinal(true); } else if (modifier.isPrivate()) { apiElement.setPrivate(true); } else if (modifier.isProtected()) { apiElement.setProtected(true); } else if (modifier.isPublic()) { apiElement.setPublic(true); } else if (modifier.isStatic()) { apiElement.setFinal(true); } } } apiElement.setDefault( !(apiElement.isPrivate() || apiElement.isPublic() || apiElement.isProtected())); Javadoc javadoc = node.getJavadoc(); if (javadoc != null) { apiElement.setHasJavadoc(true); apiElement.setHidden(false); Stack<Object> tags = new Stack<Object>(); tags.addAll(javadoc.tags()); while (!tags.isEmpty()) { Object tag = tags.pop(); if (tag instanceof TagElement) { String tagName = ((TagElement) tag).getTagName(); if (tagName != null && tagName.equalsIgnoreCase("@hide")) { apiElement.setHidden(true); break; } tags.addAll(((TagElement) tag).fragments()); } } } else { apiElement.setHasJavadoc(false); apiElement.setHidden(true); } }