/**Return the deepest DocTreePath at the given position. * * @param treepath for which the {@code doc} comment was determined * @param doc the documentation comment inside which the search should be performed * @param pos the position to search for * @return the deepest DocTreePath at the given position * @since 0.124 */ public DocTreePath pathFor(TreePath treepath, DocCommentTree doc, int pos) { return pathFor(new DocTreePath(treepath, doc), pos); }
/**Return the deepest DocTreePath at the given position. * * @param path where the search should start * @param pos the position to search for * @return the deepest DocTreePath at the given position * @since 0.124 */ public DocTreePath pathFor(DocTreePath path, int pos) { return pathFor(path, pos, info.getDocTrees().getSourcePositions()); }
private TreePath findUnresolvedElement(CompilationInfo info, int offset) throws IOException { int[] span = findUnresolvedElementSpan(info, offset); if (span != null) { return info.getTreeUtilities().pathFor(span[0] + 1); } else { return null; } }
public TreePath pathFor(int pos) { return pathFor(new TreePath(info.getCompilationUnit()), pos); }
public TreePath pathFor(TreePath path, int pos) { return pathFor(path, pos, info.getTrees().getSourcePositions()); }
packageName = elements.getPackageOf(typeElement).getQualifiedName().toString(); TreePath tp = controller.getTreeUtilities().pathFor(caretPosition); while (tp != null && tp.getLeaf().getKind() != Kind.METHOD) { tp = tp.getParentPath();
TypeElement testcase = elements.getTypeElement(TESTCASE); boolean junit3 = (testcase != null && typeElement != null) ? controller.getTypes().isSubtype(typeElement.asType(), testcase.asType()) : false; TreePath tp = controller.getTreeUtilities().pathFor(caretPosition); while (tp != null && tp.getLeaf().getKind() != Kind.METHOD) { tp = tp.getParentPath();
private DocTreePath resolvePathForPos(CompilationInfo javac, TreePath treePath, DocCommentTree doc, int pos) { DocTreePath tp = javac.getTreeUtilities().pathFor(treePath, doc, pos); while (tp != null) { KindPath kindPath1 = new KindPath(tp); kindPath.getList().remove(Tree.Kind.ERRONEOUS); if (kindPath1.equals(kindPath)) { return tp; } tp = tp.getParentPath(); } return null; }
private TreePath resolvePathForPos(final CompilationInfo compilationInfo, int pos) { TreePath tp = compilationInfo.getTreeUtilities().pathFor(pos); while (tp != null) { KindPath kindPath1 = new KindPath(tp); kindPath.getList().remove(Tree.Kind.ERRONEOUS); if (kindPath1.equals(kindPath)) { return tp; } tp = tp.getParentPath(); } return null; }
@Override public void run(ResultIterator resultIterator) throws Exception { Result res = resultIterator.getParserResult(offset); if (res == null) { return; } CompilationController controller = CompilationController.get(res); if (controller == null || controller.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) { return; } TreePath path = controller.getTreeUtilities().pathFor(offset); javax.lang.model.element.Element elem = controller.getTrees().getElement(path); ElementKind kind = elem.getKind(); if (kind == ElementKind.CLASS || kind == ElementKind.ENUM || kind == ElementKind.ANNOTATION_TYPE) { result[0] = elem.asType().toString(); } } });
@Override public void run(ResultIterator resultIterator) throws Exception { Result res = resultIterator.getParserResult(offset); if (res == null) { return; } CompilationController controller = CompilationController.get(res); if (controller == null || controller.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) { return; } TreePath path = controller.getTreeUtilities().pathFor(offset); javax.lang.model.element.Element elem = controller.getTrees().getElement(path); ElementKind kind = elem.getKind(); if (kind == ElementKind.CLASS || kind == ElementKind.ENUM || kind == ElementKind.ANNOTATION_TYPE) { result[0] = elem.asType().toString(); } } });
TypeElement testcase = elements.getTypeElement(TESTCASE); boolean junit3 = (testcase != null && typeElement != null) ? controller.getTypes().isSubtype(typeElement.asType(), testcase.asType()) : false; TreePath tp = controller.getTreeUtilities().pathFor(caretPosition); while (tp != null && tp.getLeaf().getKind() != Kind.METHOD) { tp = tp.getParentPath();
private TreePath getCommonPath(int startOffset, int endOffset) { TreeUtilities tu = controller.getTreeUtilities(); TreePath startPath = tu.pathFor(startOffset); com.sun.tools.javac.util.List<Tree> reverseStartPath = com.sun.tools.javac.util.List.<Tree>nil(); for (Tree t : startPath) reverseStartPath = reverseStartPath.prepend(t); TreePath endPath = tu.pathFor(endOffset); com.sun.tools.javac.util.List<Tree> reverseEndPath = com.sun.tools.javac.util.List.<Tree>nil(); for (Tree t : endPath) reverseEndPath = reverseEndPath.prepend(t); TreePath path = null; TreePath statementPath = null; while(reverseStartPath.head != null && reverseStartPath.head == reverseEndPath.head) { path = reverseStartPath.head instanceof CompilationUnitTree ? new TreePath((CompilationUnitTree)reverseStartPath.head) : new TreePath(path, reverseStartPath.head); if (reverseStartPath.head instanceof StatementTree) statementPath = path; reverseStartPath = reverseStartPath.tail; reverseEndPath = reverseEndPath.tail; } return statementPath != null ? statementPath : path; }
@Override public void run(CompilationController controller) throws Exception { controller.toPhase( Phase.ELEMENTS_RESOLVED ); int dot = strategy.getOffset(component); TreePath tp = controller.getTreeUtilities() .pathFor(dot); Element element = controller.getTrees().getElement(tp ); if ( element == null ){ StatusDisplayer.getDefault().setStatusText( NbBundle.getMessage( WebBeansActionHelper.class, "LBL_ElementNotFound")); return; } if ( element instanceof TypeElement ){ subject[0] = ElementHandle.create(element); subject[1] = element.getSimpleName(); subject[2] = InspectActionId.CLASS_CONTEXT; } } }, true );
int dot = strategy.getOffset(component); TreePath tp = controller.getTreeUtilities() .pathFor(dot); Element element = controller.getTrees().getElement(tp ); if ( element == null ){
controller.toPhase( Phase.ELEMENTS_RESOLVED ); int dot = strategy.getOffset(component); TreePath tp = controller.getTreeUtilities().pathFor(dot); Element contextElement = controller.getTrees().getElement(tp ); if ( contextElement == null ){
@Override public void run(CompilationController controller) throws Exception { controller.toPhase( Phase.ELEMENTS_RESOLVED ); int dot = component.getCaret().getDot(); TreePath tp = controller.getTreeUtilities().pathFor(dot); Element contextElement = controller.getTrees().getElement(tp ); if ( contextElement == null ){ StatusDisplayer.getDefault().setStatusText( NbBundle.getMessage( WebBeansActionHelper.class, "LBL_ElementNotFound")); return; } context[0] = contextElement; } }, true );
context.getClass().getMethod("setTreePath", new Class[] { TreePath.class }); if (doc != null) { treePath = ci.getTreeUtilities().pathFor(offset); treePath = new TreePath(treePath, tree); setTreePathMethod.invoke(context, treePath);
return; TreePath p = ci.getTreeUtilities().pathFor(offset); while (p != null && !TreeUtilities.CLASS_TREE_KINDS.contains(p.getLeaf().getKind())) { p = p.getParentPath();
TreePath tp = javac.getTreeUtilities().pathFor(offsetBehindJavadoc);