Examples of JavacFileManager


Examples of com.sun.tools.javac.file.JavacFileManager

            context.put(DiagnosticListener.class, diagnosticListener);
        PrintWriter pw = (charset == null)
                ? new PrintWriter(System.err, true)
                : new PrintWriter(new OutputStreamWriter(System.err, charset), true);
        context.put(Log.outKey, pw);
        return new JavacFileManager(context, true, charset);
    }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

    public JavaFileManager getFileManager() {
        if (fileManager == null) {
            if (root instanceof RootDocImpl)
                fileManager = ((RootDocImpl) root).getFileManager();
            else
                fileManager = new JavacFileManager(new Context(), false, null);
        }
        return fileManager;
    }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

            if (!useSymbolFile) {
                Options options = Options.instance(c);
                options.put("ignore.symbol.file", "true");
            }

            return new JavacFileManager(c, false, null);
        } finally {
            if (resetProperties) {
                if (prev == null) {
                    System.getProperties().remove("useJavaUtilZip");
                } else {
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

    /** Parse contents of file.
     *  @param filename     The name of the file to be parsed.
     */
    @Deprecated
    public JCTree.JCCompilationUnit parse(String filename) throws IOException {
        JavacFileManager fm = (JavacFileManager)fileManager;
        return parse(fm.getJavaFileObjectsFromStrings(List.of(filename)).iterator().next());
    }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

        long msec = System.currentTimeMillis();

        ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
        try {
            JavacFileManager fm = (JavacFileManager)fileManager;
            //parse all files
            ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
            for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
                if (classesAsDecls) {
                    if (! l.head.endsWith(".java") ) { // process as class file
                        ClassSymbol cs = reader.enterClass(names.fromString(l.head));
                        try {
                            cs.complete();
                        } catch(Symbol.CompletionFailure cf) {
                            bark.aptError("CantFindClass", l);
                            continue;
                        }

                        classes.append(cs); // add to list of classes
                        continue;
                    }
                }
                JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
                trees.append(parse(fo));
            }

            //enter symbols for all files
            List<JCCompilationUnit> roots = trees.toList();
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

                else
                    origOptions.put(s, value);
            }
            origOptions = Collections.unmodifiableMap(origOptions);

            JavacFileManager fm = (JavacFileManager) context.get(JavaFileManager.class);
            {
                // Note: it might be necessary to check for an empty
                // component ("") of the source path or class path

                String sourceDest = options.get("-s");
                if (fm.hasLocation(StandardLocation.SOURCE_PATH)) {
                    for(File f: fm.getLocation(StandardLocation.SOURCE_PATH))
                        augmentedSourcePath += (f + File.pathSeparator);
                    augmentedSourcePath += (sourceDest == null)?".":sourceDest;
                } else {
                    augmentedSourcePath = ".";

                    if (sourceDest != null)
                        augmentedSourcePath += (File.pathSeparator + sourceDest);
                }

                String classDest = options.get("-d");
                if (fm.hasLocation(StandardLocation.CLASS_PATH)) {
                    for(File f: fm.getLocation(StandardLocation.CLASS_PATH))
                        baseClassPath += (f + File.pathSeparator);
                    // put baseClassPath into map to handle any
                    // value needed for the classloader
                    options.put("-classpath", baseClassPath);

                    augmentedClassPath = baseClassPath + ((classDest == null)?".":classDest);
                } else {
                    baseClassPath = ".";
                    if (classDest != null)
                        augmentedClassPath = baseClassPath + (File.pathSeparator + classDest);
                }
                assert options.get("-classpath") != null;
            }

            /*
             * Create base and augmented class loaders
             */
            ClassLoader augmentedAptCL = null;
            {
            /*
             * Use a url class loader to look for classes on the
             * user-specified class path. Prepend computed bootclass
             * path, which includes extdirs, to the URLClassLoader apt
             * uses.
             */
                String aptclasspath = "";
                String bcp = "";
                Iterable<? extends File> bootclasspath = fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH);

                if (bootclasspath != null) {
                    for(File f: bootclasspath)
                        bcp += (f + File.pathSeparator);
                }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

     *
     * @param file a file
     * @return a JavaFileObject from the standard file manager.
     */
    public JavaFileObject asJavaFileObject(File file) {
        JavacFileManager fm = (JavacFileManager)context.get(JavaFileManager.class);
        return fm.getRegularFile(file);
    }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

    private static String testSrc = System.getProperty("test.src");
    private static String self = T6358168.class.getName();

    public static void main(String... args) throws Throwable {

        JavacFileManager fm = new JavacFileManager(new Context(), false, null);
        JavaFileObject f = fm.getFileForInput(testSrc + File.separatorChar + T6358168.class.getName() + ".java");

        try {
            // first, test case with no annotation processing
            testNoAnnotationProcessing(fm, f);
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

        File outDir = new File(testName);
        outDir.mkdirs();
        compile(outDir, opts);

        Context ctx = new Context();
        JavacFileManager fm = new JavacFileManager(ctx, true, null);
        fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(outDir));
        ClassReader cr = ClassReader.instance(ctx);
        cr.saveParameterNames = true;
        Name.Table names = Name.Table.instance(ctx);

        Set<String> classes = getTopLevelClasses(outDir);
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

                System.getProperties().remove("useJavaUtilZip");
                resetProperties = true;
            }

            Context c = new Context();
            return new JavacFileManager(c, false, null);
        } finally {
            if (resetProperties) {
                if (prev == null) {
                    System.getProperties().remove("useJavaUtilZip");
                } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.