aboutsummaryrefslogtreecommitdiff
path: root/test/core/src/lombok/RunTestsViaEcj.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2010-07-21 23:52:28 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2010-07-21 23:52:28 +0200
commit59e585a0c68959eb72be34524bdad19df5dc8a4d (patch)
tree72860f9fce0a62bb1d0e8dbe3a021f4bd8f20ab4 /test/core/src/lombok/RunTestsViaEcj.java
parent1a9f8f168aa17f77c6e27d0a740b5f7614fb5c90 (diff)
downloadlombok-59e585a0c68959eb72be34524bdad19df5dc8a4d.tar.gz
lombok-59e585a0c68959eb72be34524bdad19df5dc8a4d.tar.bz2
lombok-59e585a0c68959eb72be34524bdad19df5dc8a4d.zip
refactored the tests to prepare running ecj as well as delombok.
Diffstat (limited to 'test/core/src/lombok/RunTestsViaEcj.java')
-rw-r--r--test/core/src/lombok/RunTestsViaEcj.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java
new file mode 100644
index 00000000..3f7d6e81
--- /dev/null
+++ b/test/core/src/lombok/RunTestsViaEcj.java
@@ -0,0 +1,56 @@
+package lombok;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.util.Locale;
+
+import lombok.eclipse.TransformEclipseAST;
+
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+
+public class RunTestsViaEcj extends AbstractRunTests {
+ protected static CompilerOptions ecjCompilerOptions() {
+ CompilerOptions options = new CompilerOptions();
+ options.complianceLevel = ClassFileConstants.JDK1_6;
+ options.sourceLevel = ClassFileConstants.JDK1_6;
+ options.targetJDK = ClassFileConstants.JDK1_6;
+ options.parseLiteralExpressionsAsConstants = true;
+ return options;
+ }
+
+ @Override
+ public void transformCode(final StringBuilder messages, StringWriter result, File file) throws Throwable {
+ ProblemReporter problemReporter = new ProblemReporter(new IErrorHandlingPolicy() {
+ public boolean proceedOnErrors() {
+ return true;
+ }
+
+ public boolean stopOnFirstError() {
+ return false;
+ }
+ }, ecjCompilerOptions(), new DefaultProblemFactory(Locale.ENGLISH));
+
+ Parser parser = new Parser(problemReporter, true);
+ String source = readFile(file);
+ CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), "UTF-8");
+ CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+ CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
+
+ TransformEclipseAST.transform(parser, cud);
+
+ for (CategorizedProblem p : compilationResult.getErrors()) {
+ messages.append(p.toString()).append("\n");
+ }
+
+ result.append(cud.toString());
+ }
+}