@Override ASTNode clone0(AST target) { Javadoc result = new Javadoc(target); result.setSourceRange(getStartPosition(), getLength()); if (this.ast.apiLevel == AST.JLS2_INTERNAL) { result.setComment(getComment()); } result.tags().addAll(ASTNode.copySubtrees(target, tags())); return result; }
@Override public JavaDocSource<O> addTagValue(String tagName, String tagValue) { Assert.notNull(tagName, TAG_NAME_CANNOT_BE_NULL); TagElement tagElement = javadoc.getAST().newTagElement(); TextElement textElement = javadoc.getAST().newTextElement(); tagElement.setTagName(tagName); textElement.setText(tagValue); tagElement.fragments().add(textElement); javadoc.tags().add(tagElement); return this; }
/** * Return whether the deprecated comment strings of the given java doc are equals. * <p> * Note the only purpose of this method is to hide deprecated warnings. * @deprecated mark deprecated to hide deprecated usage */ private boolean compareDeprecatedComment(Javadoc first, Javadoc second) { if (first.getAST().apiLevel == AST.JLS2_INTERNAL) { return safeEquals(first.getComment(), second.getComment()); } else { return true; } }
final Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) { if (property == COMMENT_PROPERTY) { if (get) { return getComment(); } else { setComment((String) value); return null; } } // allow default implementation to flag the error return super.internalGetSetObjectProperty(property, get, value); }
LOGGER.error("Method " + currentMethod.getName().getIdentifier() + " not found in class"); } else { for (Object tag : javaDoc.tags()) { if (tag instanceof TagElement) { TagElement tagElement = (TagElement) tag;
public boolean visit(AnnotationTypeDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); } printModifiers(node.modifiers()); this.fBuffer.append("@interface ");//$NON-NLS-1$ node.getName().accept(this); this.fBuffer.append(" {");//$NON-NLS-1$ for (Iterator it= node.bodyDeclarations().iterator(); it.hasNext();) { BodyDeclaration d= (BodyDeclaration) it.next(); d.accept(this); } this.fBuffer.append("}");//$NON-NLS-1$ return false; }
@Override public boolean visit(Javadoc aNode) { new de.tudarmstadt.ukp.teaching.uima.lesson2.type.Javadoc(jcas, aNode .getStartPosition(), aNode.getStartPosition() + aNode.getLength()).addToIndexes(); return false; } }
private static ICompilationUnit createPreparedCU(ICompilationUnit cu, Javadoc comment, int wordStart) throws JavaModelException { int startpos= comment.getStartPosition(); boolean isTopLevel= comment.getParent().getParent() instanceof CompilationUnit; char[] content= (char[]) cu.getBuffer().getCharacters().clone(); if (isTopLevel && (wordStart + 6 < content.length)) { content[startpos++]= 'i'; content[startpos++]= 'm'; content[startpos++]= 'p'; content[startpos++]= 'o'; content[startpos++]= 'r'; content[startpos++]= 't'; } if (wordStart < content.length) { for (int i= startpos; i < wordStart; i++) { content[i]= ' '; } } /* * Explicitly create a new non-shared working copy. */ ICompilationUnit newCU= cu.getWorkingCopy(null); newCU.getBuffer().setContents(content); return newCU; }
private String addPeriodAtEndOfFirstLine(Javadoc node, String comment) { String beforeFirstTag = comment; String afterFirstTag = ""; final Matcher m = FIRST_JAVADOC_TAG.matcher(comment); if (m.find()) { if (m.start() == 0) { return null; } beforeFirstTag = comment.substring(0, m.start()); afterFirstTag = comment.substring(m.start()); } final Matcher matcher = JAVADOC_WITHOUT_PUNCTUATION.matcher(beforeFirstTag); if (matcher.matches()) { final List<TagElement> tagElements = tags(node); if (tagElements.size() >= 2) { final TagElement firstLine = tagElements.get(0); final int relativeStart = firstLine.getStartPosition() - node.getStartPosition(); final int endOfFirstLine = relativeStart + firstLine.getLength(); return comment.substring(0, endOfFirstLine) + "." + comment.substring(endOfFirstLine); // TODO JNR do the replace here, not outside this method } return matcher.group(1) + "." + matcher.group(2) + afterFirstTag; } return null; }
private MethodDeclaration resolveMethodDeclaration(ASTNode node) { if (node instanceof MethodDeclaration) return (MethodDeclaration)node; Javadoc doc= (Javadoc) ASTNodes.getParent(node, ASTNode.JAVADOC); if (doc == null) return null; if (doc.getParent() instanceof MethodDeclaration) return (MethodDeclaration) doc.getParent(); return null; }
private void handleExceptionTags(List<TagElement> tags, List<String> exceptionNames, CharSequence[] exceptionDescriptions) { if (tags.size() == 0 && containsOnlyNull(exceptionNames)) { return; } handleBlockTagTitle(JavaDoc2HTMLTextReader_throws_section); fBuf.append(BLOCK_TAG_START); for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext();) { TagElement tag = iter.next(); fBuf.append(BlOCK_TAG_ENTRY_START); handleThrowsTag(tag); fBuf.append(BlOCK_TAG_ENTRY_END); } for (int i = 0; i < exceptionDescriptions.length; i++) { CharSequence description = exceptionDescriptions[i]; String name = exceptionNames.get(i); if (name != null) { fBuf.append(BlOCK_TAG_ENTRY_START); handleLink(Collections.singletonList(fJavadoc.getAST().newSimpleName(name))); if (description != null) { fBuf.append(JavaElementLabels.CONCAT_STRING); fBuf.append(description); } fBuf.append(BlOCK_TAG_ENTRY_END); } } fBuf.append(BLOCK_TAG_END); }
public boolean visit(Javadoc node) { ASTNode parent = node.getParent(); if (parent == null) { parent = node.getAlternateRoot(); } insert(documentation, resolveBinding(parent), getSourceLocation(node)); return false; }
private List<ExtractedDocTest> extractExamples( Collection<String> imports, String pkg, String rootClass, String source, BodyDeclaration node ) { Javadoc javadoc = node.getJavadoc(); if(javadoc == null) { return Collections.emptyList(); } return extractCodeBlocks( source, imports, pkg, rootClass, extractJavadoc( javadoc.getComment() ) ); }
@Override protected void updateDocComment() { for (int idx = 0; idx <= this.astPtr; idx++) { this.docComment.tags().add(this.astStack[idx]); } } }
public boolean visit(PackageDeclaration node) { if (node.getAST().apiLevel() >= AST.JLS3) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); } for (Iterator it= node.annotations().iterator(); it.hasNext();) { Annotation p= (Annotation) it.next(); p.accept(this); this.fBuffer.append(" ");//$NON-NLS-1$ } } this.fBuffer.append("package ");//$NON-NLS-1$ node.getName().accept(this); this.fBuffer.append(";");//$NON-NLS-1$ return false; }
return DO_NOT_VISIT_SUBTREE; } else if (!acceptJavadoc(getNextNode(node)) && node.getStartPosition() != 0) { this.ctx.getRefactorings().replace(node, comment.replace("/**", "/*")); return DO_NOT_VISIT_SUBTREE; int startLine = this.astRoot.getLineNumber(node.getStartPosition()); int endLine = this.astRoot.getLineNumber(node.getStartPosition() + node.getLength()); if (startLine != endLine) { this.ctx.getRefactorings().replace(node, "/** {@inheritDoc} */");
private static ICompilationUnit createPreparedCU(ICompilationUnit cu, Javadoc comment, int wordStart) throws JavaModelException { int startpos= comment.getStartPosition(); boolean isTopLevel= comment.getParent().getParent() instanceof CompilationUnit; char[] content= cu.getBuffer().getCharacters().clone(); if (isTopLevel && (wordStart + 6 < content.length)) { content[startpos++]= 'i'; content[startpos++]= 'm'; content[startpos++]= 'p'; content[startpos++]= 'o'; content[startpos++]= 'r'; content[startpos++]= 't'; } if (wordStart < content.length) { for (int i= startpos; i < wordStart; i++) { content[i]= ' '; } } /* * Explicitly create a new non-shared working copy. */ ICompilationUnit newCU= cu.getWorkingCopy(null); newCU.getBuffer().setContents(content); return newCU; }
/** * Return whether the deprecated comment strings of the given java doc are equals. * <p> * Note the only purpose of this method is to hide deprecated warnings. * @deprecated mark deprecated to hide deprecated usage */ private boolean compareDeprecatedComment(Javadoc first, Javadoc second) { if (first.getAST().apiLevel == AST.JLS2_INTERNAL) { return safeEquals(first.getComment(), second.getComment()); } else { return true; } }
@Override public boolean visit(Javadoc node) { if (!hasChildrenChanges(node)) { return doVisitUnchangedChildren(node); } int startPos= node.getStartPosition() + 3; String separator= getLineDelimiter() + getIndentAtOffset(node.getStartPosition()) + " * "; //$NON-NLS-1$ rewriteNodeList(node, Javadoc.TAGS_PROPERTY, startPos, separator, separator); return false; }