mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#132 Docs
This commit is contained in:
parent
e5272fab2b
commit
e88ea868ac
@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.testutil.runner;
|
package org.mapstruct.ap.testutil.runner;
|
||||||
|
|
||||||
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -30,6 +32,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import javax.tools.DiagnosticCollector;
|
import javax.tools.DiagnosticCollector;
|
||||||
import javax.tools.JavaCompiler;
|
import javax.tools.JavaCompiler;
|
||||||
import javax.tools.JavaCompiler.CompilationTask;
|
import javax.tools.JavaCompiler.CompilationTask;
|
||||||
@ -48,8 +51,6 @@ import org.mapstruct.ap.testutil.compilation.annotation.ProcessorOption;
|
|||||||
import org.mapstruct.ap.testutil.compilation.model.CompilationOutcomeDescriptor;
|
import org.mapstruct.ap.testutil.compilation.model.CompilationOutcomeDescriptor;
|
||||||
import org.mapstruct.ap.testutil.compilation.model.DiagnosticDescriptor;
|
import org.mapstruct.ap.testutil.compilation.model.DiagnosticDescriptor;
|
||||||
|
|
||||||
import static org.fest.assertions.Assertions.assertThat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A JUnit4 statement that performs source generation using the annotation processor and compiles those sources.
|
* A JUnit4 statement that performs source generation using the annotation processor and compiles those sources.
|
||||||
*
|
*
|
||||||
@ -66,15 +67,20 @@ class CompilingStatement extends Statement {
|
|||||||
|
|
||||||
private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
|
private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
|
||||||
private static final DiagnosticDescriptorComparator COMPARATOR = new DiagnosticDescriptorComparator();
|
private static final DiagnosticDescriptorComparator COMPARATOR = new DiagnosticDescriptorComparator();
|
||||||
|
|
||||||
private static final ThreadLocal<Integer> THREAD_NUMBER = new ThreadLocal<Integer>() {
|
private static final ThreadLocal<Integer> THREAD_NUMBER = new ThreadLocal<Integer>() {
|
||||||
private final AtomicInteger highWaterMark = new AtomicInteger( 0 );
|
private final AtomicInteger nextThreadId = new AtomicInteger( 0 );
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Integer initialValue() {
|
protected Integer initialValue() {
|
||||||
return highWaterMark.getAndIncrement();
|
return nextThreadId.getAndIncrement();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caches the outcome of given compilations. That way we avoid the repeated compilation of the same source files for
|
||||||
|
* several test methods of one test class.
|
||||||
|
*/
|
||||||
private static final ThreadLocal<CompilationCache> COMPILATION_CACHE = new ThreadLocal<CompilationCache>() {
|
private static final ThreadLocal<CompilationCache> COMPILATION_CACHE = new ThreadLocal<CompilationCache>() {
|
||||||
@Override
|
@Override
|
||||||
protected CompilationCache initialValue() {
|
protected CompilationCache initialValue() {
|
||||||
@ -369,6 +375,9 @@ class CompilingStatement extends Statement {
|
|||||||
private CompilationResultHolder lastResult;
|
private CompilationResultHolder lastResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the result of a compilation.
|
||||||
|
*/
|
||||||
private static class CompilationResultHolder {
|
private static class CompilationResultHolder {
|
||||||
private final DiagnosticCollector<JavaFileObject> diagnostics;
|
private final DiagnosticCollector<JavaFileObject> diagnostics;
|
||||||
private final boolean compilationSuccessful;
|
private final boolean compilationSuccessful;
|
||||||
@ -379,6 +388,9 @@ class CompilingStatement extends Statement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a compilation task for a number of sources with given processor options.
|
||||||
|
*/
|
||||||
private static class CompilationRequest {
|
private static class CompilationRequest {
|
||||||
private final Set<Class<?>> sourceClasses;
|
private final Set<Class<?>> sourceClasses;
|
||||||
private final List<String> processorOptions;
|
private final List<String> processorOptions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user