FieldDefaults (and Value) did not call .rebuild() after changing modifiers. This also meant delombok would not emit the changed code if that's all that changed, because it thought nothing changed.

This commit is contained in:
Reinier Zwitserloot committed 2012-08-13 00:12:41 +02:00
1 parent 6e25b00ace
commit 5f511da091
5 files changed
+17 -3

No files matched your search

@@ -89,6 +89,8 @@ public class HandleFieldDefaults extends EclipseAnnotationHandler<FieldDefaults>
field.modifiers |= ClassFileConstants.AccFinal;
}
}
fieldNode.rebuild();
}
public void handle(AnnotationValues<FieldDefaults> annotation, Annotation ast, EclipseNode annotationNode) {
@@ -57,7 +57,12 @@ public class HandleValue extends EclipseAnnotationHandler<Value> {
}
// Make class final.
if (!hasAnnotation(NonFinal.class, typeNode)) typeDecl.modifiers |= ClassFileConstants.AccFinal;
if (!hasAnnotation(NonFinal.class, typeNode)) {
if ((typeDecl.modifiers & ClassFileConstants.AccFinal) == 0) {
typeDecl.modifiers |= ClassFileConstants.AccFinal;
typeNode.rebuild();
}
}
new HandleFieldDefaults().generateFieldDefaultsForType(typeNode, annotationNode, AccessLevel.PRIVATE, true, true);
@@ -99,7 +99,7 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho
if (providerType == null) continue;
if ((providerType.tsym.flags() & (INTERFACE | ANNOTATION)) != 0) continue;
extensions.add(getExtension(typeNode, (ClassType) providerType));
extensions.add(getExtension(typeNode, (ClassType) providerType));
}
return extensions;
}
@@ -91,6 +91,8 @@ public class HandleFieldDefaults extends JavacAnnotationHandler<FieldDefaults> {
field.mods.flags |= Flags.FINAL;
}
}
fieldNode.rebuild();
}
@Override public void handle(AnnotationValues<FieldDefaults> annotation, JCAnnotation ast, JavacNode annotationNode) {
@@ -35,6 +35,7 @@ import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCModifiers;
/**
* Handles the {@code lombok.Value} annotation for javac.
@@ -55,7 +56,11 @@ public class HandleValue extends JavacAnnotationHandler<Value> {
String staticConstructorName = annotation.getInstance().staticConstructor();
if (!hasAnnotationAndDeleteIfNeccessary(NonFinal.class, typeNode)) {
((JCClassDecl) typeNode.get()).mods.flags |= Flags.FINAL;
JCModifiers jcm = ((JCClassDecl) typeNode.get()).mods;
if ((jcm.flags & Flags.FINAL) == 0) {
jcm.flags |= Flags.FINAL;
typeNode.rebuild();
}
}
new HandleFieldDefaults().generateFieldDefaultsForType(typeNode, annotationNode, AccessLevel.PRIVATE, true, true);