static int getEndPosition(DocTree docTree, VisitorState state) { DocSourcePositions positions = JavacTrees.instance(state.context).getSourcePositions(); CompilationUnitTree compilationUnitTree = state.getPath().getCompilationUnit(); return (int) positions.getEndPosition(compilationUnitTree, getDocCommentTree(state), docTree); }
static SuggestedFix replace(DocTree docTree, String replacement, VisitorState state) { DocSourcePositions positions = JavacTrees.instance(state.context).getSourcePositions(); CompilationUnitTree compilationUnitTree = state.getPath().getCompilationUnit(); int startPos = getStartPosition(docTree, state); int endPos = (int) positions.getEndPosition(compilationUnitTree, getDocCommentTree(state), docTree); return SuggestedFix.replace(startPos, endPos, replacement); }
@Override public Void visitParam(ParamTree paramTree, Void unused) { if (paramTree.isTypeParameter() && paramTree.getName().getName().contentEquals(name)) { DocSourcePositions positions = JavacTrees.instance(state.context).getSourcePositions(); CompilationUnitTree compilationUnitTree = state.getPath().getCompilationUnit(); int startPos = (int) positions.getStartPosition( compilationUnitTree, docCommentTree, paramTree.getName()); int endPos = (int) positions.getEndPosition( compilationUnitTree, docCommentTree, paramTree.getName()); fixBuilder.replace(startPos, endPos, typeVarReplacement); } return super.visitParam(paramTree, null); } },
public int endPos(DCTree oldT, DCDocComment doc) { DocSourcePositions sp = JavacTrees.instance(context).getSourcePositions(); return (int) sp.getEndPosition(null, doc, oldT); }
public String renderSource(TreePath path, List<? extends Tree> trees, String source) { CompilationUnitTree unit = path.getCompilationUnit(); int from = (int) docTrees.getSourcePositions().getStartPosition(unit, trees.get(0)); int to = (int) docTrees.getSourcePositions().getEndPosition(unit, trees.get(trees.size() - 1));
@Override public Void scan(DocTree node, Void p) { if ( node != null && positions.getStartPosition(javac.getCompilationUnit(), docComment, node) <= offset && positions.getEndPosition(javac.getCompilationUnit(), docComment, node) >= offset) { return super.scan(node, p); } return null; } @Override public Void visitReference(ReferenceTree node, Void p) {
@Override public Void scan(DocTree node, Void p) { if ( node != null && positions.getStartPosition(javac.getCompilationUnit(), docComment, node) <= offset && positions.getEndPosition(javac.getCompilationUnit(), docComment, node) >= offset) { return super.scan(node, p); } return null; } @Override public Void visitReference(ReferenceTree node, Void p) {
private void copyContent(DocTree node) { int from = (int) docTrees.getSourcePositions().getStartPosition(pkgPath.getCompilationUnit(), docTree, node); int to = (int) docTrees.getSourcePositions().getEndPosition(pkgPath.getCompilationUnit(), docTree, node); writer.append(pkgSource, from, to); }
@Override public Void visitParam(ParamTree node, Void p) { //XXX: getElement for the param's identifier??? if ( node.getName() != null && positions.getStartPosition(javac.getCompilationUnit(), docComment, node.getName()) <= offset && positions.getEndPosition(javac.getCompilationUnit(), docComment, node.getName()) >= offset) { result[0] = findNameTokenOfParamTag(offset, getJavadocTS(javac, offset)); return null; } return super.visitParam(node, p); } @Override public Void visitSee(SeeTree node, Void p) {
static SuggestedFix replace(DocTree docTree, String replacement, VisitorState state) { DocSourcePositions positions = JavacTrees.instance(state.context).getSourcePositions(); CompilationUnitTree compilationUnitTree = state.getPath().getCompilationUnit(); int startPos = getStartPosition(docTree, state); int endPos = (int) positions.getEndPosition(compilationUnitTree, getDocCommentTree(state), docTree); return SuggestedFix.replace(startPos, endPos, replacement); }
@Override public Void visitParam(ParamTree node, Void p) { //XXX: getElement for the param's identifier??? if ( node.getName() != null && positions.getStartPosition(javac.getCompilationUnit(), docComment, node.getName()) <= offset && positions.getEndPosition(javac.getCompilationUnit(), docComment, node.getName()) >= offset) { result[0] = paramElementFor(trees.getElement(tp), node); return null; } return super.visitParam(node, p); } @Override public Void visitSee(SeeTree node, Void p) {
final JavacTrees jt = JavacTrees.instance(task); final int origStartPos = (int) jt.getSourcePositions().getStartPosition(cu, orig.getBody()); final int origEndPos = (int) jt.getSourcePositions().getEndPosition(cu, orig.getBody()); if (origStartPos < 0) { LOGGER.log(Level.WARNING, "Javac returned startpos: {0} < 0", new Object[]{origStartPos}); //NOI18N return false; final int newEndPos = (int) jt.getSourcePositions().getEndPosition(cu, block); if (newEndPos != origStartPos + newBody.length()) { return false;
@Override public Void visitParam(ParamTree paramTree, Void unused) { if (paramTree.isTypeParameter() && paramTree.getName().getName().contentEquals(name)) { DocSourcePositions positions = JavacTrees.instance(state.context).getSourcePositions(); CompilationUnitTree compilationUnitTree = state.getPath().getCompilationUnit(); int startPos = (int) positions.getStartPosition( compilationUnitTree, docCommentTree, paramTree.getName()); int endPos = (int) positions.getEndPosition( compilationUnitTree, docCommentTree, paramTree.getName()); fixBuilder.replace(startPos, endPos, typeVarReplacement); } return super.visitParam(paramTree, null); } },