From 5b160554176f7439fba10fe709b948b8310a4fb0 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 1 Sep 2009 18:47:01 +0200 Subject: Well, bugger me! Adjusting the positions of the actual type identifier for the generated annotations seems to fix the David Lynch bug (issue #41). Saving this now before further fiddling breaks things again. --- src/lombok/eclipse/handlers/HandleToString.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lombok/eclipse/handlers/HandleToString.java b/src/lombok/eclipse/handlers/HandleToString.java index 4b5204b5..86f4496d 100644 --- a/src/lombok/eclipse/handlers/HandleToString.java +++ b/src/lombok/eclipse/handlers/HandleToString.java @@ -159,7 +159,8 @@ public class HandleToString implements EclipseAnnotationHandler { } private MethodDeclaration createToString(Node type, Collection fields, boolean includeFieldNames, boolean callSuper, ASTNode pos) { - char[] rawTypeName = ((TypeDeclaration)type.get()).name; + TypeDeclaration typeDeclaration = (TypeDeclaration)type.get(); + char[] rawTypeName = typeDeclaration.name; String typeName = rawTypeName == null ? "" : new String(rawTypeName); char[] suffix = ")".toCharArray(); String infixS = ", "; @@ -227,9 +228,10 @@ public class HandleToString implements EclipseAnnotationHandler { MethodDeclaration method = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult); method.modifiers = PKG.toModifier(AccessLevel.PUBLIC); method.returnType = new QualifiedTypeReference(TypeConstants.JAVA_LANG_STRING, new long[] {0, 0, 0}); - method.annotations = new Annotation[] { - new MarkerAnnotation(new QualifiedTypeReference(TypeConstants.JAVA_LANG_OVERRIDE, new long[] { 0, 0, 0}), 0) - }; + MarkerAnnotation overrideAnnotation = new MarkerAnnotation(new QualifiedTypeReference(TypeConstants.JAVA_LANG_OVERRIDE, new long[] {p, p, p}), (int)(p >> 32)); + overrideAnnotation.declarationSourceEnd = overrideAnnotation.sourceEnd = overrideAnnotation.statementEnd = (int)p; + overrideAnnotation.bits |= ASTNode.HasBeenGenerated; + method.annotations = new Annotation[] {overrideAnnotation}; method.arguments = null; method.selector = "toString".toCharArray(); method.thrownExceptions = null; -- cgit