Search in sources :

Example 1 with Abort

use of org.eclipse.ceylon.langtools.tools.javac.util.Abort in project ceylon by eclipse.

the class LanguageCompiler method addResources.

private void addResources() throws Abort {
    HashSet<String> written = new HashSet<String>();
    try {
        for (JavaFileObject fo : resourceFileObjects) {
            CeyloncFileManager dfm = (CeyloncFileManager) fileManager;
            String jarFileName = JarUtils.toPlatformIndependentPath(dfm.getLocation(CeylonLocation.RESOURCE_PATH), fo.getName());
            if (!written.contains(jarFileName)) {
                dfm.setModule(modelLoader.findModuleForFile(new File(jarFileName)));
                FileObject outFile = dfm.getFileForOutput(StandardLocation.CLASS_OUTPUT, "", jarFileName, null);
                OutputStream out = outFile.openOutputStream();
                try {
                    InputStream in = new FileInputStream(new File(fo.getName()));
                    try {
                        JarUtils.copy(in, out);
                    } finally {
                        in.close();
                    }
                } finally {
                    out.close();
                }
                written.add(jarFileName);
            }
        }
    } catch (IOException ex) {
        throw new Abort(ex);
    }
}
Also used : JavaFileObject(org.eclipse.ceylon.javax.tools.JavaFileObject) Abort(org.eclipse.ceylon.langtools.tools.javac.util.Abort) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) JavaFileObject(org.eclipse.ceylon.javax.tools.JavaFileObject) FileObject(org.eclipse.ceylon.javax.tools.FileObject) CeylonFileObject(org.eclipse.ceylon.compiler.java.codegen.CeylonFileObject) IOException(java.io.IOException) VirtualFile(org.eclipse.ceylon.compiler.typechecker.io.VirtualFile) File(java.io.File) FileInputStream(java.io.FileInputStream) HashSet(java.util.HashSet)

Example 2 with Abort

use of org.eclipse.ceylon.langtools.tools.javac.util.Abort in project ceylon by eclipse.

the class CeylonEnter method prepareForTypeChecking.

public void prepareForTypeChecking(List<JCCompilationUnit> trees) {
    if (hasRun)
        throw new RuntimeException("Waaaaa, running twice!!!");
    // By now le language module version should be known (as local)
    // or we should use the default one.
    int numParserErrors = log.nerrors;
    // load the standard modules
    timer.startTask("loadStandardModules");
    compilerDelegate.loadStandardModules(modelLoader);
    timer.endTask();
    // load the modules we are compiling first
    hasRun = true;
    // make sure we don't load the files we are compiling from their class files
    timer.startTask("setupSourceFileObjects");
    compilerDelegate.setupSourceFileObjects(trees, modelLoader);
    timer.endTask();
    // resolve module dependencies
    timer.startTask("verifyModuleDependencyTree");
    compilerDelegate.resolveModuleDependencies(phasedUnits);
    timer.endTask();
    // now load package descriptors
    timer.startTask("loadPackageDescriptors");
    compilerDelegate.loadPackageDescriptors(modelLoader);
    timer.endTask();
    // at this point, abort if we had any errors logged due to module descriptors
    timer.startTask("collectTreeErrors");
    collectTreeErrors(false, false);
    timer.endTask();
    // check if we abort on errors or not
    if (options.get(Option.CEYLONCONTINUE) == null) {
        // they can't be re-logged and duplicated later on
        if (log.nerrors - numParserErrors > 0)
            throw new Abort();
    }
}
Also used : Abort(org.eclipse.ceylon.langtools.tools.javac.util.Abort)

Aggregations

Abort (org.eclipse.ceylon.langtools.tools.javac.util.Abort)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashSet (java.util.HashSet)1 CeylonFileObject (org.eclipse.ceylon.compiler.java.codegen.CeylonFileObject)1 VirtualFile (org.eclipse.ceylon.compiler.typechecker.io.VirtualFile)1 FileObject (org.eclipse.ceylon.javax.tools.FileObject)1 JavaFileObject (org.eclipse.ceylon.javax.tools.JavaFileObject)1