@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 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; }
@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; }
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; }
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; }
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; }
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; }
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; }
@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; }
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; }
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; }
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; }
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; }
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; }
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 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; }
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; }
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; }
Javadoc javadocNode = getPackageJavadocNode(fragment, source); if (javadocNode != null) { int start = javadocNode.getStartPosition(); int length = javadocNode.getLength(); return new JavaDocCommentReader(source, start, start + length - 1);
protected static void copyJavadocNode(final ASTRewrite rewrite, final IMember member, final BodyDeclaration oldDeclaration, final BodyDeclaration newDeclaration) throws JavaModelException { final Javadoc predecessor= oldDeclaration.getJavadoc(); if (predecessor != null) { final IDocument buffer= new Document(member.getCompilationUnit().getBuffer().getContents()); try { final String[] lines= Strings.convertIntoLines(buffer.get(predecessor.getStartPosition(), predecessor.getLength())); Strings.trimIndentation(lines, member.getJavaProject(), false); final Javadoc successor= (Javadoc) rewrite.createStringPlaceholder(Strings.concatenate(lines, TextUtilities.getDefaultLineDelimiter(buffer)), ASTNode.JAVADOC); newDeclaration.setJavadoc(successor); } catch (BadLocationException exception) { JavaPlugin.log(exception); } } }