Search in sources :

Example 6 with CeyloncFileManager

use of com.redhat.ceylon.compiler.java.tools.CeyloncFileManager in project ceylon-compiler by ceylon.

the class CompilerTests method getCompilerTask.

protected CeyloncTaskImpl getCompilerTask(List<String> initialOptions, DiagnosticListener<? super FileObject> diagnosticListener, List<String> modules, String... sourcePaths) {
    java.util.List<File> sourceFiles = new ArrayList<File>(sourcePaths.length);
    for (String file : sourcePaths) {
        sourceFiles.add(new File(getPackagePath(), file));
    }
    CeyloncTool runCompiler = makeCompiler();
    CeyloncFileManager runFileManager = makeFileManager(runCompiler, diagnosticListener);
    // make sure the destination repo exists
    new File(destDir).mkdirs();
    List<String> options = new LinkedList<String>();
    options.addAll(initialOptions);
    if (!options.contains("-src"))
        options.addAll(Arrays.asList("-src", getSourcePath()));
    if (!options.contains("-cacherep"))
        options.addAll(Arrays.asList("-cacherep", getCachePath()));
    if (!options.contains("-cp"))
        options.addAll(Arrays.asList("-cp", getClassPathAsPath()));
    boolean hasVerbose = false;
    for (String option : options) {
        if (option.startsWith("-verbose")) {
            hasVerbose = true;
            break;
        }
    }
    if (!hasVerbose)
        options.add("-verbose:ast,code");
    Iterable<? extends JavaFileObject> compilationUnits1 = runFileManager.getJavaFileObjectsFromFiles(sourceFiles);
    return runCompiler.getTask(null, runFileManager, diagnosticListener, options, modules, compilationUnits1);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(com.redhat.ceylon.compiler.java.tools.CeyloncTool) File(java.io.File) CeyloncFileManager(com.redhat.ceylon.compiler.java.tools.CeyloncFileManager) LinkedList(java.util.LinkedList)

Aggregations

CeyloncFileManager (com.redhat.ceylon.compiler.java.tools.CeyloncFileManager)6 CeyloncTool (com.redhat.ceylon.compiler.java.tools.CeyloncTool)6 File (java.io.File)6 ArrayList (java.util.ArrayList)6 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)5 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)3 Test (org.junit.Test)3 LinkedList (java.util.LinkedList)2 FileFilter (java.io.FileFilter)1 StringWriter (java.io.StringWriter)1 Ignore (org.junit.Ignore)1