List of utility methods to do Diagnostic to Output
String | diagnosticToString(final Diagnostic extends JavaFileObject> diagnostic, boolean usingAnomsgtxt) diagnostic To String String result = diagnostic.toString().trim(); if (result.contains("uses unchecked or unsafe operations.") || result.contains("Recompile with -Xlint:unchecked for details.") || result.endsWith(" declares unsafe vararg methods.") || result.contains("Recompile with -Xlint:varargs for details.")) { return null; if (usingAnomsgtxt) { ... |
String | errorsToString(DiagnosticCollector errors To String StringBuilder builder = new StringBuilder(); for (javax.tools.Diagnostic<? extends JavaFileObject> diagnostic : diagnosticCollector.getDiagnostics()) { if (diagnostic.getKind() == javax.tools.Diagnostic.Kind.ERROR) { builder.append(diagnostic).append("\n"); return builder.toString(); |
List | filterSupportedSourceVersionWarnings( List Filter out warnings about SupportedSourceVersion . List<Diagnostic<? extends JavaFileObject>> r = new ArrayList<Diagnostic<? extends JavaFileObject>>(); for (Diagnostic<? extends JavaFileObject> d : diagnostics) { if (!d.getMessage(Locale.ENGLISH).contains("SupportedSourceVersion")) { r.add(d); return r; |
void | log(ProcessingEnvironment processingEnvironment, Diagnostic.Kind kind, CharSequence message) log processingEnvironment.getMessager().printMessage(kind, MESSAGER_HEADER + " " + message);
|
void | note(final ProcessingEnvironment processingEnv, final String message, final Object... args) Writes a message of type Kind#NOTE to the messager substituting arguments in the message using String#format(String,Object) . processingEnv.getMessager().printMessage(Kind.NOTE, PREFIX + String.format(message, args)); |
void | raiseCompilerError(String error) Raises a fatal compiler error with the given message, halting execution. if (processingEnv == null) { return; processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Fatal error from optimiser: " + error + "\nAt:\n" + Arrays.toString(new Exception().getStackTrace()).replace(',', '\n')); |