Package com.sun.tools.javac.util

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


      Iterable<? extends JavaFileObject> compilationUnits) {
    ErrorProneOptions errorProneOptions = ErrorProneOptions.processArgs(options);
    List<String> remainingOptions = Arrays.asList(errorProneOptions.getRemainingArgs());
    CompilationTask task = javacTool.getTask(
        out, fileManager, diagnosticListener, remainingOptions, classes, compilationUnits);
    Context context = ((JavacTaskImpl) task).getContext();
    ErrorProneScanner scanner = scannerSupplier.get();
    context.put(Scanner.class, scanner);
    try {
      scanner.setDisabledChecks(errorProneOptions.getDisabledChecks());
    } catch (InvalidCommandLineOptionException e) {
      throw new RuntimeException(e);
    }
View Full Code Here


    protected Map<String, String> options;

    @Override
    public void init(ProcessingEnvironment processingEnv) {
        super.init(processingEnv);
        final Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
        symTable = Symtab.instance(context);
        trees = Trees.instance(processingEnv);
        elementUtils = JavacElements.instance(context);
        msgr = processingEnv.getMessager();
        tm = TreeMaker.instance(((JavacProcessingEnvironment) processingEnv).getContext());
View Full Code Here

    public JavacFileManager 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

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

     */
    public static JavacTask instance(ProcessingEnvironment processingEnvironment) {
        if (!processingEnvironment.getClass().getName().equals(
                "com.sun.tools.javac.processing.JavacProcessingEnvironment"))
            throw new IllegalArgumentException();
        Context c = ((JavacProcessingEnvironment) processingEnvironment).getContext();
        JavacTask t = c.get(JavacTask.class);
        return (t != null) ? t : new BasicJavacTask(c, true);
    }
View Full Code Here

        private TreeMaker m;

        ImportCleaner(JavaFileManager fm) {
            // ImportCleaner itself doesn't require a filemanager, but instantiating
            // a TreeMaker does, indirectly (via ClassReader, sigh)
            Context c = new Context();
            c.put(JavaFileManager.class, fm);
            m = TreeMaker.instance(c);
        }
View Full Code Here

                out.println(localize("dc.main.no.files.given"));
        }

        JavacTool tool = JavacTool.create();

        JavacFileManager fm = new JavacFileManager(new Context(), false, null);
        fm.setSymbolFileEnabled(false);
        fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, javacBootClassPath);
        fm.setLocation(StandardLocation.CLASS_PATH, javacClassPath);
        fm.setLocation(StandardLocation.SOURCE_PATH, javacSourcePath);

        JavacTask task = tool.getTask(out, fm, null, javacOpts, null,
                fm.getJavaFileObjectsFromFiles(javacFiles));
        Iterable<? extends CompilationUnitTree> units = task.parse();
        ((JavacTaskImpl) task).enter();

        env.init(task);
        checker = new Checker(env);

        DeclScanner ds = new DeclScanner() {
            @Override
            void visitDecl(Tree tree, Name name) {
                TreePath p = getCurrentPath();
                DocCommentTree dc = env.trees.getDocCommentTree(p);

                checker.scan(dc, p);
            }
        };

        ds.scan(units, null);

        reportStats(out);

        Context ctx = ((JavacTaskImpl) task).getContext();
        JavaCompiler c = JavaCompiler.instance(ctx);
        c.printCount("error", c.errorCount());
        c.printCount("warn", c.warningCount());
    }
View Full Code Here

    @Override
    public void run() {
        // Get the post-annotation-processing context (javac sometimes
        // reassigns it during annotation processing.)
        Context finalContext = JOUST.environ.getContext();
        StaticCompilerUtils.uninit();
        StaticCompilerUtils.initWithContext(finalContext);

        List<JCCompilationUnit> compilationUnitList = List.nil();
        for (JCCompilationUnit unit : JOUST.conventionalTrees) {
View Full Code Here

        trees = Trees.instance(env);

        // We typecast the processing environment to the one used by javac. This dirty trick allows
        // us to alter the AST - something not generally possible in annotation processors.
        Context con = ((JavacProcessingEnvironment) env).getContext();

        initWithContext(con);
    }
View Full Code Here

    protected Kind eventKind;
    protected Messages messages;

    public void init(JavacTask task, String... args) {
        BasicJavacTask impl = (BasicJavacTask)task;
        Context context = impl.getContext();
        log = Log.instance(context);
        trees = Trees.instance(task);
        messages = new Messages();
        task.addTaskListener(new PostAnalyzeTaskListener());
    }
View Full Code Here

TOP

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

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.