Package com.sun.source.util

Examples of com.sun.source.util.TreePath


            this.trees = trees;
        }

        @Override
        public Void visitCatch(CatchTree node, Void p) {
            TreePath param = new TreePath(getCurrentPath(), node.getParameter());
            Element ex = trees.getElement(param);
            validateUnionTypeInfo(ex);
            if (ex.getSimpleName().contentEquals("ex")) {
                assertTrue(ex.getKind() == ElementKind.EXCEPTION_PARAMETER, "Expected EXCEPTION_PARAMETER - found " + ex.getKind());
                for (Element e : types.asElement(trees.getLub(node)).getEnclosedElements()) {
View Full Code Here


    }

    static class MyVisitor extends TreePathScanner<Void,Void> {
        @Override
        public Void visitAssignment(AssignmentTree node, Void ignored) {
            TreePath path = TreePath.getPath(getCurrentPath(), node.getExpression());
            if (trees.getTypeMirror(path).getKind() == TypeKind.ERROR)
                throw new AssertionError(path.getLeaf());
            return null;
        }
View Full Code Here

        JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, files);
        Iterable<? extends CompilationUnitTree> compUnits = ct.parse();
        CompilationUnitTree cu = compUnits.iterator().next();
        ClassTree cdef = (ClassTree)cu.getTypeDecls().get(0);
        JCVariableDecl vdef = (JCVariableDecl)cdef.getMembers().get(0);
        TreePath path = TreePath.getPath(cu, vdef.init);
        Trees.instance(ct).getScope(path);
    }
View Full Code Here

        public boolean foundError = false;
        CompilationUnitTree compilationUnit = null;
        int i = 0;
        @Override
        public Void visitMethodInvocation(MethodInvocationTree node, Void ignored) {
            TreePath path = TreePath.getPath(compilationUnit, node);
            TypeMirror typeMirror = trees.getTypeMirror(path);
            if (typeMirror.getKind() == TypeKind.ERROR) {
              if (i == 0) {
                String str1 = trees.getOriginalType((ErrorType)typeMirror).toString();
                if (!str1.equals("java.lang.Number")) {
View Full Code Here

        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
        assert tool != null;
        final JavacTask ct = (JavacTask)tool.getTask(null, null, null, Arrays.asList("-bootclasspath",  bootPath), null, Arrays.asList(new MyFileObject()));

        CompilationUnitTree cut = ct.parse().iterator().next();
        TreePath tp = new TreePath(new TreePath(cut), cut.getTypeDecls().get(0));
        Scope s = Trees.instance(ct).getScope(tp);
        TypeElement type = ct.getElements().getTypeElement("com.sun.java.util.jar.pack.Package.File");

        if (Trees.instance(ct).isAccessible(s, type)) {
            //com.sun.java.util.jar.pack.Package.File is a public innerclass inside a non-accessible class, so
View Full Code Here

        Env<AttrContext> env = null;
        JCMethodDecl method = null;
        JCVariableDecl field = null;

        List<Tree> l = List.nil();
        TreePath p = path;
        while (p != null) {
            l = l.prepend(p.getLeaf());
            p = p.getParentPath();
        }

        for ( ; l.nonEmpty(); l = l.tail) {
            Tree tree = l.head;
            switch (tree.getKind()) {
View Full Code Here

        Env<AttrContext> env = null;
        JCMethodDecl method = null;
        JCVariableDecl field = null;
       
        List<Tree> l = List.nil();
        TreePath p = path;
        while (p != null) {
            l = l.prepend(p.getLeaf());
            p = p.getParentPath();
        }
       
        for ( ; l.nonEmpty(); l = l.tail) {
            Tree tree = l.head;
            switch (tree.getKind()) {
View Full Code Here

    public Scope getScope(final CompilationUnitTree cut, JCTree tree) {
        if (tree == null) {
            throw new IllegalArgumentException("tree is " + tree);
        }
        final TreePath treePath = TreePath.getPath(cut, tree);

        try {
            com.sun.source.tree.Scope scope = trees.getScope(treePath);
            return scope;
        } catch (java.lang.Throwable ne) { //this occurs when the symbol is invalid (inaccessible)
View Full Code Here

        PackageElement packageOf = elementUtils.getPackageOf(e);
        List<? extends Element> pkgClasses = packageOf.getEnclosedElements();
        rs = new Resolver(elementUtils, trees, tm, encClass, typeUtils, symTable, pkgClasses);

        final JCMethodDecl tree = (JCMethodDecl) elementUtils.getTree(e);
        final TreePath treePath = trees.getPath(e);


        thisExp = tm.This((Type) encClass.asType());

        TypeElement superclass = getTypeElement(encClass.getSuperclass().toString());

        while (superclass != null) {
            TypeMirror superclass1 = superclass.getSuperclass();
            if (superclass1 == null) {
                break;
            }
            superclass = getTypeElement(superclass1.toString());
        }
        final CompilationUnitTree cut = treePath.getCompilationUnit();

        tree.body = processElement(tree.body, cut);
        if (reflectionInjected || methodInjected || constructorInjected) {
            tree.thrown = tree.thrown.append(getId("java.lang.ClassNotFoundException"));
            tree.thrown = tree.thrown.append(getId("java.lang.NoSuchFieldException"));
View Full Code Here

    }
    return tw;
  }

  private TreePath getTreePath(Element enclosingElement) {
    TreePath path = trees.getPath(enclosingElement);
    if (path == null) {
      Tree tree = trees.getTree(enclosingElement);
      if (tree == null) {
        tree = new DummyTree();
      }
      // XXX: this is ugly, null is better here?
      path = new TreePath(new TreePath(compilationUnit), tree);
    }
    return path;
  }
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.