Package com.sun.source.util

Examples of com.sun.source.util.TreePath


      }
    }

    private TreePath actualPathPlus(Tree actual) {
      checkNotNull(actual, "Tried to push null actual tree onto path.");
      return new TreePath(actualPath, actual);
    }
View Full Code Here


      return new TreePath(actualPath, actual);
    }

    private TreePath expectedPathPlus(Tree expected) {
      checkNotNull(expected, "Tried to push null expected tree onto path.");
      return new TreePath(expectedPath, expected);
    }
View Full Code Here

     * stack when the call completes.
     *
     * <p>This should be the ONLY place where either {@link TreePath} is mutated.
     */
    private Void pushPathAndAccept(Tree expected, Tree actual) {
      TreePath prevExpectedPath = expectedPath;
      TreePath prevActualPath = actualPath;
      expectedPath = expectedPathPlus(expected);
      actualPath = actualPathPlus(actual);
      try {
        return expected.accept(this, actual);
      } finally {
View Full Code Here

   *
   * @throws IllegalArgumentException if the node provided is not a sub-{@code Tree} of this
   *   object's {@code CompilationUnitTree}.
   */
  TreePath getNodePath(Tree node) {
    TreePath treePath = trees.getPath(compilationUnit, node);
    checkArgument(treePath != null, "The node provided was not a subtree of the "
        + "CompilationUnitTree in this TreeContext. CompilationUnit: %s; Node:",
        compilationUnit, node);
    return treePath;
  }
View Full Code Here

   *
   * @throws IllegalArgumentException if the node provided is not a sub-{@code Tree} of this
   *   object's {@code CompilationUnitTree}.
   */
  long getNodeStartPosition(Tree node) {
    TreePath currentNode = getNodePath(node);
    while (currentNode != null) {
      long startPosition = sourcePositions.getStartPosition(compilationUnit, currentNode.getLeaf());
      if (startPosition != NOPOS) {
        return startPosition;
      }
      currentNode = currentNode.getParentPath();
    }
    return NOPOS;
  }
View Full Code Here

   *
   * @throws IllegalArgumentException if the node provided is not a sub-{@code Tree} of this
   *   object's {@code CompilationUnitTree}.
   */
  long getNodeEndPosition(Tree node) {
    TreePath currentNode = getNodePath(node);
    while (node != null) {
      long endPosition = sourcePositions.getEndPosition(compilationUnit, currentNode.getLeaf());
      if (endPosition != NOPOS) {
        return endPosition;
      }
      currentNode = currentNode.getParentPath();
    }
    return NOPOS;
  }
View Full Code Here

      return isMatch(node, Optional.fromNullable(idValue));
    }

    /** Returns a TreePath that includes the current path plus the node provided */
    private Optional<TreePath> currentPathPlus(Tree node) {
      return Optional.of(new TreePath(getCurrentPath(), node));
    }
View Full Code Here

            break;
        }
    }

    private void add(Element e) {
        TreePath p = getCurrentPath();
        long pos = this.pos.getStartPosition(p.getCompilationUnit(), p.getLeaf());
        if(pos==-1)
            return;
       
        Set<TreePath> trees = result.get(e);
        if(trees==null)
View Full Code Here

        javac.analyze();

        // used to list up all analyzed classes
        TreePathScanner<?,?> classScanner = new TreePathScanner<Void,Void>() {
            public Void visitClass(ClassTree ct, Void _) {
                TreePath path = getCurrentPath();
                treePathByClass.put(ct,path);
                TypeElement e = (TypeElement) trees.getElement(path);
                if(e!=null) {
                    classes.put(e.getQualifiedName().toString(), path);
View Full Code Here

        }
    };

    private void writeLocation(TypeElement e) {
        String className = e.getQualifiedName().toString();
        TreePath treePath = pss.getClassTreePath(className);
        found: {
            if (treePath != null) {
                CompilationUnitTree cu = treePath.getCompilationUnit();
                if (cu != null && cu.getSourceFile().getKind() == JavaFileObject.Kind.SOURCE) {
                    String projectPath = pss.getProjectDir().getAbsolutePath();
                    String cuPath = cu.getSourceFile().toUri().getPath();
                    if (cuPath.contains(projectPath)) {
                        string("in:" + cuPath.substring(projectPath.length() + 1));
View Full Code Here

TOP

Related Classes of com.sun.source.util.TreePath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.