Package com.sun.tools.javac.util

Examples of com.sun.tools.javac.util.Context$Factory


        if (StaticCompilerUtils.isInitialised()) {
            return;
        }

        log.debug("TreeFabricatingTest init.");
        Context context = new Context();
        StaticCompilerUtils.initWithContext(context);
        LogUtils.init(null);

        f = new UnitTestTreeFactory(StaticCompilerUtils.treeMaker);
        StaticCompilerUtils.treeMaker = f;
View Full Code Here


            JavaFileManager fileManager,
            DiagnosticListener<? super JavaFileObject> diagnosticListener,
            Class<?> docletClass,
            Iterable<String> options,
            Iterable<? extends JavaFileObject> compilationUnits) {
        Context context = new Context();
        return getTask(out, fileManager, diagnosticListener,
                docletClass, options, compilationUnits, context);
    }
View Full Code Here

    @Override
    public StandardJavaFileManager getStandardFileManager(
            DiagnosticListener<? super JavaFileObject> diagnosticListener,
            Locale locale,
            Charset charset) {
        Context context = new Context();
        context.put(Locale.class, locale);
        if (diagnosticListener != null)
            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

        }

        /** Create the compiler to be used for the final compilation. */
        JavaCompiler finalCompiler() {
            try {
                Context nextCtx = nextContext();
                JavacProcessingEnvironment.this.context = nextCtx;
                JavaCompiler c = JavaCompiler.instance(nextCtx);
                c.log.initRound(compiler.log);
                return c;
            } finally {
View Full Code Here

        /** Get the context for the next round of processing.
         * Important values are propagated from round to round;
         * other values are implicitly reset.
         */
        private Context nextContext() {
            Context next = new Context(context);

            Options options = Options.instance(context);
            Assert.checkNonNull(options);
            next.put(Options.optionsKey, options);

            Locale locale = context.get(Locale.class);
            if (locale != null)
                next.put(Locale.class, locale);

            Assert.checkNonNull(messages);
            next.put(JavacMessages.messagesKey, messages);

            final boolean shareNames = true;
            if (shareNames) {
                Names names = Names.instance(context);
                Assert.checkNonNull(names);
                next.put(Names.namesKey, names);
            }

            DiagnosticListener<?> dl = context.get(DiagnosticListener.class);
            if (dl != null)
                next.put(DiagnosticListener.class, dl);

            MultiTaskListener mtl = context.get(MultiTaskListener.taskListenerKey);
            if (mtl != null)
                next.put(MultiTaskListener.taskListenerKey, mtl);

            FSInfo fsInfo = context.get(FSInfo.class);
            if (fsInfo != null)
                next.put(FSInfo.class, fsInfo);

            JavaFileManager jfm = context.get(JavaFileManager.class);
            Assert.checkNonNull(jfm);
            next.put(JavaFileManager.class, jfm);
            if (jfm instanceof JavacFileManager) {
                ((JavacFileManager)jfm).setContext(next);
            }

            Names names = Names.instance(context);
            Assert.checkNonNull(names);
            next.put(Names.namesKey, names);

            Tokens tokens = Tokens.instance(context);
            Assert.checkNonNull(tokens);
            next.put(Tokens.tokensKey, tokens);

            Log nextLog = Log.instance(next);
            nextLog.initRound(log);

            JavaCompiler oldCompiler = JavaCompiler.instance(context);
            JavaCompiler nextCompiler = JavaCompiler.instance(next);
            nextCompiler.initRound(oldCompiler);

            filer.newRound(next);
            messager.newRound(next);
            elementUtils.setContext(next);
            typeUtils.setContext(next);

            JavacTask task = context.get(JavacTask.class);
            if (task != null) {
                next.put(JavacTask.class, task);
                if (task instanceof BasicJavacTask)
                    ((BasicJavacTask) task).updateContext(next);
            }

            JavacTrees trees = context.get(JavacTrees.class);
            if (trees != null) {
                next.put(JavacTrees.class, trees);
                trees.updateContext(next);
            }

            context.clear();
            return next;
View Full Code Here

          PrintWriter errWriter,
          PrintWriter warnWriter,
          PrintWriter noticeWriter,
          String defaultDocletClassName,
          ClassLoader docletParentClassLoader) {
        context = new Context();
        messager = new Messager(context, programName, errWriter, warnWriter, noticeWriter);
        this.defaultDocletClassName = defaultDocletClassName;
        this.docletParentClassLoader = docletParentClassLoader;
    }
View Full Code Here

        this(programName, defaultDocletClassName, null);
    }

    Start(String programName, String defaultDocletClassName,
          ClassLoader docletParentClassLoader) {
        context = new Context();
        messager = new Messager(context, programName);
        this.defaultDocletClassName = defaultDocletClassName;
        this.docletParentClassLoader = docletParentClassLoader;
    }
View Full Code Here

    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

    private RootDocLoader() {
    }

    public static RootDoc fromPath(String path, String subpackage) throws IOException {
        final Context context = new Context();
        Options.instance(context).put("-sourcepath", path);
        Messager.preRegister(context, "Messager!");

        final ListBuffer<String> subPackages = new ListBuffer<String>();
        subPackages.append(subpackage);
View Full Code Here

                                 Iterable<String> classes,
                                 Iterable<? extends JavaFileObject> compilationUnits) {
    ErrorProneOptions errorProneOptions = ErrorProneOptions.processArgs(ArrayUtil.toStringArray(ContainerUtil.toCollection(options)));
    List<String> remainingOptions = Arrays.asList(errorProneOptions.getRemainingArgs());
    CompilationTask task = myJavacTool.getTask(out, fileManager, diagnosticListener, remainingOptions, classes, compilationUnits);
    Context context = ((JavacTaskImpl)task).getContext();
    try {
      ErrorProneScanner scanner = new ErrorProneScanner(ErrorProneScanner.EnabledPredicate.DEFAULT_CHECKS);
      Method setDisabledChecks = ErrorProneScanner.class.getDeclaredMethod("setDisabledChecks", Set.class);
      setDisabledChecks.setAccessible(true);
      setDisabledChecks.invoke(scanner, errorProneOptions.getDisabledChecks());
      context.put(Scanner.class, scanner);
    }
    catch (InvocationTargetException e) {
      throw new RuntimeException(e.getTargetException());
    }
    catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.util.Context$Factory

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.