use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class RecoveryTests method testSyntaxErrorInModule.
@Test
public void testSyntaxErrorInModule() throws IOException {
String subPath = "modules/syntaxErrorInModule";
String srcPath = getPackagePath() + subPath;
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(srcPath);
options.addAll(defaultOptions);
options.add("-continue");
ErrorCollector c = new ErrorCollector();
CeyloncTaskImpl task = getCompilerTask(options, c, Arrays.asList("okmodule"), subPath + "/someok.ceylon");
Boolean ret = task.call();
assertFalse(ret);
TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
compareErrors(actualErrors, new CompilerError(20, "incorrect syntax: missing ':' operator at '\"1.0.0\"'"));
File carFile = getModuleArchive("default", null);
assertTrue(carFile.exists());
JarFile car = new JarFile(carFile);
ZipEntry moduleClass = car.getEntry("foobar_.class");
assertNotNull(moduleClass);
car.close();
carFile = getModuleArchive("okmodule", "1.0.0");
assertFalse(carFile.exists());
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class JavaCompilerImpl method compile.
@SuppressWarnings("deprecation")
@Override
public boolean compile(CompilerOptions options, CompilationListener listener) {
CeyloncTool compiler = new CeyloncTool();
CompilationListenerAdapter diagnosticListener = new CompilationListenerAdapter(listener);
Writer writer = options.getOutWriter();
if (!options.isVerbose() && writer == null) {
// make the tool shut the hell up
writer = new NullWriter();
}
JavacFileManager fileManager = compiler.getStandardFileManager(writer, diagnosticListener, null, null);
Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(options.getFiles());
CeyloncTaskImpl compilerTask = compiler.getTask(null, fileManager, diagnosticListener, translateOptions(options), options.getModules(), compilationUnits);
compilerTask.setTaskListener(diagnosticListener);
ExitState state = compilerTask.call2();
// print any helpful info if required
if (options.isVerbose() && state.abortingException != null)
state.abortingException.printStackTrace();
return state.ceylonState == CeylonState.OK;
}
Aggregations