aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
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.
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java12
1 files changed, 11 insertions, 1 deletions
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) {