diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-10-17 15:32:29 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-10-17 15:35:05 +0200 |
commit | 56616f3bec6d8eda8c2bcf0550490f0098fb7fed (patch) | |
tree | 224718bcdf3855508843ceca56fd60deb95b52f2 | |
parent | 4bf8ee3f67f7c076421b6c6a396c85e7bd794749 (diff) | |
download | lombok-56616f3bec6d8eda8c2bcf0550490f0098fb7fed.tar.gz lombok-56616f3bec6d8eda8c2bcf0550490f0098fb7fed.tar.bz2 lombok-56616f3bec6d8eda8c2bcf0550490f0098fb7fed.zip |
Fix: getters and setters for $foo fields (including our own $lock!) are now no longer generated.
-rw-r--r-- | src/lombok/eclipse/handlers/HandleData.java | 2 | ||||
-rw-r--r-- | src/lombok/javac/handlers/HandleData.java | 4 | ||||
-rw-r--r-- | website/features/Data.html | 3 |
3 files changed, 7 insertions, 2 deletions
diff --git a/src/lombok/eclipse/handlers/HandleData.java b/src/lombok/eclipse/handlers/HandleData.java index 555b311f..22538a53 100644 --- a/src/lombok/eclipse/handlers/HandleData.java +++ b/src/lombok/eclipse/handlers/HandleData.java @@ -87,6 +87,8 @@ public class HandleData implements EclipseAnnotationHandler<Data> { for (EclipseNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; FieldDeclaration fieldDecl = (FieldDeclaration) child.get(); + //Skip fields that start with $ + if (fieldDecl.name.length > 0 && fieldDecl.name[0] == '$') continue; //Skip static fields. if ((fieldDecl.modifiers & ClassFileConstants.AccStatic) != 0) continue; boolean isFinal = (fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0; diff --git a/src/lombok/javac/handlers/HandleData.java b/src/lombok/javac/handlers/HandleData.java index 8aa744c7..8d80808f 100644 --- a/src/lombok/javac/handlers/HandleData.java +++ b/src/lombok/javac/handlers/HandleData.java @@ -70,15 +70,15 @@ public class HandleData implements JavacAnnotationHandler<Data> { return false; } - List<JavacNode> nodesForEquality = List.nil(); List<JavacNode> nodesForConstructor = List.nil(); for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; JCVariableDecl fieldDecl = (JCVariableDecl) child.get(); + //Skip fields that start with $ + if (fieldDecl.name.toString().startsWith("$")) continue; long fieldFlags = fieldDecl.mods.flags; //Skip static fields. if ((fieldFlags & Flags.STATIC) != 0) continue; - if ((fieldFlags & Flags.TRANSIENT) == 0) nodesForEquality = nodesForEquality.append(child); boolean isFinal = (fieldFlags & Flags.FINAL) != 0; boolean isNonNull = !findAnnotations(child, TransformationsUtil.NON_NULL_PATTERN).isEmpty(); if ((isFinal || isNonNull) && fieldDecl.init == null) nodesForConstructor = nodesForConstructor.append(child); diff --git a/website/features/Data.html b/website/features/Data.html index 2689a124..8e33be8f 100644 --- a/website/features/Data.html +++ b/website/features/Data.html @@ -69,6 +69,9 @@ <em>null</em>. Therefore, these annotations result in an explicit null check in the generated constructor for the provided field. Also, these annotations (as well as any annotation named <code>@Nullable</code>) are copied to the constructor parameter, in both the true constructor and any static constructor. The same principle applies to generated getters and setters (see the documentation for <a href="GetterSetter.html">@Getter / @Setter</a>) + </p><p> + By default, any variables that start with a $ symbol are excluded automatically. + You can include them by specifying an explicit annotation (<code>@Getter</code> or <code>@ToString</code>, for example) and using the 'of' parameter. </p> </div> </div> |