Added tests for ecj, fixed a few minor bugs that came out of that.

This commit is contained in:
Reinier Zwitserloot committed 2010-07-22 01:33:24 +02:00
1 parent 59e585a0c6
commit 483e23d385
50 files changed
+1180 -34

No files matched your search

@@ -527,6 +527,7 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
/* MyType<?> other = (MyType<?>) o; */ {
if (!fields.isEmpty()) {
LocalDeclaration other = new LocalDeclaration(otherN, pS, pE);
other.modifiers |= ClassFileConstants.AccFinal;
Eclipse.setGeneratedBy(other, source);
char[] typeName = typeDecl.name;
Expression targetType;
@@ -412,7 +412,7 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler<EqualsAnd
} else /* objects */ {
/* if (this.fieldName == null ? other.fieldName != null : !this.fieldName.equals(other.fieldName)) return false; */
JCExpression thisEqualsNull = maker.Binary(JCTree.EQ, thisFieldAccessor, maker.Literal(TypeTags.BOT, null));
JCExpression otherNotEqualsNull = maker.Binary(JCTree.NE, thisFieldAccessor, maker.Literal(TypeTags.BOT, null));
JCExpression otherNotEqualsNull = maker.Binary(JCTree.NE, otherFieldAccessor, maker.Literal(TypeTags.BOT, null));
JCExpression thisEqualsThat = maker.Apply(List.<JCExpression>nil(),
maker.Select(createFieldAccessor(maker, fieldNode, useFieldsDirectly), typeNode.toName("equals")),
List.of(createFieldAccessor(maker, fieldNode, useFieldsDirectly, maker.Ident(otherName))));
@@ -102,7 +102,7 @@ public class HandleSneakyThrows implements JavacAnnotationHandler<SneakyThrows>
JCExpression varType = chainDots(maker, node, exception.split("\\."));
JCVariableDecl catchParam = maker.VarDef(maker.Modifiers(0), node.toName("$ex"), varType, null);
JCVariableDecl catchParam = maker.VarDef(maker.Modifiers(Flags.FINAL), node.toName("$ex"), varType, null);
JCExpression lombokLombokSneakyThrowNameRef = chainDots(maker, node, "lombok", "Lombok", "sneakyThrow");
JCBlock catchBody = maker.Block(0, List.<JCStatement>of(maker.Throw(maker.Apply(
List.<JCExpression>nil(), lombokLombokSneakyThrowNameRef,
@@ -83,6 +83,10 @@ public abstract class AbstractRunTests {
System.out.println(expectedFile);
System.out.println("**** Actual ******");
System.out.println(actualFile);
if (actualMessages != null && !actualMessages.isEmpty()) {
System.out.println("**** Actual Errors *****");
System.out.println(actualMessages);
}
System.out.println("*******************");
}
throw e;
@@ -24,6 +24,8 @@ package lombok;
import java.io.File;
import java.io.StringWriter;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
@@ -35,14 +37,17 @@ public class RunTestsViaDelombok extends AbstractRunTests {
private Delombok delombok = new Delombok();
@Override
public void transformCode(final StringBuilder messages, StringWriter result, File file) throws Throwable {
public void transformCode(final StringBuilder 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) {
messages.append(String.format("%d:%d %s %s\n", d.getLineNumber(), d.getColumnNumber(), d.getKind(), d.getMessage(Locale.ENGLISH)));
String msg = d.getMessage(Locale.ENGLISH);
Matcher m = Pattern.compile("^" + Pattern.quote(file.getAbsolutePath()) + "\\s*:\\s*\\d+\\s*:\\s*(?:warning:\\s*)?(.*)$").matcher(msg);
if (m.matches()) msg = m.group(1);
messages.append(String.format("%d:%d %s %s\n", d.getLineNumber(), d.getColumnNumber(), d.getKind(), msg));
}
});
+4 -2
View File
@@ -47,8 +47,10 @@ public class RunTestsViaEcj extends AbstractRunTests {
TransformEclipseAST.transform(parser, cud);
for (CategorizedProblem p : compilationResult.getErrors()) {
messages.append(p.toString()).append("\n");
CategorizedProblem[] problems = 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()));
}
result.append(cud.toString());
@@ -1,7 +1,7 @@
class GetterWithDollar1 {
int $i;
@java.lang.SuppressWarnings("all")
public int getI() {
public int get$i() {
return this.$i;
}
}
@@ -9,6 +9,10 @@ class GetterWithDollar2 {
int $i;
int i;
@java.lang.SuppressWarnings("all")
public int get$i() {
return this.$i;
}
@java.lang.SuppressWarnings("all")
public int getI() {
return this.i;
}
@@ -3,15 +3,15 @@ class NonNullPlain {
int i;
@lombok.NonNull
String s;
@java.lang.SuppressWarnings("all")
public void setI(@lombok.NonNull final int i) {
this.i = i;
}
@lombok.NonNull
@java.lang.SuppressWarnings("all")
public int getI() {
return this.i;
}
@java.lang.SuppressWarnings("all")
public void setI(@lombok.NonNull final int i) {
this.i = i;
}
@lombok.NonNull
@java.lang.SuppressWarnings("all")
public String getS() {
@@ -1,14 +1,20 @@
class SetterWithDollar1 {
int $i;
public void setI(final int i) {
this.$i = i;
@java.lang.SuppressWarnings("all")
public void set$i(final int $i) {
this.$i = $i;
}
}
class SetterWithDollar2 {
int $i;
int i;
@java.lang.SuppressWarnings("all")
public void set$i(final int $i) {
this.$i = $i;
}
@java.lang.SuppressWarnings("all")
public void setI(final int i) {
this.i = i;
}
@@ -7,10 +7,10 @@ class SneakyThrowsMultiple {
try {
System.out.println("test1");
throw new IOException();
} catch (IOException $ex) {
} catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
} catch (Throwable $ex) {
} catch (final Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
@@ -23,10 +23,10 @@ class SneakyThrowsMultiple {
} else {
throw new AWTException("WHAT");
}
} catch (AWTException $ex) {
} catch (final AWTException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
} catch (IOException $ex) {
} catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
@@ -35,10 +35,10 @@ class SneakyThrowsMultiple {
try {
System.out.println("test3");
throw new IOException();
} catch (IOException $ex) {
} catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
} catch (Throwable $ex) {
} catch (final Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
@@ -2,7 +2,7 @@ class SneakyThrowsPlain {
public void test() {
try {
System.out.println("test1");
} catch (java.lang.Throwable $ex) {
} catch (final java.lang.Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
@@ -10,7 +10,7 @@ class SneakyThrowsPlain {
public void test2() {
try {
System.out.println("test2");
} catch (java.lang.Throwable $ex) {
} catch (final java.lang.Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
@@ -3,7 +3,7 @@ class SneakyThrowsSingle {
public void test() {
try {
System.out.println("test1");
} catch (Throwable $ex) {
} catch (final Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
@@ -11,7 +11,7 @@ class SneakyThrowsSingle {
try {
System.out.println("test2");
throw new IOException();
} catch (IOException $ex) {
} catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
@@ -19,7 +19,7 @@ class SneakyThrowsSingle {
try {
System.out.println("test3");
throw new IOException();
} catch (IOException $ex) {
} catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
@@ -2,7 +2,7 @@ class SynchronizedName {
private Object read = new Object();
private static Object READ = new Object();
void test1() {
synchronized (read) {
synchronized (this.read) {
System.out.println("one");
}
}
@@ -10,15 +10,17 @@ class SynchronizedName {
System.out.println("two");
}
static void test3() {
System.out.println("three");
synchronized (SynchronizedName.read) {
System.out.println("three");
}
}
void test4() {
synchronized (READ) {
synchronized (this.READ) {
System.out.println("four");
}
}
void test5() {
synchronized (read) {
synchronized (this.read) {
System.out.println("five");
}
}
@@ -0,0 +1,9 @@
class GetFoo {
private @lombok.Getter int foo;
GetFoo() {
super();
}
public @java.lang.SuppressWarnings("all") int getFoo() {
return this.foo;
}
}
@@ -0,0 +1,27 @@
class CleanupName {
CleanupName() {
super();
}
void test() {
@lombok.Cleanup("toString") Object o = "Hello World!";
try
{
System.out.println(o);
}
finally
{
o.toString();
}
}
void test2() {
@lombok.Cleanup(value = "toString") Object o = "Hello World too!";
try
{
System.out.println(o);
}
finally
{
o.toString();
}
}
}
@@ -0,0 +1,29 @@
import lombok.Cleanup;
import java.io.*;
class CleanupPlain {
CleanupPlain() {
super();
}
void test() throws Exception {
@lombok.Cleanup InputStream in = new FileInputStream("in");
try
{
@Cleanup OutputStream out = new FileOutputStream("out");
try
{
if (in.markSupported())
{
out.flush();
}
}
finally
{
out.close();
}
}
finally
{
in.close();
}
}
}
@@ -0,0 +1,12 @@
import lombok.Getter;
public class CommentsInterspersed {
private int x;
private @Getter String test = "foo";
public CommentsInterspersed() {
super();
}
public native void gwtTest();
public @java.lang.SuppressWarnings("all") String getTest() {
return this.test;
}
}
@@ -0,0 +1,33 @@
@lombok.Data @lombok.ToString(doNotUseGetters = true) class DataExtended {
int x;
public @java.lang.SuppressWarnings("all") DataExtended() {
super();
}
public @java.lang.SuppressWarnings("all") int getX() {
return this.x;
}
public @java.lang.SuppressWarnings("all") void setX(final int x) {
this.x = x;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
if ((o == this))
return true;
if ((o == null))
return false;
if ((o.getClass() != this.getClass()))
return false;
final DataExtended other = (DataExtended) o;
if ((this.getX() != other.getX()))
return false;
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
final int PRIME = 31;
int result = 1;
result = ((result * PRIME) + this.getX());
return result;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (("DataExtended(x=" + this.x) + ")");
}
}
@@ -0,0 +1,32 @@
@lombok.Data class DataIgnore {
final int x;
String $name;
public @java.beans.ConstructorProperties({"x"}) @java.lang.SuppressWarnings("all") DataIgnore(final int x) {
super();
this.x = x;
}
public @java.lang.SuppressWarnings("all") int getX() {
return this.x;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
if ((o == this))
return true;
if ((o == null))
return false;
if ((o.getClass() != this.getClass()))
return false;
final DataIgnore other = (DataIgnore) o;
if ((this.getX() != other.getX()))
return false;
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
final int PRIME = 31;
int result = 1;
result = ((result * PRIME) + this.getX());
return result;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (("DataIgnore(x=" + this.getX()) + ")");
}
}
@@ -0,0 +1,83 @@
import lombok.Data;
@lombok.Data class Data1 {
final int x;
String name;
public @java.beans.ConstructorProperties({"x"}) @java.lang.SuppressWarnings("all") Data1(final int x) {
super();
this.x = x;
}
public @java.lang.SuppressWarnings("all") int getX() {
return this.x;
}
public @java.lang.SuppressWarnings("all") String getName() {
return this.name;
}
public @java.lang.SuppressWarnings("all") void setName(final String name) {
this.name = name;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
if ((o == this))
return true;
if ((o == null))
return false;
if ((o.getClass() != this.getClass()))
return false;
final Data1 other = (Data1) o;
if ((this.getX() != other.getX()))
return false;
if (((this.getName() == null) ? (other.getName() != null) : (! this.getName().equals(other.getName()))))
return false;
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
final int PRIME = 31;
int result = 1;
result = ((result * PRIME) + this.getX());
result = ((result * PRIME) + ((this.getName() == null) ? 0 : this.getName().hashCode()));
return result;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (((("Data1(x=" + this.getX()) + ", name=") + this.getName()) + ")");
}
}
@Data class Data2 {
final int x;
String name;
public @java.beans.ConstructorProperties({"x"}) @java.lang.SuppressWarnings("all") Data2(final int x) {
super();
this.x = x;
}
public @java.lang.SuppressWarnings("all") int getX() {
return this.x;
}
public @java.lang.SuppressWarnings("all") String getName() {
return this.name;
}
public @java.lang.SuppressWarnings("all") void setName(final String name) {
this.name = name;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
if ((o == this))
return true;
if ((o == null))
return false;
if ((o.getClass() != this.getClass()))
return false;
final Data2 other = (Data2) o;
if ((this.getX() != other.getX()))
return false;
if (((this.getName() == null) ? (other.getName() != null) : (! this.getName().equals(other.getName()))))
return false;
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
final int PRIME = 31;
int result = 1;
result = ((result * PRIME) + this.getX());
result = ((result * PRIME) + ((this.getName() == null) ? 0 : this.getName().hashCode()));
return result;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (((("Data2(x=" + this.getX()) + ", name=") + this.getName()) + ")");
}
}
@@ -0,0 +1,43 @@
class GetterAccessLevel {
@lombok.Getter(lombok.AccessLevel.NONE) boolean isNone;
@lombok.Getter(lombok.AccessLevel.PRIVATE) boolean isPrivate;
@lombok.Getter(lombok.AccessLevel.PACKAGE) boolean isPackage;
@lombok.Getter(lombok.AccessLevel.PROTECTED) boolean isProtected;
@lombok.Getter(lombok.AccessLevel.PUBLIC) boolean isPublic;
@lombok.Getter(lombok.AccessLevel.NONE) String noneString;
@lombok.Getter(lombok.AccessLevel.PRIVATE) String privateString;
@lombok.Getter(lombok.AccessLevel.PACKAGE) String packageString;
@lombok.Getter(lombok.AccessLevel.PROTECTED) String protectedString;
@lombok.Getter(lombok.AccessLevel.PUBLIC) String publicString;
@lombok.Getter(value = lombok.AccessLevel.PUBLIC) String value;
GetterAccessLevel() {
super();
}
private @java.lang.SuppressWarnings("all") boolean isPrivate() {
return this.isPrivate;
}
@java.lang.SuppressWarnings("all") boolean isPackage() {
return this.isPackage;
}
protected @java.lang.SuppressWarnings("all") boolean isProtected() {
return this.isProtected;
}
public @java.lang.SuppressWarnings("all") boolean isPublic() {
return this.isPublic;
}
private @java.lang.SuppressWarnings("all") String getPrivateString() {
return this.privateString;
}
@java.lang.SuppressWarnings("all") String getPackageString() {
return this.packageString;
}
protected @java.lang.SuppressWarnings("all") String getProtectedString() {
return this.protectedString;
}
public @java.lang.SuppressWarnings("all") String getPublicString() {
return this.publicString;
}
public @java.lang.SuppressWarnings("all") String getValue() {
return this.value;
}
}
@@ -0,0 +1,186 @@
class Getter1 {
@lombok.Getter boolean foo;
Getter1() {
super();
}
boolean hasFoo() {
return true;
}
}
class Getter2 {
@lombok.Getter boolean foo;
Getter2() {
super();
}
boolean isFoo() {
return true;
}
}
class Getter3 {
@lombok.Getter boolean foo;
Getter3() {
super();
}
boolean getFoo() {
return true;
}
}
class Getter4 {
@lombok.Getter String foo;
Getter4() {
super();
}
String hasFoo() {
return null;
}
public @java.lang.SuppressWarnings("all") String getFoo() {
return this.foo;
}
}
class Getter5 {
@lombok.Getter String foo;
Getter5() {
super();
}
String isFoo() {
return null;
}
public @java.lang.SuppressWarnings("all") String getFoo() {
return this.foo;
}
}
class Getter6 {
@lombok.Getter String foo;
Getter6() {
super();
}
String getFoo() {
return null;
}
}
class Getter7 {
@lombok.Getter String foo;
Getter7() {
super();
}
boolean hasFoo() {
return false;
}
public @java.lang.SuppressWarnings("all") String getFoo() {
return this.foo;
}
}
class Getter8 {
@lombok.Getter String foo;
Getter8() {
super();
}
boolean isFoo() {
return false;
}
public @java.lang.SuppressWarnings("all") String getFoo() {
return this.foo;
}
}
class Getter9 {
@lombok.Getter String foo;
Getter9() {
super();
}
boolean getFoo() {
return false;
}
}
class Getter10 {
@lombok.Getter boolean foo;
Getter10() {
super();
}
static boolean hasFoo() {
return false;
}
}
class Getter11 {
@lombok.Getter boolean foo;
Getter11() {
super();
}
static boolean isFoo() {
return false;
}
}
class Getter12 {
@lombok.Getter boolean foo;
Getter12() {
super();
}
static boolean getFoo() {
return false;
}
}
class Getter13 {
@lombok.Getter String foo;
Getter13() {
super();
}
static boolean hasFoo() {
return false;
}
public @java.lang.SuppressWarnings("all") String getFoo() {
return this.foo;
}
}
class Getter14 {
@lombok.Getter String foo;
Getter14() {
super();
}
static boolean isFoo() {
return false;
}
public @java.lang.SuppressWarnings("all") String getFoo() {
return this.foo;
}
}
class Getter15 {
@lombok.Getter String foo;
Getter15() {
super();
}
static boolean getFoo() {
return false;
}
}
class Getter16 {
@lombok.Getter String foo;
Getter16() {
super();
}
static String hasFoo() {
return false;
}
public @java.lang.SuppressWarnings("all") String getFoo() {
return this.foo;
}
}
class Getter17 {
@lombok.Getter String foo;
Getter17() {
super();
}
static String isFoo() {
return false;
}
public @java.lang.SuppressWarnings("all") String getFoo() {
return this.foo;
}
}
class Getter18 {
@lombok.Getter String foo;
Getter18() {
super();
}
static String getFoo() {
return false;
}
}
@@ -0,0 +1,26 @@
class Getter {
@lombok.Getter boolean foo;
@lombok.Getter boolean isBar;
@lombok.Getter boolean hasBaz;
Getter() {
super();
}
public @java.lang.SuppressWarnings("all") boolean isFoo() {
return this.foo;
}
public @java.lang.SuppressWarnings("all") boolean isBar() {
return this.isBar;
}
public @java.lang.SuppressWarnings("all") boolean hasBaz() {
return this.hasBaz;
}
}
class MoreGetter {
@lombok.Getter boolean foo;
MoreGetter() {
super();
}
boolean hasFoo() {
return true;
}
}
@@ -0,0 +1,67 @@
@lombok.Getter class GetterOnClass1 {
@lombok.Getter(lombok.AccessLevel.NONE) boolean isNone;
boolean isPublic;
GetterOnClass1() {
super();
}
public @java.lang.SuppressWarnings("all") boolean isPublic() {
return this.isPublic;
}
}
@lombok.Getter(lombok.AccessLevel.PROTECTED) class GetterOnClass2 {
@lombok.Getter(lombok.AccessLevel.NONE) boolean isNone;
boolean isProtected;
@lombok.Getter(lombok.AccessLevel.PACKAGE) boolean isPackage;
GetterOnClass2() {
super();
}
@java.lang.SuppressWarnings("all") boolean isPackage() {
return this.isPackage;
}
protected @java.lang.SuppressWarnings("all") boolean isProtected() {
return this.isProtected;
}
}
@lombok.Getter(lombok.AccessLevel.PACKAGE) class GetterOnClass3 {
@lombok.Getter(lombok.AccessLevel.NONE) boolean isNone;
boolean isPackage;
GetterOnClass3() {
super();
}
@java.lang.SuppressWarnings("all") boolean isPackage() {
return this.isPackage;
}
}
@lombok.Getter(lombok.AccessLevel.PRIVATE) class GetterOnClass4 {
@lombok.Getter(lombok.AccessLevel.NONE) boolean isNone;
boolean isPrivate;
GetterOnClass4() {
super();
}
private @java.lang.SuppressWarnings("all") boolean isPrivate() {
return this.isPrivate;
}
}
@lombok.Getter(lombok.AccessLevel.PUBLIC) class GetterOnClass5 {
@lombok.Getter(lombok.AccessLevel.NONE) boolean isNone;
boolean isPublic;
GetterOnClass5() {
super();
}
public @java.lang.SuppressWarnings("all") boolean isPublic() {
return this.isPublic;
}
}
@lombok.Getter class GetterOnClass6 {
String couldBeNull;
@lombok.NonNull String nonNull;
GetterOnClass6() {
super();
}
public @java.lang.SuppressWarnings("all") String getCouldBeNull() {
return this.couldBeNull;
}
public @lombok.NonNull @java.lang.SuppressWarnings("all") String getNonNull() {
return this.nonNull;
}
}
@@ -0,0 +1,14 @@
import lombok.Getter;
class GetterPlain {
@lombok.Getter int i;
@Getter int foo;
GetterPlain() {
super();
}
public @java.lang.SuppressWarnings("all") int getI() {
return this.i;
}
public @java.lang.SuppressWarnings("all") int getFoo() {
return this.foo;
}
}
@@ -0,0 +1,22 @@
class GetterWithDollar1 {
@lombok.Getter int $i;
GetterWithDollar1() {
super();
}
public @java.lang.SuppressWarnings("all") int get$i() {
return this.$i;
}
}
class GetterWithDollar2 {
@lombok.Getter int $i;
@lombok.Getter int i;
GetterWithDollar2() {
super();
}
public @java.lang.SuppressWarnings("all") int get$i() {
return this.$i;
}
public @java.lang.SuppressWarnings("all") int getI() {
return this.i;
}
}
@@ -0,0 +1,21 @@
class NonNullPlain {
@lombok.Setter @lombok.NonNull @lombok.Getter int i;
@lombok.Getter @lombok.Setter @lombok.NonNull String s;
NonNullPlain() {
super();
}
public @java.lang.SuppressWarnings("all") void setI(final @lombok.NonNull int i) {
this.i = i;
}
public @lombok.NonNull @java.lang.SuppressWarnings("all") int getI() {
return this.i;
}
public @lombok.NonNull @java.lang.SuppressWarnings("all") String getS() {
return this.s;
}
public @java.lang.SuppressWarnings("all") void setS(final @lombok.NonNull String s) {
if ((s == null))
throw new java.lang.NullPointerException("s");
this.s = s;
}
}
@@ -0,0 +1,26 @@
class SetterAccessLevel {
@lombok.Setter(lombok.AccessLevel.NONE) boolean isNone;
@lombok.Setter(lombok.AccessLevel.PRIVATE) boolean isPrivate;
@lombok.Setter(lombok.AccessLevel.PACKAGE) boolean isPackage;
@lombok.Setter(lombok.AccessLevel.PROTECTED) boolean isProtected;
@lombok.Setter(lombok.AccessLevel.PUBLIC) boolean isPublic;
@lombok.Setter(value = lombok.AccessLevel.PUBLIC) boolean value;
SetterAccessLevel() {
super();
}
private @java.lang.SuppressWarnings("all") void setIsPrivate(final boolean isPrivate) {
this.isPrivate = isPrivate;
}
@java.lang.SuppressWarnings("all") void setIsPackage(final boolean isPackage) {
this.isPackage = isPackage;
}
protected @java.lang.SuppressWarnings("all") void setIsProtected(final boolean isProtected) {
this.isProtected = isProtected;
}
public @java.lang.SuppressWarnings("all") void setIsPublic(final boolean isPublic) {
this.isPublic = isPublic;
}
public @java.lang.SuppressWarnings("all") void setValue(final boolean value) {
this.value = value;
}
}
@@ -0,0 +1,56 @@
class Setter1 {
@lombok.Setter boolean foo;
Setter1() {
super();
}
void setFoo(boolean foo) {
}
}
class Setter2 {
@lombok.Setter boolean foo;
Setter2() {
super();
}
void setFoo(String foo) {
}
}
class Setter3 {
@lombok.Setter String foo;
Setter3() {
super();
}
void setFoo(boolean foo) {
}
}
class Setter4 {
@lombok.Setter String foo;
Setter4() {
super();
}
void setFoo(String foo) {
}
}
class Setter5 {
@lombok.Setter String foo;
Setter5() {
super();
}
void setFoo() {
}
}
class Setter6 {
@lombok.Setter String foo;
Setter6() {
super();
}
void setFoo(String foo, int x) {
}
}
class Setter7 {
@lombok.Setter String foo;
Setter7() {
super();
}
static void setFoo() {
}
}
@@ -0,0 +1,69 @@
@lombok.Setter class SetterOnClass1 {
@lombok.Setter(lombok.AccessLevel.NONE) boolean isNone;
boolean isPublic;
SetterOnClass1() {
super();
}
public @java.lang.SuppressWarnings("all") void setIsPublic(final boolean isPublic) {
this.isPublic = isPublic;
}
}
@lombok.Setter(lombok.AccessLevel.PROTECTED) class SetterOnClass2 {
@lombok.Setter(lombok.AccessLevel.NONE) boolean isNone;
boolean isProtected;
@lombok.Setter(lombok.AccessLevel.PACKAGE) boolean isPackage;
SetterOnClass2() {
super();
}
@java.lang.SuppressWarnings("all") void setIsPackage(final boolean isPackage) {
this.isPackage = isPackage;
}
protected @java.lang.SuppressWarnings("all") void setIsProtected(final boolean isProtected) {
this.isProtected = isProtected;
}
}
@lombok.Setter(lombok.AccessLevel.PACKAGE) class SetterOnClass3 {
@lombok.Setter(lombok.AccessLevel.NONE) boolean isNone;
boolean isPackage;
SetterOnClass3() {
super();
}
@java.lang.SuppressWarnings("all") void setIsPackage(final boolean isPackage) {
this.isPackage = isPackage;
}
}
@lombok.Setter(lombok.AccessLevel.PRIVATE) class SetterOnClass4 {
@lombok.Setter(lombok.AccessLevel.NONE) boolean isNone;
boolean isPrivate;
SetterOnClass4() {
super();
}
private @java.lang.SuppressWarnings("all") void setIsPrivate(final boolean isPrivate) {
this.isPrivate = isPrivate;
}
}
@lombok.Setter(lombok.AccessLevel.PUBLIC) class SetterOnClass5 {
@lombok.Setter(lombok.AccessLevel.NONE) boolean isNone;
boolean isPublic;
SetterOnClass5() {
super();
}
public @java.lang.SuppressWarnings("all") void setIsPublic(final boolean isPublic) {
this.isPublic = isPublic;
}
}
@lombok.Setter class SetterOnClass6 {
String couldBeNull;
@lombok.NonNull String nonNull;
SetterOnClass6() {
super();
}
public @java.lang.SuppressWarnings("all") void setCouldBeNull(final String couldBeNull) {
this.couldBeNull = couldBeNull;
}
public @java.lang.SuppressWarnings("all") void setNonNull(final @lombok.NonNull String nonNull) {
if ((nonNull == null))
throw new java.lang.NullPointerException("nonNull");
this.nonNull = nonNull;
}
}
@@ -0,0 +1,14 @@
import lombok.Setter;
class SetterPlain {
@lombok.Setter int i;
@Setter int foo;
SetterPlain() {
super();
}
public @java.lang.SuppressWarnings("all") void setI(final int i) {
this.i = i;
}
public @java.lang.SuppressWarnings("all") void setFoo(final int foo) {
this.foo = foo;
}
}
@@ -0,0 +1,22 @@
class SetterWithDollar1 {
@lombok.Setter int $i;
SetterWithDollar1() {
super();
}
public @java.lang.SuppressWarnings("all") void set$i(final int $i) {
this.$i = $i;
}
}
class SetterWithDollar2 {
@lombok.Setter int $i;
@lombok.Setter int i;
SetterWithDollar2() {
super();
}
public @java.lang.SuppressWarnings("all") void set$i(final int $i) {
this.$i = $i;
}
public @java.lang.SuppressWarnings("all") void setI(final int i) {
this.i = i;
}
}
@@ -0,0 +1,63 @@
import java.awt.AWTException;
import java.io.IOException;
import java.util.Random;
class SneakyThrowsMultiple {
SneakyThrowsMultiple() {
super();
}
public @lombok.SneakyThrows({IOException.class, Throwable.class}) void test() {
try
{
try
{
System.out.println("test1");
throw new IOException();
}
catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
catch (final Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
public @lombok.SneakyThrows({AWTException.class, IOException.class}) void test2() {
try
{
try
{
System.out.println("test2");
if (new Random().nextBoolean())
{
throw new IOException();
}
else
{
throw new AWTException("WHAT");
}
}
catch (final AWTException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
public @lombok.SneakyThrows(value = {IOException.class, Throwable.class}) void test3() {
try
{
try
{
System.out.println("test3");
throw new IOException();
}
catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
catch (final Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
}
@@ -0,0 +1,24 @@
import lombok.SneakyThrows;
class SneakyThrowsPlain {
SneakyThrowsPlain() {
super();
}
public @lombok.SneakyThrows void test() {
try
{
System.out.println("test1");
}
catch (final java.lang.Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
public @SneakyThrows void test2() {
try
{
System.out.println("test2");
}
catch (final java.lang.Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
}
@@ -0,0 +1,35 @@
import java.io.IOException;
class SneakyThrowsSingle {
SneakyThrowsSingle() {
super();
}
public @lombok.SneakyThrows(Throwable.class) void test() {
try
{
System.out.println("test1");
}
catch (final Throwable $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
public @lombok.SneakyThrows(IOException.class) void test2() {
try
{
System.out.println("test2");
throw new IOException();
}
catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
public @lombok.SneakyThrows(value = IOException.class) void test3() {
try
{
System.out.println("test3");
throw new IOException();
}
catch (final IOException $ex) {
throw lombok.Lombok.sneakyThrow($ex);
}
}
}
@@ -0,0 +1,36 @@
class SynchronizedName {
private Object read = new Object();
private static Object READ = new Object();
<clinit>() {
}
SynchronizedName() {
super();
}
@lombok.Synchronized("read") void test1() {
synchronized (this.read)
{
System.out.println("one");
}
}
@lombok.Synchronized("write") void test2() {
System.out.println("two");
}
static @lombok.Synchronized("read") void test3() {
synchronized (SynchronizedName.read)
{
System.out.println("three");
}
}
@lombok.Synchronized("READ") void test4() {
synchronized (this.READ)
{
System.out.println("four");
}
}
@lombok.Synchronized(value = "read") void test5() {
synchronized (this.read)
{
System.out.println("five");
}
}
}
@@ -0,0 +1,37 @@
import lombok.Synchronized;
class SynchronizedPlain1 {
private final @java.lang.SuppressWarnings("all") java.lang.Object $lock = new java.lang.Object[0];
SynchronizedPlain1() {
super();
}
@lombok.Synchronized void test() {
synchronized (this.$lock)
{
System.out.println("one");
}
}
@Synchronized void test2() {
synchronized (this.$lock)
{
System.out.println("two");
}
}
}
class SynchronizedPlain2 {
private static final @java.lang.SuppressWarnings("all") java.lang.Object $LOCK = new java.lang.Object[0];
SynchronizedPlain2() {
super();
}
static @lombok.Synchronized void test() {
synchronized (SynchronizedPlain2.$LOCK)
{
System.out.println("three");
}
}
static @Synchronized void test2() {
synchronized (SynchronizedPlain2.$LOCK)
{
System.out.println("four");
}
}
}
@@ -0,0 +1,43 @@
import lombok.ToString;
@ToString class ToStringOuter {
@ToString class ToStringInner {
final int y;
ToStringInner() {
super();
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (("ToStringInner(y=" + this.y) + ")");
}
}
static @ToString class ToStringStaticInner {
final int y;
ToStringStaticInner() {
super();
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (("ToStringStaticInner(y=" + this.y) + ")");
}
}
class ToStringMiddle {
@ToString class ToStringMoreInner {
final String name;
ToStringMoreInner() {
super();
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (("ToStringMoreInner(name=" + this.name) + ")");
}
}
ToStringMiddle() {
super();
}
}
final int x;
String name;
ToStringOuter() {
super();
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (((("ToStringOuter(x=" + this.x) + ", name=") + this.name) + ")");
}
}
@@ -0,0 +1,21 @@
import lombok.ToString;
@lombok.ToString class ToString1 {
final int x;
String name;
ToString1() {
super();
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (((("ToString1(x=" + this.x) + ", name=") + this.name) + ")");
}
}
@ToString class ToString2 {
final int x;
String name;
ToString2() {
super();
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return (((("ToString2(x=" + this.x) + ", name=") + this.name) + ")");
}
}
@@ -1,4 +1,3 @@
//ignore
class GetterWithDollar1 {
@lombok.Getter int $i;
}
@@ -1,5 +1,4 @@
class NonNullPlain {
@lombok.Getter
@lombok.Setter
@lombok.NonNull
@lombok.Getter int i;
@@ -1,4 +1,3 @@
//ignore
class SetterWithDollar1 {
@lombok.Setter int $i;
}
@@ -3,13 +3,13 @@ import java.io.IOException;
import java.util.Random;
class SneakyThrowsMultiple {
@lombok.SneakyThrows(IOException.class,Throwable.class)
@lombok.SneakyThrows({IOException.class,Throwable.class})
public void test() {
System.out.println("test1");
throw new IOException();
}
@lombok.SneakyThrows(AWTException.class,IOException.class)
@lombok.SneakyThrows({AWTException.class,IOException.class})
public void test2() {
System.out.println("test2");
if (new Random().nextBoolean()) {
@@ -1,4 +1,3 @@
//ignore
class SynchronizedName {
private Object read = new Object();
private static Object READ = new Object();
@@ -0,0 +1 @@
8:9 ERROR The field write does not exist.
@@ -0,0 +1,10 @@
2 warning Not generating isFoo(): A method with that name already exists (hasFoo)
8 warning Not generating isFoo(): A method with that name already exists
14 warning Not generating isFoo(): A method with that name already exists (getFoo)
32 warning Not generating getFoo(): A method with that name already exists
50 warning Not generating getFoo(): A method with that name already exists
56 warning Not generating isFoo(): A method with that name already exists (hasFoo)
62 warning Not generating isFoo(): A method with that name already exists
68 warning Not generating isFoo(): A method with that name already exists (getFoo)
86 warning Not generating getFoo(): A method with that name already exists
104 warning Not generating getFoo(): A method with that name already exists
@@ -0,0 +1 @@
7 warning Not generating isFoo(): A method with that name already exists (hasFoo)
@@ -0,0 +1,7 @@
2 warning Not generating setFoo(boolean foo): A method with that name already exists
7 warning Not generating setFoo(boolean foo): A method with that name already exists
12 warning Not generating setFoo(String foo): A method with that name already exists
17 warning Not generating setFoo(String foo): A method with that name already exists
22 warning Not generating setFoo(String foo): A method with that name already exists
27 warning Not generating setFoo(String foo): A method with that name already exists
32 warning Not generating setFoo(String foo): A method with that name already exists
@@ -0,0 +1 @@
8 error The field write does not exist.
@@ -0,0 +1,56 @@
/*
* Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
*
* 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.transform;
import java.io.File;
import lombok.DirectoryRunner;
import org.junit.runner.RunWith;
@RunWith(DirectoryRunner.class)
public class TestWithEcj implements DirectoryRunner.TestParams {
@Override
public DirectoryRunner.Compiler getCompiler() {
return DirectoryRunner.Compiler.ECJ;
}
@Override
public boolean printErrors() {
return true;
}
@Override
public File getBeforeDirectory() {
return new File("test/transform/resource/before");
}
@Override
public File getAfterDirectory() {
return new File("test/transform/resource/after-ecj");
}
@Override
public File getMessagesDirectory() {
return new File("test/transform/resource/messages-ecj");
}
}