use of org.eclipse.jdt.core.dom.TagElement in project che by eclipse.
the class DelegateCreator method createJavadoc.
/**
* Creates the javadoc for the delegate.
*
* @throws JavaModelException
*/
private void createJavadoc() throws JavaModelException {
TagElement tag = getDelegateJavadocTag(fDeclaration);
Javadoc comment = fDeclaration.getJavadoc();
if (comment == null) {
comment = getAst().newJavadoc();
comment.tags().add(tag);
fDelegateRewrite.getASTRewrite().set(fDeclaration, getJavaDocProperty(), comment, null);
} else
fDelegateRewrite.getASTRewrite().getListRewrite(comment, Javadoc.TAGS_PROPERTY).insertLast(tag, null);
}
use of org.eclipse.jdt.core.dom.TagElement in project che by eclipse.
the class DelegateCreator method getDelegateJavadocTag.
// ******************* INTERNAL HELPERS ***************************
private TagElement getDelegateJavadocTag(BodyDeclaration declaration) throws JavaModelException {
Assert.isNotNull(declaration);
String msg = RefactoringCoreMessages.DelegateCreator_use_member_instead;
//$NON-NLS-1$
int firstParam = msg.indexOf("{0}");
Assert.isTrue(firstParam != -1);
List<ASTNode> fragments = new ArrayList<ASTNode>();
TextElement text = getAst().newTextElement();
text.setText(msg.substring(0, firstParam).trim());
fragments.add(text);
fragments.add(createJavadocMemberReferenceTag(declaration, getAst()));
text = getAst().newTextElement();
text.setText(msg.substring(firstParam + 3).trim());
fragments.add(text);
final TagElement tag = getAst().newTagElement();
tag.setTagName(TagElement.TAG_DEPRECATED);
tag.fragments().addAll(fragments);
return tag;
}
use of org.eclipse.jdt.core.dom.TagElement in project che by eclipse.
the class ModifierCorrectionSubProcessor method addOverridingDeprecatedMethodProposal.
public static void addOverridingDeprecatedMethodProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
ICompilationUnit cu = context.getCompilationUnit();
ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
if (!(selectedNode instanceof MethodDeclaration)) {
return;
}
boolean is50OrHigher = JavaModelUtil.is50OrHigher(cu.getJavaProject());
MethodDeclaration methodDecl = (MethodDeclaration) selectedNode;
AST ast = methodDecl.getAST();
ASTRewrite rewrite = ASTRewrite.create(ast);
if (is50OrHigher) {
Annotation annot = ast.newMarkerAnnotation();
//$NON-NLS-1$
annot.setTypeName(ast.newName("Deprecated"));
rewrite.getListRewrite(methodDecl, methodDecl.getModifiersProperty()).insertFirst(annot, null);
}
Javadoc javadoc = methodDecl.getJavadoc();
if (javadoc != null || !is50OrHigher) {
if (!is50OrHigher) {
javadoc = ast.newJavadoc();
rewrite.set(methodDecl, MethodDeclaration.JAVADOC_PROPERTY, javadoc, null);
}
TagElement newTag = ast.newTagElement();
newTag.setTagName(TagElement.TAG_DEPRECATED);
JavadocTagsSubProcessor.insertTag(rewrite.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY), newTag, null);
}
String label = CorrectionMessages.ModifierCorrectionSubProcessor_overrides_deprecated_description;
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal(label, cu, rewrite, IProposalRelevance.OVERRIDES_DEPRECATED, image);
proposals.add(proposal);
}
use of org.eclipse.jdt.core.dom.TagElement in project che 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 che by eclipse.
the class JavadocTagsSubProcessor method findThrowsTag.
public static TagElement findThrowsTag(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_THROWS.equals(currName) || TagElement.TAG_EXCEPTION.equals(currName)) {
String argument = getArgument(curr);
if (arg.equals(argument)) {
return curr;
}
}
}
return null;
}
Aggregations