Examples of CeyloncTaskImpl


Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

    }

    protected void compareWithJavaSourceWithLines(String name) {
        // make a compiler task
        // FIXME: runFileManager.setSourcePath(dir);
        CeyloncTaskImpl task = getCompilerTask(new String[] {name+".ceylon"});

        // grab the CU after we've completed it
        class Listener implements TaskListener{
            JCCompilationUnit compilationUnit;
            private String compilerSrc;
            private JavaPositionsRetriever javaPositionsRetriever = new JavaPositionsRetriever();

            @Override
            public void started(TaskEvent e) {
            }

            @Override
            public void finished(TaskEvent e) {
                if(e.getKind() == Kind.ENTER){
                    if(compilationUnit == null) {
                        compilationUnit = (JCCompilationUnit) e.getCompilationUnit();
                        // for some reason compilationUnit is full here in the listener, but empty as soon
                        // as the compile task is done. probably to clean up for the gc?
                        javaPositionsRetriever.retrieve(compilationUnit);
                        compilerSrc = normalizeLineEndings(javaPositionsRetriever.getJavaSourceCodeWithCeylonLines());
                        AbstractTransformer.trackNodePositions(null);
                    }
                }
            }
        }
        Listener listener = new Listener();
        task.setTaskListener(listener);

        // now compile it all the way
        ExitState exitState = task.call2();
        Assert.assertEquals("Compilation failed", exitState.ceylonState == CeylonState.OK);

        // now look at what we expected
        String expectedSrc = normalizeLineEndings(readFile(new File(getPackagePath(), name+".src"))).trim();
        String compiledSrc = listener.compilerSrc.trim();
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

   
    protected void compareWithJavaSource(List<String> options, String java, String... ceylon) {
        // make a compiler task
        // FIXME: runFileManager.setSourcePath(dir);
        ErrorCollector collector = new ErrorCollector();
        CeyloncTaskImpl task = getCompilerTask(options, collector, ceylon);

        // grab the CU after we've completed it
        class Listener implements TaskListener{
            JCCompilationUnit compilationUnit;
            private String compilerSrc;
            @Override
            public void started(TaskEvent e) {
            }

            @Override
            public void finished(TaskEvent e) {
                if(e.getKind() == Kind.ENTER){
                    if(compilationUnit == null) {
                        compilationUnit = (JCCompilationUnit) e.getCompilationUnit();
                        // for some reason compilationUnit is full here in the listener, but empty as soon
                        // as the compile task is done. probably to clean up for the gc?
                        compilerSrc = normalizeLineEndings(compilationUnit.toString());
                    }
                }
            }
        }
        Listener listener = new Listener();
        task.setTaskListener(listener);

        // now compile it all the way
        assertCompilesOk(collector, task.call2());
       
        // now look at what we expected
        File expectedSrcFile = new File(getPackagePath(), java);
        String expectedSrc = normalizeLineEndings(readFile(expectedSrcFile)).trim();
        String compiledSrc = listener.compilerSrc.trim();
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

    @Test
    public void testImpImportWildcardSinglePass(){
        List<String> options = new LinkedList<String>();
        options.add("-src");
        options.add(getPackagePath()+"/importIt/src");
        CeyloncTaskImpl task = getCompilerTask(options, "importIt/src/pkg/File.ceylon", "importIt/src/pkg/sub/ConcreteDirectory.ceylon");
        Assert.assertTrue(task.call());
        task = getCompilerTask(options, "importIt/src/pkg/File.ceylon", "importIt/src/pkg/sub/ConcreteDirectory.ceylon");
        Assert.assertTrue(task.call());
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

            CompilerError... expectedErrors) {
        // make a compiler task
        // FIXME: runFileManager.setSourcePath(dir);
        ErrorCollector collector = new ErrorCollector();
       
        CeyloncTaskImpl task = getCompilerTask(options, collector, ceylonFiles);

        if (kinds == null) {
            kinds = new Diagnostic.Kind[]{Diagnostic.Kind.ERROR};
        }
       
        boolean expectedToFail = false;
        for (Diagnostic.Kind kind : kinds) {
            if (kind == Diagnostic.Kind.ERROR) {
                expectedToFail = true;
                break;
            }
        }
        // now compile it all the way
        Throwable ex = null;
        ExitState exitState = task.call2();
        switch (exitState.ceylonState) {
        case OK:
            if (expectedToFail) {
                Assert.fail("Compilation successful (it should have failed!)");
            }
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

    }
   
    protected void compareWithJavaSourceWithPositions(String name) {
        // make a compiler task
        // FIXME: runFileManager.setSourcePath(dir);
        CeyloncTaskImpl task = getCompilerTask(new String[] {name+".ceylon"});

        // grab the CU after we've completed it
        class Listener implements TaskListener{
            JCCompilationUnit compilationUnit;
            private String compilerSrc;
            private JavaPositionsRetriever javaPositionsRetriever = new JavaPositionsRetriever();

            @Override
            public void started(TaskEvent e) {
                AbstractTransformer.trackNodePositions(javaPositionsRetriever);
            }

            @Override
            public void finished(TaskEvent e) {
                if(e.getKind() == Kind.ENTER){
                    if(compilationUnit == null) {
                        compilationUnit = (JCCompilationUnit) e.getCompilationUnit();
                        // for some reason compilationUnit is full here in the listener, but empty as soon
                        // as the compile task is done. probably to clean up for the gc?
                        javaPositionsRetriever.retrieve(compilationUnit);
                        compilerSrc = normalizeLineEndings(javaPositionsRetriever.getJavaSourceCodeWithCeylonPositions());
                        AbstractTransformer.trackNodePositions(null);
                    }
                }
            }
        }
        Listener listener = new Listener();
        task.setTaskListener(listener);

        // now compile it all the way
        ExitState exitState = task.call2();
        Assert.assertEquals("Compilation failed", exitState.ceylonState, CeylonState.OK);

        // now look at what we expected
        String expectedSrc = normalizeLineEndings(readFile(new File(getPackagePath(), name+".src"))).trim();
        String compiledSrc = listener.compilerSrc.trim();
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

        }
        CeyloncFileManager fileManager = (CeyloncFileManager)compiler.getStandardFileManager(null, null, null);
        Iterable<? extends JavaFileObject> compilationUnits1 =
            fileManager.getJavaFileObjectsFromFiles(sourceFiles);
        String compilerSourcePath = ceylonSourcePath + File.pathSeparator + javaSourcePath;
        CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, null,
                Arrays.asList("-sourcepath", compilerSourcePath,
                              "-d", "build/classes-runtime", "-Xbootstrapceylon",
                              "-cp", getClassPathAsPathExcludingLanguageModule(),
                              "-suppress-warnings", "ceylonNamespace"
                              /*, "-verbose"*/),
                null, compilationUnits1);
        Boolean result = task.call();
        Assert.assertEquals("Compilation failed", Boolean.TRUE, result);
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

        }
        CeyloncFileManager fileManager = (CeyloncFileManager)compiler.getStandardFileManager(null, null, null);
        Iterable<? extends JavaFileObject> compilationUnits1 =
            fileManager.getJavaFileObjectsFromFiles(sourceFiles);
        String compilerSourcePath = sdkSourcePath + File.pathSeparator + testSourcePath;
        CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, null,
                Arrays.asList("-sourcepath", compilerSourcePath, "-d", "../ceylon-sdk/modules"/*, "-verbose"*/),
                null, compilationUnits1);
        Boolean result = task.call();
        Assert.assertEquals("Compilation failed", Boolean.TRUE, result);
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

            System.err.println("ERROR: Cannot run tests! Did you maybe forget to configure the -Xbootclasspath/p: parameter?");
            throw e;
        }
        ErrorCollector errorCollector = new ErrorCollector();
        CeyloncFileManager fileManager = (CeyloncFileManager)compiler.getStandardFileManager(null, null, null);
        CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, errorCollector,
                Arrays.asList("-sourcepath", sourceDir, "-d", "build/classes-sdk",
                        "-suppress-warnings", "ceylonNamespace",
                        "-cp", getClassPathAsPath()),
                        moduleNames, null);
        Boolean result = task.call();
        Assert.assertEquals("Compilation of SDK itself failed: " + errorCollector.getAssertionFailureMessage(), Boolean.TRUE, result);
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

            System.err.println("ERROR: Cannot run tests! Did you maybe forget to configure the -Xbootclasspath/p: parameter?");
            throw e;
        }
        ErrorCollector errorCollector = new ErrorCollector();
        CeyloncFileManager fileManager = (CeyloncFileManager)compiler.getStandardFileManager(null, null, null);
        CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, errorCollector,
                Arrays.asList("-sourcepath", sourceDir, "-rep", depsDir, "-d", "build/classes-sdk", "-cp", getClassPathAsPath()),
                moduleNames, null);
       
        Boolean result = task.call();
        Assert.assertEquals("Compilation of SDK tests failed:" + errorCollector.getAssertionFailureMessage(), Boolean.TRUE, result);
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl

    protected void verifyCompilerClassLoading(String ceylon) {
        verifyCompilerClassLoading(ceylon, new ModelComparison());
    }
    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);
       
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.