use of org.eclipse.jdt.core.dom.Javadoc in project xtext-xtend by eclipse.
the class JavaASTFlattener method visit.
@Override
public boolean visit(final EnumConstantDeclaration node) {
Javadoc _javadoc = node.getJavadoc();
boolean _tripleNotEquals = (_javadoc != null);
if (_tripleNotEquals) {
node.getJavadoc().accept(this);
}
this.appendModifiers(node, node.modifiers());
node.getName().accept(this);
boolean _isEmpty = node.arguments().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
this.addProblem(node, "Enum constant cannot have any arguments");
this.appendToBuffer("(");
this.visitAllSeparatedByComma(node.arguments());
this.appendToBuffer(")");
}
AnonymousClassDeclaration _anonymousClassDeclaration = node.getAnonymousClassDeclaration();
boolean _tripleNotEquals_1 = (_anonymousClassDeclaration != null);
if (_tripleNotEquals_1) {
this.addProblem(node, "Enum constant cannot have any anonymous class declarations");
node.getAnonymousClassDeclaration().accept(this);
}
return false;
}
use of org.eclipse.jdt.core.dom.Javadoc in project xtext-eclipse by eclipse.
the class XbaseHoverDocumentationProvider method computeDocumentation.
public String computeDocumentation(EObject object) {
buffer = new StringBuffer();
context = object;
fLiteralContent = 0;
List<String> parameterNames = initParameterNames();
Map<String, URI> exceptionNamesToURI = initExceptionNamesToURI();
addAnnotations(object);
getDocumentationWithPrefix(object);
Javadoc javadoc = getJavaDoc();
if (javadoc == null)
return buffer.toString();
TagElement deprecatedTag = null;
TagElement start = null;
List<TagElement> parameters = new ArrayList<TagElement>();
TagElement returnTag = null;
List<TagElement> exceptions = new ArrayList<TagElement>();
List<TagElement> versions = new ArrayList<TagElement>();
List<TagElement> authors = new ArrayList<TagElement>();
List<TagElement> sees = new ArrayList<TagElement>();
List<TagElement> since = new ArrayList<TagElement>();
List<TagElement> rest = new ArrayList<TagElement>();
@SuppressWarnings("unchecked") List<TagElement> tags = javadoc.tags();
for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
TagElement tag = iter.next();
String tagName = tag.getTagName();
if (tagName == null) {
start = tag;
} else if (TagElement.TAG_PARAM.equals(tagName)) {
parameters.add(tag);
@SuppressWarnings("unchecked") List<? extends ASTNode> fragments = tag.fragments();
if (fragments.size() > 0) {
Object first = fragments.get(0);
if (first instanceof SimpleName) {
String name = ((SimpleName) first).getIdentifier();
int paramIndex = parameterNames.indexOf(name);
if (paramIndex != -1) {
parameterNames.set(paramIndex, null);
}
}
}
} else if (TagElement.TAG_RETURN.equals(tagName)) {
if (returnTag == null)
// the Javadoc tool only shows the first return tag
returnTag = tag;
} else if (TagElement.TAG_EXCEPTION.equals(tagName) || TagElement.TAG_THROWS.equals(tagName)) {
exceptions.add(tag);
@SuppressWarnings("unchecked") List<? extends ASTNode> fragments = tag.fragments();
if (fragments.size() > 0) {
Object first = fragments.get(0);
if (first instanceof Name) {
@SuppressWarnings("restriction") String name = org.eclipse.jdt.internal.corext.dom.ASTNodes.getSimpleNameIdentifier((Name) first);
if (exceptionNamesToURI.containsKey(name)) {
exceptionNamesToURI.put(name, null);
}
}
}
} else if (TagElement.TAG_SINCE.equals(tagName)) {
since.add(tag);
} else if (TagElement.TAG_VERSION.equals(tagName)) {
versions.add(tag);
} else if (TagElement.TAG_AUTHOR.equals(tagName)) {
authors.add(tag);
} else if (TagElement.TAG_SEE.equals(tagName)) {
sees.add(tag);
} else if (TagElement.TAG_DEPRECATED.equals(tagName)) {
if (deprecatedTag == null)
// the Javadoc tool only shows the first deprecated tag
deprecatedTag = tag;
} else {
rest.add(tag);
}
}
boolean hasParameters = parameters.size() > 0;
boolean hasReturnTag = returnTag != null;
boolean hasExceptions = exceptions.size() > 0;
if (deprecatedTag != null)
handleDeprecatedTag(deprecatedTag);
if (start != null) {
@SuppressWarnings("unchecked") List<ASTNode> fragments = start.fragments();
handleContentElements(fragments);
}
if (hasParameters || hasReturnTag || hasExceptions || versions.size() > 0 || authors.size() > 0 || since.size() > 0 || sees.size() > 0 || rest.size() > 0 || (buffer.length() > 0) && (parameterNames.size() > 0 || exceptionNamesToURI.size() > 0)) {
handleSuperMethodReferences(object);
buffer.append(BLOCK_TAG_START);
handleParameters(object, parameters, parameterNames);
handleReturnTag(returnTag);
handleExceptionTags(exceptions, exceptionNamesToURI);
handleBlockTags("Since:", since);
handleBlockTags("Version:", versions);
handleBlockTags("Author:", authors);
handleBlockTags("See Also:", sees);
handleBlockTags(rest);
buffer.append(BLOCK_TAG_END);
} else if (buffer.length() > 0) {
handleSuperMethodReferences(object);
}
String result = buffer.toString();
buffer = null;
rawJavaDoc = null;
context = null;
return result;
}
use of org.eclipse.jdt.core.dom.Javadoc 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;
}
};
}
Aggregations