Package com.sun.tools.javac.tree.JCTree

Examples of com.sun.tools.javac.tree.JCTree.JCCompilationUnit


   * invoked with the -Xjcov option.
   *
   * @return the end position of the node, or -1 if it is not available
   */
  public int getEndPosition(JCTree node) {
    JCCompilationUnit compilationUnit = (JCCompilationUnit) getPath().getCompilationUnit();
    if (compilationUnit.endPositions == null) {
      return -1;
    }
    return node.getEndPosition(compilationUnit.endPositions);
  }
View Full Code Here


            c.put(JavaFileManager.class, fm);
            m = TreeMaker.instance(c);
        }

        CompilationUnitTree removeRedundantImports(CompilationUnitTree t) {
            JCCompilationUnit tree = (JCCompilationUnit) t;
            tree.accept(this);
            ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
            for (JCTree def: tree.defs) {
                if (def.getTag() == JCTree.Tag.IMPORT) {
                    JCImport imp = (JCImport) def;
                    if (imp.qualid.getTag() == JCTree.Tag.SELECT) {
View Full Code Here

            for (List<String> it = javaNames; it.nonEmpty(); it = it.tail) {
                String name = it.head;
                if (!docClasses && fm != null && name.endsWith(".java") && new File(name).exists()) {
                    JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next();
                    docenv.notice("main.Loading_source_file", name);
                    JCCompilationUnit tree = parse(fo);
                    classTrees.append(tree);
                } else if (isValidPackageName(name)) {
                    names = names.append(name);
                } else if (name.endsWith(".java")) {
                    if (fm == null)
                        throw new IllegalArgumentException();
                    else
                        docenv.error(null, "main.file_not_found", name);
                } else {
                    docenv.error(null, "main.illegal_package_name", name);
                }
            }
            for (JavaFileObject fo: fileObjects) {
                docenv.notice("main.Loading_source_file", fo.getName());
                JCCompilationUnit tree = parse(fo);
                classTrees.append(tree);
            }

            if (!docClasses) {
                // Recursively search given subpackages.  If any packages
View Full Code Here

    private static String getCommentText(TreePath p) {
        if (p == null)
            return null;

        JCCompilationUnit topLevel = (JCCompilationUnit) p.getCompilationUnit();
        JCTree tree = (JCTree) p.getLeaf();
        return topLevel.docComments.getCommentText(tree);
    }
View Full Code Here

            for (List<String> it = javaNames; it.nonEmpty(); it = it.tail) {
                String name = it.head;
                if (!docClasses && name.endsWith(".java") && new File(name).exists()) {
                    JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next();
                    docenv.notice("main.Loading_source_file", name);
                    JCCompilationUnit tree = parse(fo);
                    classTrees.append(tree);
                } else if (isValidPackageName(name)) {
                    names = names.append(name);
                } else if (name.endsWith(".java")) {
                    docenv.error(null, "main.file_not_found", name);
View Full Code Here

            c.put(JavaFileManager.class, fm);
            m = TreeMaker.instance(c);
        }

        CompilationUnitTree removeRedundantImports(CompilationUnitTree t) {
            JCCompilationUnit tree = (JCCompilationUnit) t;
            tree.accept(this);
            ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
            for (JCTree def: tree.defs) {
                if (def.getTag() == JCTree.IMPORT) {
                    JCImport imp = (JCImport) def;
                    if (imp.qualid.getTag() == JCTree.SELECT) {
View Full Code Here

            for (List<String> it = javaNames; it.nonEmpty(); it = it.tail) {
                String name = it.head;
                if (!docClasses && name.endsWith(".java") && new File(name).exists()) {
                    JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next();
                    docenv.notice("main.Loading_source_file", name);
                    JCCompilationUnit tree = parse(fo);
                    classTrees.append(tree);
                } else if (isValidPackageName(name)) {
                    names = names.append(name);
                } else if (name.endsWith(".java")) {
                    docenv.error(null, "main.file_not_found", name);
View Full Code Here

    /**
     * Attribute a top level tree. These trees are encountered when the
     * package declaration has annotations.
     */
    public void attribTopLevel(Env<AttrContext> env) {
        JCCompilationUnit toplevel = env.toplevel;
        try {
            annotate.flush();
            chk.validateAnnotations(toplevel.packageAnnotations, toplevel.packge);
        } catch (CompletionFailure ex) {
            chk.completionError(toplevel.pos(), ex);
        }
    }
View Full Code Here

        JCExpression pkg = pkgName != null ? getPackage(pkgName) : null;
        at(t);
       
        List<JCTree> defs = makeDefs(t);
       
        JCCompilationUnit topLev = new CeylonCompilationUnit(List.<JCTree.JCAnnotation> nil(), pkg, defs, null, null, null, null, t, phasedUnit);

        topLev.lineMap = getMap();
        topLev.sourcefile = file;
        topLev.isCeylonProgram = true;
View Full Code Here

        if (r.errors > 0)
            throw new ParseException(sw.toString());
        Iterator<? extends CompilationUnitTree> iter = trees.iterator();
        if (!iter.hasNext())
            throw new Error("no trees found");
        JCCompilationUnit t = (JCCompilationUnit) iter.next();
        if (iter.hasNext())
            throw new Error("too many trees found");
        return t;
    }
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.tree.JCTree.JCCompilationUnit

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.