Search in sources :

Example 1 with CompilationResult

use of org.mapstruct.ap.testutil.compilation.annotation.CompilationResult in project mapstruct by mapstruct.

the class CompilationOutcomeDescriptor method forResult.

public static CompilationOutcomeDescriptor forResult(String sourceDir, CompilerResult compilerResult) {
    CompilationResult compilationResult = compilerResult.isSuccess() ? CompilationResult.SUCCEEDED : CompilationResult.FAILED;
    List<DiagnosticDescriptor> diagnosticDescriptors = new ArrayList<>();
    for (CompilerMessage message : compilerResult.getCompilerMessages()) {
        if (message.getKind() != CompilerMessage.Kind.NOTE) {
            diagnosticDescriptors.add(DiagnosticDescriptor.forCompilerMessage(sourceDir, message));
        }
    // the eclipse compiler does not support NOTE (it is never actually set).
    }
    return new CompilationOutcomeDescriptor(compilationResult, diagnosticDescriptors, Collections.emptyList());
}
Also used : CompilerMessage(org.codehaus.plexus.compiler.CompilerMessage) ArrayList(java.util.ArrayList) CompilationResult(org.mapstruct.ap.testutil.compilation.annotation.CompilationResult)

Example 2 with CompilationResult

use of org.mapstruct.ap.testutil.compilation.annotation.CompilationResult in project mapstruct by mapstruct.

the class CompilationOutcomeDescriptor method forResult.

public static CompilationOutcomeDescriptor forResult(String sourceDir, boolean compilationSuccessful, List<Diagnostic<? extends JavaFileObject>> diagnostics) {
    CompilationResult compilationResult = compilationSuccessful ? CompilationResult.SUCCEEDED : CompilationResult.FAILED;
    List<String> notes = new ArrayList<>();
    List<DiagnosticDescriptor> diagnosticDescriptors = new ArrayList<>();
    for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) {
        // ignore notes created by the compiler
        if (diagnostic.getKind() != Kind.NOTE) {
            diagnosticDescriptors.add(DiagnosticDescriptor.forDiagnostic(sourceDir, diagnostic));
        } else {
            notes.add(diagnostic.getMessage(null));
        }
    }
    return new CompilationOutcomeDescriptor(compilationResult, diagnosticDescriptors, notes);
}
Also used : ArrayList(java.util.ArrayList) CompilationResult(org.mapstruct.ap.testutil.compilation.annotation.CompilationResult)

Aggregations

ArrayList (java.util.ArrayList)2 CompilationResult (org.mapstruct.ap.testutil.compilation.annotation.CompilationResult)2 CompilerMessage (org.codehaus.plexus.compiler.CompilerMessage)1