aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2012-10-30 00:25:26 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2012-10-30 00:25:26 +0100
commit8a5d637af766d71d4f2b5f87eceec5360de831fa (patch)
tree510e592c508e856bced582d5333eea2a820bc3a9
parentb8e1f3bdeb622ba92b25f12a4eff35ea5f75908c (diff)
downloadlombok-8a5d637af766d71d4f2b5f87eceec5360de831fa.tar.gz
lombok-8a5d637af766d71d4f2b5f87eceec5360de831fa.tar.bz2
lombok-8a5d637af766d71d4f2b5f87eceec5360de831fa.zip
Fix for issue 408: IllegalArgumentException when generating setters in eclipse for fields with @Deprecated on them.
-rw-r--r--doc/changelog.markdown1
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java12
-rw-r--r--test/core/src/lombok/DirectoryRunner.java3
3 files changed, 13 insertions, 3 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index e0fe2b2c..17555015 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -6,6 +6,7 @@ Lombok Changelog
* BUGFIX: {Delombok} Running delombok has been causing VerifyError errors when used with javac 1.7 since 0.11.0. [Issue #422](http://code.google.com/p/projectlombok/issues/detail?id=422)
* BUGFIX: A conflict between lombok and certain eclipse plugins would result in NullPointerExceptions in the log when using `@Delegate`.
* BUGFIX: `NullPointerException in lombok.javac.handlers.JavacHandlerUtil.upToTypeNode(JavacHandlerUtil.java:978)` when compiling with `@ExtensionMethod` in javac and generated constructors are involved. [Issue #423](http://code.google.com/p/projectlombok/issues/detail?id=423)
+* BUGFIX: `@Deprecated` on a field that gets a generated setter in eclipse would result in `IllegalArgumentException`, which you wouldn't see unless you have the error log open. If you have save actions defined, you'd get a popup box with the exception. Now fixed. [Issue #408](http://code.google.com/p/projectlombok/issues/detail?id=408)
### v0.11.4 (August 13th, 2012)
* FEATURE: {Experimental} `@Value`, `@Wither` and `@FieldDefaults` are now available. These are a lot like `@Data` but geared towards immutable classes. [Documentation on @Value](http://projectlombok.org/features/experimental/Value.html), [Documentation on @Wither](http://projectlombok.org/features/experimental/Wither.html) and [Documentation on @FieldDefaults](http://projectlombok.org/features/experimental/FieldDefaults.html).
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 79a14d5a..96795fe1 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -249,7 +249,17 @@ public class EclipseHandlerUtil {
QualifiedTypeReference qtr = new QualifiedTypeReference(new char[][] {
{'j', 'a', 'v', 'a'}, {'l', 'a', 'n', 'g'}, {'D', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd'}}, poss(source, 3));
setGeneratedBy(qtr, source);
- return new MarkerAnnotation(qtr, source.sourceStart);
+ MarkerAnnotation ma = new MarkerAnnotation(qtr, source.sourceStart);
+ // No matter what value you input for sourceEnd, the AST->DOM converter of eclipse will reparse to find the end, and will fail as
+ // it can't find code that isn't really there. This results in the end position being set to 2 or 0 or some weird magic value, and thus,
+ // length, as calculated by end-start, is all screwed up, resulting in IllegalArgumentException during a setSourceRange call MUCH later in the process.
+ // We solve it by going with a voodoo magic source start value such that the calculated length so happens to exactly be 0. 0 lengths are accepted
+ // by eclipse. For some reason.
+ // TL;DR: Don't change 1. 1 is sacred. Trust the 1.
+ // issue: #408.
+ ma.sourceStart = 1;
+ setGeneratedBy(ma, source);
+ return ma;
}
public static boolean isFieldDeprecated(EclipseNode fieldNode) {
diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java
index 59a24af7..c896d327 100644
--- a/test/core/src/lombok/DirectoryRunner.java
+++ b/test/core/src/lombok/DirectoryRunner.java
@@ -103,8 +103,7 @@ public class DirectoryRunner extends Runner {
if (!runTest(entry.getKey())) {
notifier.fireTestIgnored(testDescription);
}
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
notifier.fireTestFailure(new Failure(testDescription, t));
}
notifier.fireTestFinished(testDescription);