aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/src/lombok/RunTestsViaEclipse.java40
-rw-r--r--test/transform/resource/after-eclipse/LoggerSlf4jWithPackage.java23
-rw-r--r--test/transform/resource/messages-eclipse/LoggerSlf4jOnNonType.java.messages3
3 files changed, 50 insertions, 16 deletions
diff --git a/test/core/src/lombok/RunTestsViaEclipse.java b/test/core/src/lombok/RunTestsViaEclipse.java
index 03f205ba..82df9c91 100644
--- a/test/core/src/lombok/RunTestsViaEclipse.java
+++ b/test/core/src/lombok/RunTestsViaEclipse.java
@@ -66,29 +66,37 @@ public class RunTestsViaEclipse extends AbstractRunTests {
}
@Override public void transformCode(final StringBuilder messages, StringWriter result, File file) throws Throwable {
- String source = readFile(file);
- CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), "UTF-8");
- IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
- IProblemFactory problemFactory = new DefaultProblemFactory(Locale.ENGLISH);
- INameEnvironment nameEnvironment = new LombokTestNameEnvironment();
- ICompilerRequestor compilerRequestor = new LombokTestCompilerRequestor();
- CompilerOptions options = ecjCompilerOptions();
+ // setup parser and compiler
+ final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
+ final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.ENGLISH);
+ final INameEnvironment nameEnvironment = new LombokTestNameEnvironment();
+ final ICompilerRequestor compilerRequestor = new LombokTestCompilerRequestor();
+ final ISourceElementRequestor sourceElementRequestor = new LombokTestSourceElementRequestor();
+ final CompilerOptions options = ecjCompilerOptions();
+ final LombokTestCompiler jdtCompiler = new LombokTestCompiler(nameEnvironment, policy, options, compilerRequestor, problemFactory);
+ final SourceElementParser parser = new SourceElementParser(sourceElementRequestor, problemFactory, options, true, true);
+ // read the file
+ final String source = readFile(file);
+ final CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), "UTF-8");
- ISourceElementRequestor sourceElementRequestor = new LombokTestSourceElementRequestor();
- SourceElementParser parser = new SourceElementParser(sourceElementRequestor, problemFactory, options, true, true);
- final CompilationUnitDeclaration cud = parser.parseCompilationUnit(sourceUnit, true, null);
- final LombokTestCompiler jdtCompiler = new LombokTestCompiler(nameEnvironment, policy, options, compilerRequestor, problemFactory);
+ // parse
+ final CompilationUnitDeclaration cud = parser.parseCompilationUnit(sourceUnit, true, null);
+ // build
jdtCompiler.lookupEnvironment.buildTypeBindings(cud, null);
jdtCompiler.lookupEnvironment.completeTypeBindings(cud, true);
+ // process
+ if (cud.scope != null) cud.scope.verifyMethods(jdtCompiler.lookupEnvironment.methodVerifier());
- CategorizedProblem[] problems = cud.compilationResult.getAllProblems();
+ // handle problems
+ final CategorizedProblem[] problems = cud.compilationResult.getAllProblems();
if (problems != null) for (CategorizedProblem p : problems) {
messages.append(String.format("%d %s %s\n", p.getSourceLineNumber(), p.isError() ? "error" : p.isWarning() ? "warning" : "unknown", p.getMessage()));
}
+ // set transformed code
result.append(cud.toString());
}
@@ -217,6 +225,10 @@ public class RunTestsViaEclipse extends AbstractRunTests {
private static class LombokTestNameEnvironment implements INameEnvironment {
Map<String, Boolean> packagesCache = new HashMap<String, Boolean>();
+ public LombokTestNameEnvironment() {
+ packagesCache.put("before", true);
+ }
+
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
final StringBuffer result = new StringBuffer();
for (int i = 0; i < compoundTypeName.length; i++) {
@@ -289,8 +301,8 @@ public class RunTestsViaEclipse extends AbstractRunTests {
if (packagesCache.containsKey(name)) {
return packagesCache.get(name).booleanValue();
}
- byte[] bytes = getClassDefinition(name);
- if (bytes != null) {
+
+ if (name.startsWith("before") || (getClassDefinition(name) != null)) {
packagesCache.put(name, false);
return false;
}
diff --git a/test/transform/resource/after-eclipse/LoggerSlf4jWithPackage.java b/test/transform/resource/after-eclipse/LoggerSlf4jWithPackage.java
index cb06d3c1..6d395db8 100644
--- a/test/transform/resource/after-eclipse/LoggerSlf4jWithPackage.java
+++ b/test/transform/resource/after-eclipse/LoggerSlf4jWithPackage.java
@@ -1 +1,22 @@
-//ignore \ No newline at end of file
+package before;
+@lombok.extern.slf4j.Slf4j class LoggerSlf4jWithPackage {
+ private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithPackage.class);
+ <clinit>() {
+ }
+ LoggerSlf4jWithPackage() {
+ super();
+ }
+}
+class LoggerSlf4jWithPackageOuter {
+ static @lombok.extern.slf4j.Slf4j class Inner {
+ private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class);
+ <clinit>() {
+ }
+ Inner() {
+ super();
+ }
+ }
+ LoggerSlf4jWithPackageOuter() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/messages-eclipse/LoggerSlf4jOnNonType.java.messages b/test/transform/resource/messages-eclipse/LoggerSlf4jOnNonType.java.messages
index 4a446f28..4af47f01 100644
--- a/test/transform/resource/messages-eclipse/LoggerSlf4jOnNonType.java.messages
+++ b/test/transform/resource/messages-eclipse/LoggerSlf4jOnNonType.java.messages
@@ -1 +1,2 @@
-2 error @Log is legal only on types. \ No newline at end of file
+2 error @Log is legal only on types.
+2 error The annotation @Slf4j is disallowed for this location \ No newline at end of file