use of org.eclipse.jdt.core.dom.TagElement in project eclipse-cs by checkstyle.
the class MethodLimitQuickfix method handleGetCorrectingASTVisitor.
/**
* {@inheritDoc}
*/
protected ASTVisitor handleGetCorrectingASTVisitor(final IRegion lineInfo, final int markerStartOffset) {
return new ASTVisitor() {
@SuppressWarnings("unchecked")
public boolean visit(MethodDeclaration node) {
Javadoc doc = node.getJavadoc();
if (doc == null) {
doc = node.getAST().newJavadoc();
node.setJavadoc(doc);
}
TagElement newTag = node.getAST().newTagElement();
newTag.setTagName("TODO Added by MethodLimit Sample quickfix");
doc.tags().add(0, newTag);
return true;
}
};
}
use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocTagsSubProcessor method findTag.
public static TagElement findTag(Javadoc javadoc, String name, String arg) {
List<TagElement> tags = javadoc.tags();
int nTags = tags.size();
for (int i = 0; i < nTags; i++) {
TagElement curr = tags.get(i);
if (name.equals(curr.getTagName())) {
if (arg != null) {
String argument = getArgument(curr);
if (arg.equals(argument)) {
return curr;
}
} else {
return curr;
}
}
}
return null;
}
use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocTagsSubProcessor method insertTag.
public static void insertTag(ListRewrite rewriter, TagElement newElement, Set<String> sameKindLeadingNames, TextEditGroup groupDescription) {
List<? extends ASTNode> tags = rewriter.getRewrittenList();
String insertedTagName = newElement.getTagName();
ASTNode after = null;
int tagRanking = getTagRanking(insertedTagName);
for (int i = tags.size() - 1; i >= 0; i--) {
TagElement curr = (TagElement) tags.get(i);
String tagName = curr.getTagName();
if (tagName == null || tagRanking > getTagRanking(tagName)) {
after = curr;
break;
}
if (sameKindLeadingNames != null && isSameTag(insertedTagName, tagName)) {
String arg = getArgument(curr);
if (arg != null && sameKindLeadingNames.contains(arg)) {
after = curr;
break;
}
}
}
if (after != null) {
rewriter.insertAfter(newElement, after, groupDescription);
} else {
rewriter.insertFirst(newElement, groupDescription);
}
}
use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocTagsSubProcessor method findParamTag.
public static TagElement findParamTag(Javadoc javadoc, String arg) {
List<TagElement> tags = javadoc.tags();
int nTags = tags.size();
for (int i = 0; i < nTags; i++) {
TagElement curr = tags.get(i);
String currName = curr.getTagName();
if (TagElement.TAG_PARAM.equals(currName)) {
String argument = getArgument(curr);
if (arg.equals(argument)) {
return curr;
}
}
}
return null;
}
use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocTagsSubProcessor method getRemoveJavadocTagProposals.
public static void getRemoveJavadocTagProposals(IInvocationContext context, IProblemLocationCore problem, Collection<ChangeCorrectionProposal> proposals) {
ASTNode node = problem.getCoveringNode(context.getASTRoot());
while (node != null && !(node instanceof TagElement)) {
node = node.getParent();
}
if (node == null) {
return;
}
ASTRewrite rewrite = ASTRewrite.create(node.getAST());
rewrite.remove(node, null);
String label = CorrectionMessages.JavadocTagsSubProcessor_removetag_description;
proposals.add(new ASTRewriteCorrectionProposal(label, CodeActionKind.QuickFix, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_TAG));
}
Aggregations