Package com.sun.tools.javac.util

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


    }
    protected void verifyCompilerClassLoading(String ceylon, final ModelComparison modelCompare){
        // now compile the ceylon decl file
        CeyloncTaskImpl task = getCompilerTask(ceylon);
        // get the context to grab the phased units
        Context context = task.getContext();

        Boolean success = task.call();
       
        Assert.assertTrue(success);

        PhasedUnits phasedUnits = LanguageCompiler.getPhasedUnitsInstance(context);
       
        // find out what was in that file
        Assert.assertEquals(2, phasedUnits.getPhasedUnits().size());
        PhasedUnit one = phasedUnits.getPhasedUnits().get(0);
        PhasedUnit two = phasedUnits.getPhasedUnits().get(1);
        PhasedUnit phasedUnit = one.getUnitFile().getName().endsWith("module.ceylon")
                ? two : one;
        final Map<String,Declaration> decls = new HashMap<String,Declaration>();
        for(Declaration decl : phasedUnit.getUnit().getDeclarations()){
            if(decl.isToplevel()){
                decls.put(getQualifiedPrefixedName(decl), decl);
            }
        }

        // now compile the ceylon usage file
        // remove the extension, make lowercase and add "test"
        String testfile = ceylon.substring(0, ceylon.length()-7).toLowerCase()+"test.ceylon";
        JavacTaskImpl task2 = getCompilerTask(testfile);
        // get the context to grab the declarations
        final Context context2 = task2.getContext();
       
        // check the declarations after Enter but before the compilation is done otherwise we can't load lazy
        // declarations from the jar anymore because we've overridden the jar and the javac jar index is corrupted
        class Listener implements TaskListener{
            @Override
View Full Code Here


   
    protected void verifyCompilerClassLoading(String ceylon, final RunnableTest test, List<String> options){
        // now compile the ceylon usage file
        JavacTaskImpl task2 = getCompilerTask(options, ceylon);
        // get the context to grab the declarations
        final Context context2 = task2.getContext();
       
        // check the declarations after Enter but before the compilation is done otherwise we can'tload lazy
        // declarations from the jar anymore because we've overridden the jar and the javac jar index is corrupted
        class Listener implements TaskListener{
            @Override
View Full Code Here

        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;
        Names names = Names.instance(ctx);
View Full Code Here

    public static void main(String... args) throws Exception {
        new MakeLiteralTest().run();
    }

    void run() throws Exception {
        Context context = new Context();
        JavacFileManager.preRegister(context);
        Symtab syms = Symtab.instance(context);
        maker = TreeMaker.instance(context);
        types = Types.instance(context);
View Full Code Here

    protected Symtab predef;
    protected Names names;
    protected Factory fac;

    protected TypeHarness() {
        Context ctx = new Context();
        JavacFileManager.preRegister(ctx);
        types = Types.instance(ctx);
        chk = Check.instance(ctx);
        predef = Symtab.instance(ctx);
        names = Names.instance(ctx);
View Full Code Here

    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        round++;

        JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv;
        Context c = jpe.getContext();
        check(c.get(JavacElements.class), eltUtils);
        check(c.get(JavacTypes.class), typeUtils);
        check(c.get(JavacTrees.class), treeUtils);

        final int MAXROUNDS = 3;
        if (round < MAXROUNDS)
            generateSource("Gen" + round);
View Full Code Here

    //---------------

    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
        Locale locale = context.get(Locale.class);
        JavacMessages messages = context.get(JavacMessages.messagesKey);

        round++;
        if (round == 1) {
            initialLocale = locale;
            initialMessages = messages;
View Full Code Here

        test(false);
        test(true);
    }

    static void test(boolean genEndPos) throws IOException {
        Context context = new Context();

        Options options = Options.instance(context);
        options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");

        Log log = Log.instance(context);
View Full Code Here

        System.err.println("Test " + count + " " + Arrays.asList(opts) + " " + className);
        Path testSrcDir = Paths.get(System.getProperty("test.src"));
        Path testClassesDir = Paths.get(System.getProperty("test.classes"));
        Path classes = Files.createDirectory(Paths.get("classes." + count));

        Context ctx = new Context();
        PathFileManager fm = new JavacPathFileManager(ctx, true, null);
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        List<String> options = new ArrayList<String>();
        options.addAll(Arrays.asList(opts));
        options.addAll(Arrays.asList(
View Full Code Here

    public static void main(String[] args) throws IOException {
        List<? extends JavaFileObject> files = Arrays.asList(new SourceFile());
        JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
        JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, files);
        Context ctx = new Context();
        JavacFileManager.preRegister(ctx);
        checkImplementationCache(ct.analyze(), Types.instance(ctx));
    }
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.