use of org.eclipse.ceylon.javax.tools.DiagnosticListener in project ceylon by eclipse.
the class CeyloncTool method getStandardFileManager.
public JavacFileManager getStandardFileManager(Writer out, DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset) {
Context context = new Context();
if (diagnosticListener != null)
context.put(DiagnosticListener.class, diagnosticListener);
// make sure we set the out before someone else sets a default one, or uses one
if (context.get(Log.outKey) == null) {
if (out == null)
context.put(Log.outKey, new PrintWriter(System.err, true));
else
context.put(Log.outKey, new PrintWriter(out, true));
}
CeylonLog.preRegister(context);
return new CeyloncFileManager(context, true, charset);
}
use of org.eclipse.ceylon.javax.tools.DiagnosticListener in project ceylon by eclipse.
the class CeyloncTool method getTask.
public CeyloncTaskImpl getTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes, Iterable<? extends JavaFileObject> compilationUnits) {
// final String kindMsg = "All compilation units must be of SOURCE kind";
if (options != null)
for (String option : options) // null check
option.getClass();
if (classes != null) {
for (String cls : classes) if (// implicit null check
!SourceVersion.isName(cls) && // FIX for ceylon because default is not a valid name for Java
!"default".equals(cls))
throw new IllegalArgumentException("Not a valid class name: " + cls);
}
if (fileManager == null)
fileManager = getStandardFileManager(out, diagnosticListener, null, null);
Context context = ((CeyloncFileManager) fileManager).getContext();
if (diagnosticListener != null && context.get(DiagnosticListener.class) == null)
context.put(DiagnosticListener.class, diagnosticListener);
context.put(JavaFileManager.class, fileManager);
JavacTool.processOptions(context, fileManager, options);
Main compiler = new Main("ceyloncTask", context.get(Log.outKey));
return new CeyloncTaskImpl(compiler, options, context, classes, compilationUnits);
}
Aggregations