From e0cfacd3b307b1ec9f0b62b2f953f0a0e85d9d1e Mon Sep 17 00:00:00 2001 From: grootjans Date: Mon, 21 Feb 2011 22:03:05 +0100 Subject: Issue 192: Add documentation for onMethod=, onParam, onConstructor still have to make a minor edit in the pre/post files --- buildScripts/website.ant.xml | 3 ++ usage_examples/onXExample_post.jpage | 41 +++++++++++++++++++++++++ usage_examples/onXExample_pre.jpage | 23 ++++++++++++++ website/features/Delegate.html | 2 +- website/features/index.html | 2 ++ website/features/onX.html | 58 ++++++++++++++++++++++++++++++++++++ 6 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 usage_examples/onXExample_post.jpage create mode 100644 usage_examples/onXExample_pre.jpage create mode 100644 website/features/onX.html diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml index aabc337c..68e20eae 100644 --- a/buildScripts/website.ant.xml +++ b/buildScripts/website.ant.xml @@ -144,6 +144,9 @@ such as converting the changelog into HTML, and creating javadoc. + + + diff --git a/usage_examples/onXExample_post.jpage b/usage_examples/onXExample_post.jpage new file mode 100644 index 00000000..f71f16a3 --- /dev/null +++ b/usage_examples/onXExample_post.jpage @@ -0,0 +1,41 @@ +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +public class OnMethodOnParamExample { + private int fires = 200; + private int firemen = 20; + private String fireStationName = "base"; + + @Deprecated + public int getFires() { + return fires; + } + + @Deprecated + public void setFiremen(int firemen) { + this.firemen = firemen; + } + + public void setFireStationName(@SuppressWarnings("all") int fireStationName) { + this.fireStationName = fireStationName; + } + + @Override public String toString() { + return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires); + } +} + +class OnConstructorExample { + private final int radishes; + private int bananas; + + @Deprecated + public OnConstructorExample(int radishes) { + this.radishes = radishes; + } + + @Override public String toString() { + return String.format("I have %d bananas and %d radishes", bananas, radishes); + } +} \ No newline at end of file diff --git a/usage_examples/onXExample_pre.jpage b/usage_examples/onXExample_pre.jpage new file mode 100644 index 00000000..3e91fb3a --- /dev/null +++ b/usage_examples/onXExample_pre.jpage @@ -0,0 +1,23 @@ +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +public class OnMethodOnParamExample { + @Getter(onMethod=@Deprecated) private int fires = 200; + @Setter(onMethod=@Deprecated) private int firemen = 20; + @Setter(onParam=@SuppressWarnings("all")) private String fireStationName = "base"; + + @Override public String toString() { + return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires); + } +} + +@RequiredArgsConstructor(onConstructor=@Deprecated) +class OnConstructorExample { + private final int radishes; + private int bananas; + + @Override public String toString() { + return String.format("I have %d bananas and %d radishes", bananas, radishes); + } +} \ No newline at end of file diff --git a/website/features/Delegate.html b/website/features/Delegate.html index bdb22c26..52b1035d 100644 --- a/website/features/Delegate.html +++ b/website/features/Delegate.html @@ -51,7 +51,7 @@
diff --git a/website/features/index.html b/website/features/index.html index 06b6763e..e9a2255b 100644 --- a/website/features/index.html +++ b/website/features/index.html @@ -38,6 +38,8 @@
Finally! hassle-free final local variables.
@Delegate
Don't lose your composition
+
onMethod=,onParam=,onConstructor=
+
Annotate this! Add you favorite annotation to methods generated by lombok.
diff --git a/website/features/onX.html b/website/features/onX.html new file mode 100644 index 00000000..b94dea4b --- /dev/null +++ b/website/features/onX.html @@ -0,0 +1,58 @@ + + + + + + + + onMethod=,onParam=,onConstructor= +
+
+
+ +

onMethod=,onParam=,onConstructor=

+ +
+

Overview

+

+ Lombok lets you add your favorite annotation to methods generated by @Getter and @Setter by using the attribute onMethod + on the lombok annotation. You can specify annotations to the parameters of the method on @Setter with the attribute onParameter. + You can add annotation to constructors generated by @NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor by using the attribute + onConstructor +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Small print

+ When the @Getter or @Setter annotation is placed on the type in stead of a field, using the attribute is not supported and it will result in a warning. +
+
+ +
+
+
+ + + -- cgit From 0fa03d313263991f6f7f55e68097e5e9794e4a7b Mon Sep 17 00:00:00 2001 From: grootjans Date: Mon, 28 Feb 2011 12:32:27 +0100 Subject: Updates examples to use Guice and hibernate validators. --- usage_examples/onXExample_post.jpage | 39 ++++++++++++++++++------------------ usage_examples/onXExample_pre.jpage | 17 ++++++++-------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/usage_examples/onXExample_post.jpage b/usage_examples/onXExample_post.jpage index f71f16a3..85e3c58f 100644 --- a/usage_examples/onXExample_post.jpage +++ b/usage_examples/onXExample_post.jpage @@ -1,41 +1,42 @@ +import com.google.inject.Inject; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; +import org.hibernate.validator.Min; public class OnMethodOnParamExample { - private int fires = 200; - private int firemen = 20; - private String fireStationName = "base"; - - @Deprecated - public int getFires() { - return fires; - } + private int bananas; + private int radishes; @Deprecated - public void setFiremen(int firemen) { - this.firemen = firemen; + public int getBananas() { + return bananas; } - public void setFireStationName(@SuppressWarnings("all") int fireStationName) { - this.fireStationName = fireStationName; + @Min(10) + public int setRadishes(int radishes) { + this.radishes = radishes; } @Override public String toString() { - return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires); + return String.format("I have %d bananas and %d beautiful radishes", bananas, radishes); } } class OnConstructorExample { - private final int radishes; - private int bananas; + private final Fireman fireman; + private int fires = 10; - @Deprecated - public OnConstructorExample(int radishes) { - this.radishes = radishes; + @Inject + public OnConstructorExample(Fireman fireman) { + this.fireman = fireman; + } + + public void setFires(@SuppressWarnings("all") int fires) { + this.fires = fires; } @Override public String toString() { - return String.format("I have %d bananas and %d radishes", bananas, radishes); + return String.format("Fireman: %s has %d fires", fireman, fires); } } \ No newline at end of file diff --git a/usage_examples/onXExample_pre.jpage b/usage_examples/onXExample_pre.jpage index 3e91fb3a..1bab3835 100644 --- a/usage_examples/onXExample_pre.jpage +++ b/usage_examples/onXExample_pre.jpage @@ -1,23 +1,24 @@ +import com.google.inject.Inject; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; +import org.hibernate.validator.Min; public class OnMethodOnParamExample { - @Getter(onMethod=@Deprecated) private int fires = 200; - @Setter(onMethod=@Deprecated) private int firemen = 20; - @Setter(onParam=@SuppressWarnings("all")) private String fireStationName = "base"; + @Getter(onMethod=@Deprecated) private int bananas; + @Setter(onMethod=@Min(10)) private int radishes; @Override public String toString() { - return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires); + return String.format("I have %d bananas and %d beautiful radishes", bananas, radishes); } } -@RequiredArgsConstructor(onConstructor=@Deprecated) +@RequiredArgsConstructor(onConstructor=@Inject) class OnConstructorExample { - private final int radishes; - private int bananas; + private final Fireman fireman; + @Setter(onParam=@SuppressWarnings("all")) private int fires = 10; @Override public String toString() { - return String.format("I have %d bananas and %d radishes", bananas, radishes); + return String.format("Fireman: %s has %d fires", fireman, fires); } } \ No newline at end of file -- cgit From 1c3ed9ac5d321a2c6c33659e9c97a557f99227a8 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sun, 6 Mar 2011 01:21:54 +0100 Subject: added developers and contributors to maven pom. --- doc/maven-pom.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/maven-pom.xml b/doc/maven-pom.xml index bf22ea5d..e5be451e 100644 --- a/doc/maven-pom.xml +++ b/doc/maven-pom.xml @@ -20,6 +20,28 @@ scm:git:git://github.com/rzwitserloot/lombok.git scm:git:git://github.com/rzwitserloot/lombok.git + + + rzwitserloot + Reinier Zwitserloot + reinier@projectlombok.org + http://zwitserloot.com + +1 + + + rspilker + Roel Spilker + roel@projectlombok.org + +1 + + + + + rgrootjans + Robbert Jan Grootjans + +1 + + + + diff --git a/website/mavenrepo/index.html b/website/mavenrepo/index.html index 6b8ea48d..aa7f4935 100644 --- a/website/mavenrepo/index.html +++ b/website/mavenrepo/index.html @@ -43,7 +43,7 @@
-

Use Lombok via Maven

+

Use Lombok via Maven or ivy

You can use lombok with maven by adding the following to your pom.xml:
<dependencies> @@ -53,25 +53,14 @@ <version>@VERSION@</version> <scope>provided</scope> </dependency> -</dependencies> -<repositories> - <repository> - <id>projectlombok.org</id> - <url>http://projectlombok.org/mavenrepo</url> - </repository> -</repositories>
+</dependencies>
+
+
+ You can use lombok with ivy by adding the following to your ivy.xml: +
<dependency org="projectlombok.org" name="lombok" rev="@VERSION@" conf="build" />
+
- CAREFUL: lombok requires using the javac v1.6 compiler. If this is not your default compiler, you'll need to add the following to your - pom file to explicitly set the java compiler version to use: -
<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <compilerVersion>1.6</compilerVersion> - <source>1.6</source> - <target>1.6</target> - </configuration> -</plugin>
+ CAREFUL: lombok requires using the javac v1.6 compiler or higher.
That's all there is to it!
note: You'll still need to download lombok, or doubleclick on the lombok.jar file downloaded by maven, to install lombok into your eclipse installation.
-- cgit From 4afc7e5c2344fc5edbd55e815ce62fa1ac8fb357 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 16 Mar 2011 07:43:55 +0100 Subject: Added printing oss.sonatype.org usernamepass to build script when publishing maven --- build.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.xml b/build.xml index f3de4339..d747e617 100644 --- a/build.xml +++ b/build.xml @@ -322,6 +322,12 @@ the common tasks and can be called on to run the main aspects of all the sub-scr username="lombokup" keyfile="escudo-upload.key" passphrase="" trust="true" command="./publishToMavenCentral" /> + The artifact has been published to staging. Now go to http://oss.sonatype.org/ and log in as Reinier, then doublecheck if all is well and 'release' it. + -- cgit From d0131d9c9bf8fb2dcc87c8dbec430c58bf926880 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 16 Mar 2011 07:56:29 +0100 Subject: Updated instructions for publishing a new version --- doc/publishing.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/publishing.txt b/doc/publishing.txt index 01a2c294..85a13a9c 100644 --- a/doc/publishing.txt +++ b/doc/publishing.txt @@ -10,4 +10,6 @@ Step #4: git push && git push --tags Step #5: ant publish-all +Step #6: Follow the instructions that flew by when the maven-publish task ran, which involves going to http://oss.sonatype.org/ and logging in with the username/pass that are in your scroll log, to test and then 'release' the staged repo to maven central. Note that once you do this there's no turning back, and that version number is forever associated with this release. + Step #6: Change src/core/lombok/core/Version.java to "0.8.2-EDGE", and commit this. -- cgit From 38b4128f899e81d8a5d19dca8b6cd1357ca3bd1a Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 18 Mar 2011 18:25:59 +0100 Subject: previous attempt to use more maven central repos failed, so reverted most of it. see commit 1a28ccb3471c1309357547e72a3997e1ec4c91de. --- buildScripts/ivy-repo/eclipse.org-ecj-3.6.0.xml | 14 -------------- buildScripts/ivy-repo/eclipse.org-jdt.core-3.6.0.xml | 14 -------------- buildScripts/ivy-repo/eclipse.org-jdt.ui-3.6.0.xml | 14 -------------- .../ivy-repo/org.eclipse.custom-core.runtime-3.6.0.xml | 14 ++++++++++++++ buildScripts/ivy-repo/org.eclipse.custom-ecj-3.6.0.xml | 14 ++++++++++++++ .../ivy-repo/org.eclipse.custom-equinox.common-3.6.0.xml | 14 ++++++++++++++ .../ivy-repo/org.eclipse.custom-jdt.core-3.6.0.xml | 14 ++++++++++++++ buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.6.0.xml | 14 ++++++++++++++ buildScripts/ivy-repo/org.eclipse.custom-osgi-3.6.0.xml | 14 ++++++++++++++ buildScripts/ivy.xml | 12 ++++++------ 10 files changed, 90 insertions(+), 48 deletions(-) delete mode 100644 buildScripts/ivy-repo/eclipse.org-ecj-3.6.0.xml delete mode 100644 buildScripts/ivy-repo/eclipse.org-jdt.core-3.6.0.xml delete mode 100644 buildScripts/ivy-repo/eclipse.org-jdt.ui-3.6.0.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.6.0.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-ecj-3.6.0.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.0.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.6.0.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.6.0.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-osgi-3.6.0.xml diff --git a/buildScripts/ivy-repo/eclipse.org-ecj-3.6.0.xml b/buildScripts/ivy-repo/eclipse.org-ecj-3.6.0.xml deleted file mode 100644 index e3b8aceb..00000000 --- a/buildScripts/ivy-repo/eclipse.org-ecj-3.6.0.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/buildScripts/ivy-repo/eclipse.org-jdt.core-3.6.0.xml b/buildScripts/ivy-repo/eclipse.org-jdt.core-3.6.0.xml deleted file mode 100644 index 7a3225d8..00000000 --- a/buildScripts/ivy-repo/eclipse.org-jdt.core-3.6.0.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/buildScripts/ivy-repo/eclipse.org-jdt.ui-3.6.0.xml b/buildScripts/ivy-repo/eclipse.org-jdt.ui-3.6.0.xml deleted file mode 100644 index 6244df5b..00000000 --- a/buildScripts/ivy-repo/eclipse.org-jdt.ui-3.6.0.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.6.0.xml new file mode 100644 index 00000000..fe812bbc --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.6.0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-ecj-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-ecj-3.6.0.xml new file mode 100644 index 00000000..6ea9088e --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-ecj-3.6.0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.0.xml new file mode 100644 index 00000000..889a2ceb --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.6.0.xml new file mode 100644 index 00000000..f9a8f52d --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.6.0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.6.0.xml new file mode 100644 index 00000000..dbee2865 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.6.0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.6.0.xml new file mode 100644 index 00000000..93a7f381 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.6.0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index 83bd3a19..4d3bb679 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -26,17 +26,17 @@ - + - - - - - + + + + + -- cgit From 04e9397971d3689e0710df026f673f8b0a6cb685 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 18 Mar 2011 19:30:02 +0100 Subject: Rewritten @Cleanup's new null analysis prevention to not use Lombok.preventNullAnalysis but go with Collections.singletonList(expr).get(0) instead; while this does create a pointless object, it doesn't cause a clash when eclipse has lombok 0.10 installed but the project uses 0.9, which doesn't have preventNullAnalysis. Eventually, once 0.9 is long forgotten, this can be reverted. --- .../lombok/eclipse/handlers/HandleCleanup.java | 43 ++++++++++++++++------ src/core/lombok/javac/handlers/HandleCleanup.java | 8 +++- .../resource/after-delombok/CleanupName.java | 4 +- .../resource/after-delombok/CleanupPlain.java | 4 +- test/transform/resource/after-ecj/CleanupName.java | 4 +- .../transform/resource/after-ecj/CleanupPlain.java | 4 +- 6 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/core/lombok/eclipse/handlers/HandleCleanup.java b/src/core/lombok/eclipse/handlers/HandleCleanup.java index 964653bc..9a63ce47 100644 --- a/src/core/lombok/eclipse/handlers/HandleCleanup.java +++ b/src/core/lombok/eclipse/handlers/HandleCleanup.java @@ -42,6 +42,7 @@ import org.eclipse.jdt.internal.compiler.ast.CastExpression; import org.eclipse.jdt.internal.compiler.ast.EqualExpression; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.IfStatement; +import org.eclipse.jdt.internal.compiler.ast.IntLiteral; import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.eclipse.jdt.internal.compiler.ast.MemberValuePair; import org.eclipse.jdt.internal.compiler.ast.MessageSend; @@ -174,16 +175,7 @@ public class HandleCleanup implements EclipseAnnotationHandler { NullLiteral nullLiteral = new NullLiteral(pS, pE); Eclipse.setGeneratedBy(nullLiteral, ast); - MessageSend preventNullAnalysis = new MessageSend(); - Eclipse.setGeneratedBy(preventNullAnalysis, ast); - - preventNullAnalysis.receiver = createNameReference("lombok.Lombok", ast); - preventNullAnalysis.selector = "preventNullAnalysis".toCharArray(); - - preventNullAnalysis.arguments = new Expression[] { varName }; - preventNullAnalysis.nameSourcePosition = p; - preventNullAnalysis.sourceStart = pS; - preventNullAnalysis.sourceEnd = preventNullAnalysis.statementEnd = pE; + MessageSend preventNullAnalysis = preventNullAnalysis(ast, varName); EqualExpression equalExpression = new EqualExpression(preventNullAnalysis, nullLiteral, OperatorIds.NOT_EQUAL); equalExpression.sourceStart = pS; equalExpression.sourceEnd = pE; @@ -195,8 +187,6 @@ public class HandleCleanup implements EclipseAnnotationHandler { Eclipse.setGeneratedBy(closeBlock, ast); IfStatement ifStatement = new IfStatement(equalExpression, closeBlock, 0, 0); Eclipse.setGeneratedBy(ifStatement, ast); - - finallyBlock[0] = ifStatement; tryStatement.finallyBlock = new Block(0); @@ -219,6 +209,35 @@ public class HandleCleanup implements EclipseAnnotationHandler { return true; } + private MessageSend preventNullAnalysis(Annotation ast, Expression expr) { + MessageSend singletonList = new MessageSend(); + Eclipse.setGeneratedBy(singletonList, ast); + + int pS = ast.sourceStart, pE = ast.sourceEnd; + long p = (long)pS << 32 | pE; + + singletonList.receiver = createNameReference("java.util.Collections", ast); + singletonList.selector = "singletonList".toCharArray(); + + singletonList.arguments = new Expression[] { expr }; + singletonList.nameSourcePosition = p; + singletonList.sourceStart = pS; + singletonList.sourceEnd = singletonList.statementEnd = pE; + + MessageSend preventNullAnalysis = new MessageSend(); + Eclipse.setGeneratedBy(preventNullAnalysis, ast); + + preventNullAnalysis.receiver = singletonList; + preventNullAnalysis.selector = "get".toCharArray(); + + preventNullAnalysis.arguments = new Expression[] { new IntLiteral(new char[] { '0' }, pS, pE) }; + preventNullAnalysis.nameSourcePosition = p; + preventNullAnalysis.sourceStart = pS; + preventNullAnalysis.sourceEnd = singletonList.statementEnd = pE; + + return preventNullAnalysis; + } + private void doAssignmentCheck(EclipseNode node, Statement[] tryBlock, char[] varName) { for (Statement statement : tryBlock) doAssignmentCheck0(node, statement, varName); } diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java index 9e2fddf6..b681ab28 100644 --- a/src/core/lombok/javac/handlers/HandleCleanup.java +++ b/src/core/lombok/javac/handlers/HandleCleanup.java @@ -117,7 +117,7 @@ public class HandleCleanup implements JavacAnnotationHandler { List cleanupCall = List.of(maker.Exec( maker.Apply(List.nil(), cleanupMethod, List.nil()))); - JCMethodInvocation preventNullAnalysis = maker.Apply(List.nil(), JavacHandlerUtil.chainDotsString(maker, annotationNode, "lombok.Lombok.preventNullAnalysis"), List.of(maker.Ident(decl.name))); + JCMethodInvocation preventNullAnalysis = preventNullAnalysis(maker, annotationNode, maker.Ident(decl.name)); JCBinary isNull = maker.Binary(Javac.getCTCint(JCTree.class, "NE"), preventNullAnalysis, maker.Literal(Javac.getCTCint(TypeTags.class, "BOT"), null)); JCIf ifNotNullCleanup = maker.If(isNull, maker.Block(0, cleanupCall), null); @@ -139,6 +139,12 @@ public class HandleCleanup implements JavacAnnotationHandler { return true; } + private JCMethodInvocation preventNullAnalysis(TreeMaker maker, JavacNode node, JCExpression expression) { + JCMethodInvocation singletonList = maker.Apply(List.nil(), JavacHandlerUtil.chainDotsString(maker, node, "java.util.Collections.singletonList"), List.of(expression)); + JCMethodInvocation cleanedExpr = maker.Apply(List.nil(), maker.Select(singletonList, node.toName("get")) , List.of(maker.Literal(TypeTags.INT, 0))); + return cleanedExpr; + } + private void doAssignmentCheck(JavacNode node, List statements, Name name) { for (JCStatement statement : statements) doAssignmentCheck0(node, statement, name); } diff --git a/test/transform/resource/after-delombok/CleanupName.java b/test/transform/resource/after-delombok/CleanupName.java index 37a8d117..a4ab8267 100644 --- a/test/transform/resource/after-delombok/CleanupName.java +++ b/test/transform/resource/after-delombok/CleanupName.java @@ -4,7 +4,7 @@ class CleanupName { try { System.out.println(o); } finally { - if (lombok.Lombok.preventNullAnalysis(o) != null) { + if (java.util.Collections.singletonList(o).get(0) != null) { o.toString(); } } @@ -14,7 +14,7 @@ class CleanupName { try { System.out.println(o); } finally { - if (lombok.Lombok.preventNullAnalysis(o) != null) { + if (java.util.Collections.singletonList(o).get(0) != null) { o.toString(); } } diff --git a/test/transform/resource/after-delombok/CleanupPlain.java b/test/transform/resource/after-delombok/CleanupPlain.java index 67c82f60..f91f35ee 100644 --- a/test/transform/resource/after-delombok/CleanupPlain.java +++ b/test/transform/resource/after-delombok/CleanupPlain.java @@ -9,12 +9,12 @@ class CleanupPlain { out.flush(); } } finally { - if (lombok.Lombok.preventNullAnalysis(out) != null) { + if (java.util.Collections.singletonList(out).get(0) != null) { out.close(); } } } finally { - if (lombok.Lombok.preventNullAnalysis(in) != null) { + if (java.util.Collections.singletonList(in).get(0) != null) { in.close(); } } diff --git a/test/transform/resource/after-ecj/CleanupName.java b/test/transform/resource/after-ecj/CleanupName.java index 8948e91d..f3f725f2 100644 --- a/test/transform/resource/after-ecj/CleanupName.java +++ b/test/transform/resource/after-ecj/CleanupName.java @@ -10,7 +10,7 @@ class CleanupName { } finally { - if ((lombok.Lombok.preventNullAnalysis(o) != null)) + if ((java.util.Collections.singletonList(o).get(0) != null)) { o.toString(); } @@ -24,7 +24,7 @@ class CleanupName { } finally { - if ((lombok.Lombok.preventNullAnalysis(o) != null)) + if ((java.util.Collections.singletonList(o).get(0) != null)) { o.toString(); } diff --git a/test/transform/resource/after-ecj/CleanupPlain.java b/test/transform/resource/after-ecj/CleanupPlain.java index 6eaa4377..a9b9eceb 100644 --- a/test/transform/resource/after-ecj/CleanupPlain.java +++ b/test/transform/resource/after-ecj/CleanupPlain.java @@ -18,7 +18,7 @@ class CleanupPlain { } finally { - if ((lombok.Lombok.preventNullAnalysis(out) != null)) + if ((java.util.Collections.singletonList(out).get(0) != null)) { out.close(); } @@ -26,7 +26,7 @@ class CleanupPlain { } finally { - if ((lombok.Lombok.preventNullAnalysis(in) != null)) + if ((java.util.Collections.singletonList(in).get(0) != null)) { in.close(); } -- cgit From ead7ff428c14cbfd3a84723f8abae13d5ea79330 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 22 Mar 2011 21:02:04 +0100 Subject: jarjar now used to make sure asm is no longer on the bootclasspath when using lombok. --- build.xml | 7 +++++-- buildScripts/ivy.xml | 1 + doc/maven-pom.xml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build.xml b/build.xml index d747e617..676c34d7 100644 --- a/build.xml +++ b/build.xml @@ -164,12 +164,15 @@ the common tasks and can be called on to run the main aspects of all the sub-scr - + + + + @@ -177,7 +180,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr - + diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index 4d3bb679..33d62da9 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -16,6 +16,7 @@ + diff --git a/doc/maven-pom.xml b/doc/maven-pom.xml index 61738a72..34955ab8 100644 --- a/doc/maven-pom.xml +++ b/doc/maven-pom.xml @@ -18,7 +18,7 @@ scm:git:git://github.com/rzwitserloot/lombok.git - scm:git:git://github.com/rzwitserloot/lombok.git + http://github.com/rzwitserloot/lombok Google Code -- cgit From 816c0b99e7f0395b26f8a8c26e52110107f0b1e1 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 23 Mar 2011 07:39:13 +0100 Subject: Updated documentation of XArgsConstructor to highlight that we won't/can't remove suppressConstructorProperties until GWT and Android get the CP annotation. See issue #202 --- website/features/Constructor.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/features/Constructor.html b/website/features/Constructor.html index 072e46ed..c0ab9ef8 100644 --- a/website/features/Constructor.html +++ b/website/features/Constructor.html @@ -71,6 +71,10 @@

@XArgsConstructor can also be used on an enum definition. The generated constructor will always be private, because non-private constructors aren't legal in enums. You don't have to specify AccessLevel.PRIVATE. +

+ While suppressConstructorProperties has been marked deprecated in anticipation of a world where all java environments have the + @ConstructorProperties annotation available, first GWT 2.2 and Android 2.3.3, which do not (yet) have this annotation, will have + to be ancient history before this annotation parameter will be removed.

-- cgit From ab1d938ca85870639dc912fdfc46955cb3b4764f Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 28 Mar 2011 21:36:08 +0200 Subject: Now delegating classes defined in the same project works. At this revision, you can easily and reliably reproduce issue #164 by creating a loop (A delegates B and B delegates A). --- src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java index 0aa47dba..846232f6 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java @@ -74,7 +74,6 @@ import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.ClassScope; -import org.eclipse.jdt.internal.compiler.lookup.MemberTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; @@ -475,7 +474,7 @@ public class PatchDelegate { inner = binding; } - if (inner instanceof MemberTypeBinding) { + if (inner instanceof SourceTypeBinding) { ClassScope cs = ((SourceTypeBinding)inner).scope; if (cs != null) { try { @@ -527,6 +526,7 @@ public class PatchDelegate { private static final List METHODS_IN_OBJECT = Collections.unmodifiableList(Arrays.asList( "hashCode()", + "canEqual(java.lang.Object)", //Not in j.l.Object, but it goes with hashCode and equals so if we ignore those two, we should ignore this one. "equals(java.lang.Object)", "wait()", "wait(long)", -- cgit From 7ebf05aaec0c4ed0e70a3a2a8a0f56afd029bd46 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 1 Apr 2011 18:07:17 +0200 Subject: Added ability to log warnings in eclipse error log. --- src/core/lombok/eclipse/Eclipse.java | 71 ++++++++++++++++++++++------- src/core/lombok/eclipse/HandlerLibrary.java | 2 +- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/src/core/lombok/eclipse/Eclipse.java b/src/core/lombok/eclipse/Eclipse.java index ddba726a..8910bb3e 100644 --- a/src/core/lombok/eclipse/Eclipse.java +++ b/src/core/lombok/eclipse/Eclipse.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2011 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 @@ -89,46 +89,85 @@ public class Eclipse { /** * Generates an error in the Eclipse error log. Note that most people never look at it! + * + * @param cud The {@code CompilationUnitDeclaration} where the error occurred. + * An error will be generated on line 0 linking to the error log entry. Can be {@code null}. + * @param message Human readable description of the problem. + * @param error The associated exception. Can be {@code null}. */ - public static void error(CompilationUnitDeclaration cud, String message) { - error(cud, message, DEFAULT_BUNDLE, null); + public static void error(CompilationUnitDeclaration cud, String message, Throwable error) { + error(cud, message, null, error); } /** * Generates an error in the Eclipse error log. Note that most people never look at it! + * + * @param cud The {@code CompilationUnitDeclaration} where the error occurred. + * An error will be generated on line 0 linking to the error log entry. Can be {@code null}. + * @param message Human readable description of the problem. + * @param bundleName Can be {@code null} to default to {@code org.eclipse.jdt.core} which is usually right. + * @param error The associated exception. Can be {@code null}. */ - public