Package com.sun.source.tree

Examples of com.sun.source.tree.CompilationUnitTree


    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));
                        break found;
                    }
                }
View Full Code Here


                if (treePath == null)
                    return name + " (Unknown Source)";
                // just like stack trace, we just print the file name and
                // not the whole path. The idea is that the package name should
                // provide enough clue on which directory it lives.
                CompilationUnitTree compilationUnit = treePath.getCompilationUnit();
                Trees trees = Trees.instance(env);
                long startPosition = trees.getSourcePositions().getStartPosition(compilationUnit, treePath.getLeaf());
                return name + "(" +
                        compilationUnit.getSourceFile().getName() + ":" + compilationUnit.getLineMap().getLineNumber(startPosition) +
                        ")";
            }
        };
    }
View Full Code Here

TOP

Related Classes of com.sun.source.tree.CompilationUnitTree

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.