aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-02-11 22:34:48 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-02-11 22:34:48 +0100
commitaafd83079a3000d3deb6e40a182849da2509fbfb (patch)
treecf87951eee9bb098bb96ecc3c02c6f1ab34c405d /test
parentef8769d3180b2c6de91a64f69dfa23a2e6e449b9 (diff)
downloadlombok-aafd83079a3000d3deb6e40a182849da2509fbfb.tar.gz
lombok-aafd83079a3000d3deb6e40a182849da2509fbfb.tar.bz2
lombok-aafd83079a3000d3deb6e40a182849da2509fbfb.zip
BIG commit:
* re-introduction of onMethod/onConstructor/onParam * tests checking error/warnings rewritten to be more heuristic, in order to accomodate difference in messaging between java6 and java 7 * Ability to eliminate java's own output of erroneous error messages (heh); i.e. those messages that are invalidated by lombok's actions. This mechanism is used for onMethod/onConstructor/onParam * First steps to unifying a billion setGeneratedBy calls into a single visitor traversal for eclipse' HandleGetter/Setter/Constructor/Wither * To simplify 'zooming in' the tests on just a few files, added an 'accept' mechanism. * Updated copyright headers of website to 2013.
Diffstat (limited to 'test')
-rw-r--r--test/core/src/lombok/AbstractRunTests.java18
-rw-r--r--test/core/src/lombok/CompilerMessage.java50
-rw-r--r--test/core/src/lombok/CompilerMessageMatcher.java33
-rw-r--r--test/core/src/lombok/DirectoryRunner.java19
-rw-r--r--test/core/src/lombok/RunTestsViaDelombok.java24
-rw-r--r--test/core/src/lombok/RunTestsViaEcj.java6
-rw-r--r--test/transform/resource/after-delombok/Constructors.java10
-rw-r--r--test/transform/resource/after-delombok/GetterOnMethod.java24
-rw-r--r--test/transform/resource/after-delombok/GetterOnMethodErrors.java9
-rw-r--r--test/transform/resource/after-delombok/GetterOnMethodErrors2.java48
-rw-r--r--test/transform/resource/after-delombok/SetterOnMethodOnParam.java24
-rw-r--r--test/transform/resource/after-ecj/Constructors.java8
-rw-r--r--test/transform/resource/after-ecj/GetterOnMethod.java19
-rw-r--r--test/transform/resource/after-ecj/GetterOnMethodErrors.java14
-rw-r--r--test/transform/resource/after-ecj/GetterOnMethodErrors2.java39
-rw-r--r--test/transform/resource/after-ecj/SetterOnMethod.java40
-rw-r--r--test/transform/resource/after-ecj/SetterOnMethodOnParam.java19
-rw-r--r--test/transform/resource/after-ecj/SetterOnParam.java40
-rw-r--r--test/transform/resource/after-ecj/SetterOnParamAndOnMethod.java9
-rw-r--r--test/transform/resource/before/Constructors.java4
-rw-r--r--test/transform/resource/before/GetterOnMethod.java7
-rw-r--r--test/transform/resource/before/GetterOnMethodErrors.java6
-rw-r--r--test/transform/resource/before/GetterOnMethodErrors2.java12
-rw-r--r--test/transform/resource/before/SetterOnMethodOnParam.java7
-rw-r--r--test/transform/resource/messages-delombok/GetterOnMethod.java.messages7
-rw-r--r--test/transform/resource/messages-delombok/GetterOnMethodErrors.java.messages1
-rw-r--r--test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages4
-rw-r--r--test/transform/resource/messages-delombok/ValInBasicFor.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/GetterOnMethod.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/GetterOnMethodErrors.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages4
-rw-r--r--test/transform/resource/messages-idempotent/ValInBasicFor.java.messages2
-rw-r--r--test/transform/src/lombok/transform/TestLombokFilesIdempotent.java2
-rw-r--r--test/transform/src/lombok/transform/TestSourceFiles.java6
-rw-r--r--test/transform/src/lombok/transform/TestWithDelombok.java2
-rw-r--r--test/transform/src/lombok/transform/TestWithEcj.java2
36 files changed, 421 insertions, 103 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java
index 229d321a..a3f52cdd 100644
--- a/test/core/src/lombok/AbstractRunTests.java
+++ b/test/core/src/lombok/AbstractRunTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010 The Project Lombok Authors.
+ * Copyright (C) 2009-2013 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -40,6 +40,8 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
+
public abstract class AbstractRunTests {
protected static final String LINE_SEPARATOR = System.getProperty("line.separator");
private final File dumpActualFilesHere;
@@ -130,7 +132,7 @@ public abstract class AbstractRunTests {
FileOutputStream fos = new FileOutputStream(file);
try {
for (CompilerMessage message : content) {
- fos.write(message.asCompilerMessageMatcher().toString().getBytes("UTF-8"));
+ fos.write(CompilerMessageMatcher.asCompilerMessageMatcher(message).toString().getBytes("UTF-8"));
fos.write('\n');
}
} finally {
@@ -151,7 +153,9 @@ public abstract class AbstractRunTests {
System.out.println(actualFile);
if (actualMessages != null && !actualMessages.isEmpty()) {
System.out.println("**** Actual Errors *****");
- System.out.println(actualMessages);
+ for (CompilerMessage actualMessage : actualMessages) {
+ System.out.println(actualMessage);
+ }
}
System.out.println("*******************");
}
@@ -168,9 +172,13 @@ public abstract class AbstractRunTests {
System.out.println("***** " + name + " *****");
System.out.println(e.getMessage());
System.out.println("**** Expected ******");
- System.out.println(expectedMessages);
+ for (CompilerMessageMatcher expectedMessage : expectedMessages) {
+ System.out.println(expectedMessage);
+ }
System.out.println("**** Actual ******");
- System.out.println(actualMessages);
+ for (CompilerMessage actualMessage : actualMessages) {
+ System.out.println(actualMessage);
+ }
System.out.println("*******************");
}
if (dumpActualFilesHere != null) {
diff --git a/test/core/src/lombok/CompilerMessage.java b/test/core/src/lombok/CompilerMessage.java
deleted file mode 100644
index d04d17f1..00000000
--- a/test/core/src/lombok/CompilerMessage.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package lombok;
-
-public final class CompilerMessage {
- /** Line Number (starting at 1) */
- final long line;
-
- /** Position is either column number, OR position in file starting from the first byte. */
- final long position;
- final boolean isError;
- final String message;
-
- public CompilerMessage(long line, long position, boolean isError, String message) {
- this.line = line;
- this.position = position;
- this.isError = isError;
- this.message = message;
- }
-
- @Override public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (isError ? 1231 : 1237);
- result = prime * result + (int) (line ^ (line >>> 32));
- result = prime * result + ((message == null) ? 0 : message.hashCode());
- result = prime * result + (int) (position ^ (position >>> 32));
- return result;
- }
-
- @Override public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
- CompilerMessage other = (CompilerMessage) obj;
- if (isError != other.isError) return false;
- if (line != other.line) return false;
- if (message == null) {
- if (other.message != null) return false;
- } else if (!message.equals(other.message)) return false;
- if (position != other.position) return false;
- return true;
- }
-
- public CompilerMessageMatcher asCompilerMessageMatcher() {
- return new CompilerMessageMatcher(line, position, message);
- }
-
- @Override public String toString() {
- return String.format("%d:%d %s %s", line, position, isError ? "ERROR" : "WARNING", message);
- }
-}
diff --git a/test/core/src/lombok/CompilerMessageMatcher.java b/test/core/src/lombok/CompilerMessageMatcher.java
index b7902395..af12e199 100644
--- a/test/core/src/lombok/CompilerMessageMatcher.java
+++ b/test/core/src/lombok/CompilerMessageMatcher.java
@@ -1,3 +1,24 @@
+/*
+ * Copyright (C) 2012-2013 The Project Lombok Authors.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
package lombok;
import java.io.BufferedReader;
@@ -11,6 +32,8 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
+
public class CompilerMessageMatcher {
/** Line Number (starting at 1) */
private final long line;
@@ -25,6 +48,10 @@ public class CompilerMessageMatcher {
this.messageParts = Arrays.asList(message.split("\\s+"));
}
+ public static CompilerMessageMatcher asCompilerMessageMatcher(CompilerMessage message) {
+ return new CompilerMessageMatcher(message.getLine(), message.getColumnOrPosition(), message.getMessage());
+ }
+
@Override public String toString() {
StringBuilder parts = new StringBuilder();
for (String part : messageParts) parts.append(part).append(" ");
@@ -33,10 +60,10 @@ public class CompilerMessageMatcher {
}
public boolean matches(CompilerMessage message) {
- if (message.line != this.line) return false;
- if (message.position != this.position) return false;
+ if (message.getLine() != this.line) return false;
+ if (message.getColumnOrPosition() != this.position) return false;
for (String token : messageParts) {
- if (!message.message.contains(token)) return false;
+ if (!message.getMessage().contains(token)) return false;
}
return true;
}
diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java
index c896d327..191a7b63 100644
--- a/test/core/src/lombok/DirectoryRunner.java
+++ b/test/core/src/lombok/DirectoryRunner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010 The Project Lombok Authors.
+ * Copyright (C) 2009-2013 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -40,12 +40,16 @@ public class DirectoryRunner extends Runner {
DELOMBOK, JAVAC, ECJ;
}
- public interface TestParams {
- Compiler getCompiler();
- boolean printErrors();
- File getBeforeDirectory();
- File getAfterDirectory();
- File getMessagesDirectory();
+ public static abstract class TestParams {
+ public abstract Compiler getCompiler();
+ public abstract boolean printErrors();
+ public abstract File getBeforeDirectory();
+ public abstract File getAfterDirectory();
+ public abstract File getMessagesDirectory();
+
+ public boolean accept(File file) {
+ return true;
+ }
}
private static final FileFilter JAVA_FILE_FILTER = new FileFilter() {
@@ -76,6 +80,7 @@ public class DirectoryRunner extends Runner {
private void addTests(Class<?> testClass) throws Exception {
for (File file : params.getBeforeDirectory().listFiles(JAVA_FILE_FILTER)) {
+ if (!params.accept(file)) continue;
Description testDescription = Description.createTestDescription(testClass, file.getName());
description.addChild(testDescription);
tests.put(file.getName(), testDescription);
diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java
index 16eae8d3..17665173 100644
--- a/test/core/src/lombok/RunTestsViaDelombok.java
+++ b/test/core/src/lombok/RunTestsViaDelombok.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010 The Project Lombok Authors.
+ * Copyright (C) 2009-2013 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,35 +25,21 @@ import java.io.File;
import java.io.StringWriter;
import java.util.Collection;
import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.tools.Diagnostic;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaFileObject;
import lombok.delombok.Delombok;
+import lombok.javac.CapturingDiagnosticListener;
+import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
public class RunTestsViaDelombok extends AbstractRunTests {
private Delombok delombok = new Delombok();
@Override
- public void transformCode(final Collection<CompilerMessage> messages, StringWriter result, final File file) throws Throwable {
+ public void transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file) throws Throwable {
delombok.setVerbose(false);
delombok.setForceProcess(true);
delombok.setCharset("UTF-8");
- delombok.setDiagnosticsListener(new DiagnosticListener<JavaFileObject>() {
- @Override public void report(Diagnostic<? extends JavaFileObject> d) {
- String msg = d.getMessage(Locale.ENGLISH);
- Matcher m = Pattern.compile(
- "^" + Pattern.quote(file.getAbsolutePath()) +
- "\\s*:\\s*\\d+\\s*:\\s*(?:warning:\\s*)?(.*)$", Pattern.DOTALL).matcher(msg);
- if (m.matches()) msg = m.group(1);
- messages.add(new CompilerMessage(d.getLineNumber(), d.getColumnNumber(), d.getKind() == Kind.ERROR, msg));
- }
- });
+ delombok.setDiagnosticsListener(new CapturingDiagnosticListener(file, messages));
delombok.addFile(file.getAbsoluteFile().getParentFile(), file.getName());
delombok.setSourcepath(file.getAbsoluteFile().getParent());
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java
index b081d54a..0bf97213 100644
--- a/test/core/src/lombok/RunTestsViaEcj.java
+++ b/test/core/src/lombok/RunTestsViaEcj.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2012 The Project Lombok Authors.
+ * Copyright (C) 2010-2013 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -33,6 +33,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
+import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
+
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
@@ -110,7 +112,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
CategorizedProblem[] problems = compilationResult.getAllProblems();
if (problems != null) for (CategorizedProblem p : problems) {
- messages.add(new CompilerMessage(p.getSourceLineNumber(), p.getSourceStart(), p.isError(), p.getMessage()));
+ messages.add(new CompilerMessage(p.getSourceLineNumber(), p.getSourceStart(), p.getSourceStart(), p.isError(), p.getMessage()));
}
CompilationUnitDeclaration cud = compilationUnit_.get();
diff --git a/test/transform/resource/after-delombok/Constructors.java b/test/transform/resource/after-delombok/Constructors.java
index d4633dbc..12aa75ab 100644
--- a/test/transform/resource/after-delombok/Constructors.java
+++ b/test/transform/resource/after-delombok/Constructors.java
@@ -28,6 +28,16 @@ class RequiredArgsConstructorStaticName {
return new RequiredArgsConstructorStaticName(x);
}
}
+class RequiredArgsConstructorWithAnnotations {
+ final int x;
+ String name;
+ @java.beans.ConstructorProperties({"x"})
+ @Deprecated
+ @java.lang.SuppressWarnings("all")
+ public RequiredArgsConstructorWithAnnotations(final int x) {
+ this.x = x;
+ }
+}
class AllArgsConstructor1 {
final int x;
String name;
diff --git a/test/transform/resource/after-delombok/GetterOnMethod.java b/test/transform/resource/after-delombok/GetterOnMethod.java
new file mode 100644
index 00000000..4a5b3622
--- /dev/null
+++ b/test/transform/resource/after-delombok/GetterOnMethod.java
@@ -0,0 +1,24 @@
+class GetterOnMethod {
+ int i;
+ int j;
+ int k;
+ public @interface Test {
+ }
+ @Deprecated
+ @java.lang.SuppressWarnings("all")
+ public int getI() {
+ return this.i;
+ }
+ @java.lang.Deprecated
+ @Test
+ @java.lang.SuppressWarnings("all")
+ public int getJ() {
+ return this.j;
+ }
+ @java.lang.Deprecated
+ @Test
+ @java.lang.SuppressWarnings("all")
+ public int getK() {
+ return this.k;
+ }
+}
diff --git a/test/transform/resource/after-delombok/GetterOnMethodErrors.java b/test/transform/resource/after-delombok/GetterOnMethodErrors.java
new file mode 100644
index 00000000..86813bd2
--- /dev/null
+++ b/test/transform/resource/after-delombok/GetterOnMethodErrors.java
@@ -0,0 +1,9 @@
+class PlaceFillerToMakeSurePositionIsRelevant {
+}
+class GetterOnMethodErrors {
+ private int test;
+ @java.lang.SuppressWarnings("all")
+ public int getTest() {
+ return this.test;
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/GetterOnMethodErrors2.java b/test/transform/resource/after-delombok/GetterOnMethodErrors2.java
new file mode 100644
index 00000000..639022d0
--- /dev/null
+++ b/test/transform/resource/after-delombok/GetterOnMethodErrors2.java
@@ -0,0 +1,48 @@
+class GetterOnMethodErrors2 {
+ private int bad1;
+ private int bad2;
+ private int bad3;
+ private int bad4;
+ private int good1;
+ private int good2;
+ private int good3;
+ private int good4;
+ public @interface Test {
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getBad1() {
+ return this.bad1;
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getBad2() {
+ return this.bad2;
+ }
+ @Deprecated
+ @java.lang.SuppressWarnings("all")
+ public int getBad3() {
+ return this.bad3;
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getBad4() {
+ return this.bad4;
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getGood1() {
+ return this.good1;
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getGood2() {
+ return this.good2;
+ }
+ @Deprecated
+ @java.lang.SuppressWarnings("all")
+ public int getGood3() {
+ return this.good3;
+ }
+ @Deprecated
+ @Test
+ @java.lang.SuppressWarnings("all")
+ public int getGood4() {
+ return this.good4;
+ }
+}
diff --git a/test/transform/resource/after-delombok/SetterOnMethodOnParam.java b/test/transform/resource/after-delombok/SetterOnMethodOnParam.java
new file mode 100644
index 00000000..555bf698
--- /dev/null
+++ b/test/transform/resource/after-delombok/SetterOnMethodOnParam.java
@@ -0,0 +1,24 @@
+class SetterOnMethodOnParam {
+ int i;
+ int j;
+ int k;
+ public @interface Test {
+ }
+ @Deprecated
+ @java.lang.SuppressWarnings("all")
+ public void setI(final int i) {
+ this.i = i;
+ }
+ @java.lang.Deprecated
+ @Test
+ @java.lang.SuppressWarnings("all")
+ public void setJ(@Test final int j) {
+ this.j = j;
+ }
+ @java.lang.Deprecated
+ @Test
+ @java.lang.SuppressWarnings("all")
+ public void setK(@Test final int k) {
+ this.k = k;
+ }
+}
diff --git a/test/transform/resource/after-ecj/Constructors.java b/test/transform/resource/after-ecj/Constructors.java
index e994702f..540c2407 100644
--- a/test/transform/resource/after-ecj/Constructors.java
+++ b/test/transform/resource/after-ecj/Constructors.java
@@ -25,6 +25,14 @@
return new RequiredArgsConstructorStaticName(x);
}
}
+@lombok.RequiredArgsConstructor() class RequiredArgsConstructorWithAnnotations {
+ final int x;
+ String name;
+ public @Deprecated @java.beans.ConstructorProperties({"x"}) @java.lang.SuppressWarnings("all") RequiredArgsConstructorWithAnnotations(final int x) {
+ super();
+ this.x = x;
+ }
+}
@lombok.AllArgsConstructor class AllArgsConstructor1 {
final int x;
String name;
diff --git a/test/transform/resource/after-ecj/GetterOnMethod.java b/test/transform/resource/after-ecj/GetterOnMethod.java
new file mode 100644
index 00000000..a21f628c
--- /dev/null
+++ b/test/transform/resource/after-ecj/GetterOnMethod.java
@@ -0,0 +1,19 @@
+class GetterOnMethod {
+ public @interface Test {
+ }
+ @lombok.Getter() int i;
+ @lombok.Getter() int j;
+ @lombok.Getter() int k;
+ GetterOnMethod() {
+ super();
+ }
+ public @Deprecated @java.lang.SuppressWarnings("all") int getI() {
+ return this.i;
+ }
+ public @java.lang.Deprecated @Test @java.lang.SuppressWarnings("all") int getJ() {
+ return this.j;
+ }
+ public @java.lang.Deprecated @Test @java.lang.SuppressWarnings("all") int getK() {
+ return this.k;
+ }
+}
diff --git a/test/transform/resource/after-ecj/GetterOnMethodErrors.java b/test/transform/resource/after-ecj/GetterOnMethodErrors.java
new file mode 100644
index 00000000..16c625b5
--- /dev/null
+++ b/test/transform/resource/after-ecj/GetterOnMethodErrors.java
@@ -0,0 +1,14 @@
+class PlaceFillerToMakeSurePositionIsRelevant {
+ PlaceFillerToMakeSurePositionIsRelevant() {
+ super();
+ }
+}
+@lombok.Getter() class GetterOnMethodErrors {
+ private int test;
+ GetterOnMethodErrors() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") int getTest() {
+ return this.test;
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/GetterOnMethodErrors2.java b/test/transform/resource/after-ecj/GetterOnMethodErrors2.java
new file mode 100644
index 00000000..bfaa5dd4
--- /dev/null
+++ b/test/transform/resource/after-ecj/GetterOnMethodErrors2.java
@@ -0,0 +1,39 @@
+class GetterOnMethodErrors2 {
+ public @interface Test {
+ }
+ private @lombok.Getter() int bad1;
+ private @lombok.Getter() int bad2;
+ private @lombok.Getter() int bad3;
+ private @lombok.Getter() int bad4;
+ private @lombok.Getter() int good1;
+ private @lombok.Getter() int good2;
+ private @lombok.Getter() int good3;
+ private @lombok.Getter() int good4;
+ GetterOnMethodErrors2() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") int getBad1() {
+ return this.bad1;
+ }
+ public @java.lang.SuppressWarnings("all") int getBad2() {
+ return this.bad2;
+ }
+ public @java.lang.SuppressWarnings("all") int getBad3() {
+ return this.bad3;
+ }
+ public @java.lang.SuppressWarnings("all") int getBad4() {
+ return this.bad4;
+ }
+ public @java.lang.SuppressWarnings("all") int getGood1() {
+ return this.good1;
+ }
+ public @java.lang.SuppressWarnings("all") int getGood2() {
+ return this.good2;
+ }
+ public @Deprecated @java.lang.SuppressWarnings("all") int getGood3() {
+ return this.good3;
+ }
+ public @Deprecated @Test @java.lang.SuppressWarnings("all") int getGood4() {
+ return this.good4;
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SetterOnMethod.java b/test/transform/resource/after-ecj/SetterOnMethod.java
new file mode 100644
index 00000000..8bdff212
--- /dev/null
+++ b/test/transform/resource/after-ecj/SetterOnMethod.java
@@ -0,0 +1,40 @@
+import lombok.Setter;
+class SetterOnMethod {
+ @lombok.Setter() int i;
+ @lombok.Setter() int j;
+ public @Deprecated @java.lang.SuppressWarnings("all") void setI(final int i) {
+ this.i = i;
+ }
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") void setJ(final int j) {
+ this.j = j;
+ }
+ SetterOnMethod() {
+ super();
+ }
+}
+@lombok.Setter() class SetterOnClassOnMethod {
+ int i;
+ int j;
+ public @java.lang.SuppressWarnings("all") void setI(final int i) {
+ this.i = i;
+ }
+ public @java.lang.SuppressWarnings("all") void setJ(final int j) {
+ this.j = j;
+ }
+ SetterOnClassOnMethod() {
+ super();
+ }
+}
+@lombok.Setter() class SetterOnClassAndOnAField {
+ int i;
+ @lombok.Setter() int j;
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") void setJ(final int j) {
+ this.j = j;
+ }
+ public @java.lang.SuppressWarnings("all") void setI(final int i) {
+ this.i = i;
+ }
+ SetterOnClassAndOnAField() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SetterOnMethodOnParam.java b/test/transform/resource/after-ecj/SetterOnMethodOnParam.java
new file mode 100644
index 00000000..d4ea9f5d
--- /dev/null
+++ b/test/transform/resource/after-ecj/SetterOnMethodOnParam.java
@@ -0,0 +1,19 @@
+class SetterOnMethodOnParam {
+ public @interface Test {
+ }
+ @lombok.Setter() int i;
+ @lombok.Setter() int j;
+ @lombok.Setter() int k;
+ SetterOnMethodOnParam() {
+ super();
+ }
+ public @Deprecated @java.lang.SuppressWarnings("all") void setI(final int i) {
+ this.i = i;
+ }
+ public @java.lang.Deprecated @Test @java.lang.SuppressWarnings("all") void setJ(final @Test int j) {
+ this.j = j;
+ }
+ public @java.lang.Deprecated @Test @java.lang.SuppressWarnings("all") void setK(final @Test int k) {
+ this.k = k;
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SetterOnParam.java b/test/transform/resource/after-ecj/SetterOnParam.java
new file mode 100644
index 00000000..119c8fc3
--- /dev/null
+++ b/test/transform/resource/after-ecj/SetterOnParam.java
@@ -0,0 +1,40 @@
+import lombok.Setter;
+class SetterOnParam {
+ @lombok.Setter() int i;
+ @lombok.Setter() int j;
+ public @java.lang.SuppressWarnings("all") void setI(final @SuppressWarnings("all") int i) {
+ this.i = i;
+ }
+ public @java.lang.SuppressWarnings("all") void setJ(final @java.lang.SuppressWarnings("all") int j) {
+ this.j = j;
+ }
+ SetterOnParam() {
+ super();
+ }
+}
+@lombok.Setter() class SetterOnClassOnParam {
+ int i;
+ int j;
+ public @java.lang.SuppressWarnings("all") void setI(final int i) {
+ this.i = i;
+ }
+ public @java.lang.SuppressWarnings("all") void setJ(final int j) {
+ this.j = j;
+ }
+ SetterOnClassOnParam() {
+ super();
+ }
+}
+@lombok.Setter() class SetterOnClassAndOnAFieldParam {
+ int i;
+ @lombok.Setter() int j;
+ public @java.lang.SuppressWarnings("all") void setJ(final @java.lang.SuppressWarnings("all") int j) {
+ this.j = j;
+ }
+ public @java.lang.SuppressWarnings("all") void setI(final int i) {
+ this.i = i;
+ }
+ SetterOnClassAndOnAFieldParam() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SetterOnParamAndOnMethod.java b/test/transform/resource/after-ecj/SetterOnParamAndOnMethod.java
new file mode 100644
index 00000000..21d22a8f
--- /dev/null
+++ b/test/transform/resource/after-ecj/SetterOnParamAndOnMethod.java
@@ -0,0 +1,9 @@
+class SetterOnParamAndOnMethod {
+ @lombok.Setter() int i;
+ public @Deprecated @java.lang.SuppressWarnings("all") void setI(final @SuppressWarnings("all") int i) {
+ this.i = i;
+ }
+ SetterOnParamAndOnMethod() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/Constructors.java b/test/transform/resource/before/Constructors.java
index d3ed3504..0ab7b7f0 100644
--- a/test/transform/resource/before/Constructors.java
+++ b/test/transform/resource/before/Constructors.java
@@ -10,6 +10,10 @@
final int x;
String name;
}
+@lombok.RequiredArgsConstructor(onConstructor=@_(@Deprecated)) class RequiredArgsConstructorWithAnnotations {
+ final int x;
+ String name;
+}
@lombok.AllArgsConstructor class AllArgsConstructor1 {
final int x;
String name;
diff --git a/test/transform/resource/before/GetterOnMethod.java b/test/transform/resource/before/GetterOnMethod.java
new file mode 100644
index 00000000..558f3f64
--- /dev/null
+++ b/test/transform/resource/before/GetterOnMethod.java
@@ -0,0 +1,7 @@
+class GetterOnMethod {
+ @lombok.Getter(onMethod=@_(@Deprecated)) int i;
+ @lombok.Getter(onMethod=@_({@java.lang.Deprecated, @Test})) int j, k;
+
+ public @interface Test {
+ }
+}
diff --git a/test/transform/resource/before/GetterOnMethodErrors.java b/test/transform/resource/before/GetterOnMethodErrors.java
new file mode 100644
index 00000000..ae5d5b54
--- /dev/null
+++ b/test/transform/resource/before/GetterOnMethodErrors.java
@@ -0,0 +1,6 @@
+class PlaceFillerToMakeSurePositionIsRelevant {
+}
+@lombok.Getter(onMethod=@_(@Deprecated))
+class GetterOnMethodErrors {
+ private int test;
+}
diff --git a/test/transform/resource/before/GetterOnMethodErrors2.java b/test/transform/resource/before/GetterOnMethodErrors2.java
new file mode 100644
index 00000000..423183b9
--- /dev/null
+++ b/test/transform/resource/before/GetterOnMethodErrors2.java
@@ -0,0 +1,12 @@
+class GetterOnMethodErrors2 {
+ @lombok.Getter(onMethod=@_A_(@Deprecated)) private int bad1;
+ @lombok.Getter(onMethod=@_(5)) private int bad2;
+ @lombok.Getter(onMethod=@_({@Deprecated, 5})) private int bad3;
+ @lombok.Getter(onMethod=@_(bar=@Deprecated)) private int bad4;
+ @lombok.Getter(onMethod=@_) private int good1;
+ @lombok.Getter(onMethod=@_()) private int good2;
+ @lombok.Getter(onMethod=@_(value=@Deprecated)) private int good3;
+ @lombok.Getter(onMethod=@_(value={@Deprecated, @Test})) private int good4;
+ public @interface Test {
+ }
+}
diff --git a/test/transform/resource/before/SetterOnMethodOnParam.java b/test/transform/resource/before/SetterOnMethodOnParam.java
new file mode 100644
index 00000000..70f3dc8c
--- /dev/null
+++ b/test/transform/resource/before/SetterOnMethodOnParam.java
@@ -0,0 +1,7 @@
+class SetterOnMethodOnParam {
+ @lombok.Setter(onMethod=@_(@Deprecated)) int i;
+ @lombok.Setter(onMethod=@_({@java.lang.Deprecated, @Test}), onParam=@_(@Test)) int j, k;
+
+ public @interface Test {
+ }
+}
diff --git a/test/transform/resource/messages-delombok/GetterOnMethod.java.messages b/test/transform/resource/messages-delombok/GetterOnMethod.java.messages
deleted file mode 100644
index db5ef9a6..00000000
--- a/test/transform/resource/messages-delombok/GetterOnMethod.java.messages
+++ /dev/null
@@ -1,7 +0,0 @@
-3:34 incompatible types
-4:44 incompatible types
-6:26 incompatible types
-11:26 incompatible types
-14:44 incompatible types
-6:1 'onMethod' is not supported for @Getter on a type.
-11:1 'onMethod' is not supported for @Getter on a type.
diff --git a/test/transform/resource/messages-delombok/GetterOnMethodErrors.java.messages b/test/transform/resource/messages-delombok/GetterOnMethodErrors.java.messages
new file mode 100644
index 00000000..4c82f730
--- /dev/null
+++ b/test/transform/resource/messages-delombok/GetterOnMethodErrors.java.messages
@@ -0,0 +1 @@
+3:1 'onMethod' is not supported for @Getter on a type. \ No newline at end of file
diff --git a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages
new file mode 100644
index 00000000..ead040a5
--- /dev/null
+++ b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages
@@ -0,0 +1,4 @@
+2:9 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation}))
+3:9 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation}))
+4:9 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation}))
+5:9 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation}))
diff --git a/test/transform/resource/messages-delombok/ValInBasicFor.java.messages b/test/transform/resource/messages-delombok/ValInBasicFor.java.messages
index b69a4a13..9bca1be6 100644
--- a/test/transform/resource/messages-delombok/ValInBasicFor.java.messages
+++ b/test/transform/resource/messages-delombok/ValInBasicFor.java.messages
@@ -1,3 +1 @@
-6:26 'val' is not allowed in old-style for loops
-6:40 'val' is not allowed in old-style for loops
6:53 'val' is not allowed in old-style for loops
diff --git a/test/transform/resource/messages-ecj/GetterOnMethod.java.messages b/test/transform/resource/messages-ecj/GetterOnMethod.java.messages
deleted file mode 100644
index 4b240da0..00000000
--- a/test/transform/resource/messages-ecj/GetterOnMethod.java.messages
+++ /dev/null
@@ -1,2 +0,0 @@
-6:0 'onMethod' is not supported for @Getter on a type.
-11:0 'onMethod' is not supported for @Getter on a type. \ No newline at end of file
diff --git a/test/transform/resource/messages-ecj/GetterOnMethodErrors.java.messages b/test/transform/resource/messages-ecj/GetterOnMethodErrors.java.messages
new file mode 100644
index 00000000..804e8a3c
--- /dev/null
+++ b/test/transform/resource/messages-ecj/GetterOnMethodErrors.java.messages
@@ -0,0 +1 @@
+3:50 'onMethod' is not supported for @Getter on a type. \ No newline at end of file
diff --git a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages
new file mode 100644
index 00000000..6b949f41
--- /dev/null
+++ b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages
@@ -0,0 +1,4 @@
+2:31 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation}))
+3:93 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation}))
+4:143 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation}))
+5:208 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation}))
diff --git a/test/transform/resource/messages-idempotent/ValInBasicFor.java.messages b/test/transform/resource/messages-idempotent/ValInBasicFor.java.messages
index 313a33c0..fb675485 100644
--- a/test/transform/resource/messages-idempotent/ValInBasicFor.java.messages
+++ b/test/transform/resource/messages-idempotent/ValInBasicFor.java.messages
@@ -1,3 +1 @@
-5:26 'val' is not allowed in old-style for loops
-5:40 'val' is not allowed in old-style for loops
5:53 'val' is not allowed in old-style for loops
diff --git a/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java b/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java
index b47fdefd..d2909943 100644
--- a/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java
+++ b/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java
@@ -28,7 +28,7 @@ import lombok.DirectoryRunner;
import org.junit.runner.RunWith;
@RunWith(DirectoryRunner.class)
-public class TestLombokFilesIdempotent implements DirectoryRunner.TestParams {
+public class TestLombokFilesIdempotent extends DirectoryRunner.TestParams {
@Override
public File getBeforeDirectory() {
return getAfterDirectory();
diff --git a/test/transform/src/lombok/transform/TestSourceFiles.java b/test/transform/src/lombok/transform/TestSourceFiles.java
index 3b405676..c3ac0a68 100644
--- a/test/transform/src/lombok/transform/TestSourceFiles.java
+++ b/test/transform/src/lombok/transform/TestSourceFiles.java
@@ -28,19 +28,23 @@ import lombok.DirectoryRunner;
import org.junit.runner.RunWith;
@RunWith(DirectoryRunner.class)
-public class TestSourceFiles implements DirectoryRunner.TestParams {
+public class TestSourceFiles extends DirectoryRunner.TestParams {
+ @Override
public DirectoryRunner.Compiler getCompiler() {
return DirectoryRunner.Compiler.DELOMBOK;
}
+ @Override
public boolean printErrors() {
return true;
}
+ @Override
public File getBeforeDirectory() {
return new File("test/pretty/resource/before");
}
+ @Override
public File getAfterDirectory() {
return new File("test/pretty/resource/after");
}
diff --git a/test/transform/src/lombok/transform/TestWithDelombok.java b/test/transform/src/lombok/transform/TestWithDelombok.java
index 44ea6ab5..bd8d9d09 100644
--- a/test/transform/src/lombok/transform/TestWithDelombok.java
+++ b/test/transform/src/lombok/transform/TestWithDelombok.java
@@ -28,7 +28,7 @@ import lombok.DirectoryRunner;
import org.junit.runner.RunWith;
@RunWith(DirectoryRunner.class)
-public class TestWithDelombok implements DirectoryRunner.TestParams {
+public class TestWithDelombok extends DirectoryRunner.TestParams {
@Override
public DirectoryRunner.Compiler getCompiler() {
return DirectoryRunner.Compiler.DELOMBOK;
diff --git a/test/transform/src/lombok/transform/TestWithEcj.java b/test/transform/src/lombok/transform/TestWithEcj.java
index 9463b531..0a4057dd 100644
--- a/test/transform/src/lombok/transform/TestWithEcj.java
+++ b/test/transform/src/lombok/transform/TestWithEcj.java
@@ -32,7 +32,7 @@ import org.junit.runner.RunWith;
// When running inside eclipse's junit tester, you don't actually need to run 'ant dist' after updating code, though.
@RunWith(DirectoryRunner.class)
-public class TestWithEcj implements DirectoryRunner.TestParams {
+public class TestWithEcj extends DirectoryRunner.TestParams {
@Override
public DirectoryRunner.Compiler getCompiler() {
return DirectoryRunner.Compiler.ECJ;