aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/eclipse/EclipseNode.java9
-rw-r--r--src/core/lombok/javac/JavacNode.java8
-rw-r--r--test/core/src/lombok/LombokTestSource.java4
-rw-r--r--test/transform/resource/after-delombok/BuilderNestedInEnum.java70
-rw-r--r--test/transform/resource/after-ecj/BuilderNestedInEnum.java68
-rw-r--r--test/transform/resource/before/BuilderNestedInEnum.java12
-rw-r--r--website/usageExamples/ValueExample_pre.jpage4
7 files changed, 167 insertions, 8 deletions
diff --git a/src/core/lombok/eclipse/EclipseNode.java b/src/core/lombok/eclipse/EclipseNode.java
index 4f86f0a5..4950aeef 100644
--- a/src/core/lombok/eclipse/EclipseNode.java
+++ b/src/core/lombok/eclipse/EclipseNode.java
@@ -215,13 +215,16 @@ public class EclipseNode extends lombok.core.LombokNode<EclipseAST, EclipseNode,
@Override public boolean isStatic() {
if (node instanceof TypeDeclaration) {
+ TypeDeclaration t = (TypeDeclaration) node;
+ int f = t.modifiers;
+ if (((ClassFileConstants.AccInterface | ClassFileConstants.AccEnum) & f) != 0) return true;
+
EclipseNode directUp = directUp();
if (directUp == null || directUp.getKind() == Kind.COMPILATION_UNIT) return true;
if (!(directUp.get() instanceof TypeDeclaration)) return false;
TypeDeclaration p = (TypeDeclaration) directUp.get();
- int f = p.modifiers;
- if ((ClassFileConstants.AccInterface & f) != 0) return true;
- if ((ClassFileConstants.AccEnum & f) != 0) return true;
+ f = p.modifiers;
+ if (((ClassFileConstants.AccInterface | ClassFileConstants.AccEnum) & f) != 0) return true;
}
if (node instanceof FieldDeclaration) {
diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java
index 035f7c53..fca0d0d1 100644
--- a/src/core/lombok/javac/JavacNode.java
+++ b/src/core/lombok/javac/JavacNode.java
@@ -286,13 +286,15 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre
@Override public boolean isStatic() {
if (node instanceof JCClassDecl) {
+ JCClassDecl t = (JCClassDecl) node;
+ long f = t.mods.flags;
+ if (((Flags.INTERFACE | Flags.ENUM) & f) != 0) return true;
JavacNode directUp = directUp();
if (directUp == null || directUp.getKind() == Kind.COMPILATION_UNIT) return true;
if (!(directUp.get() instanceof JCClassDecl)) return false;
JCClassDecl p = (JCClassDecl) directUp.get();
- long f = p.mods.flags;
- if ((Flags.INTERFACE & f) != 0) return true;
- if ((Flags.ENUM & f) != 0) return true;
+ f = p.mods.flags;
+ if (((Flags.INTERFACE | Flags.ENUM) & f) != 0) return true;
}
if (node instanceof JCVariableDecl) {
diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java
index 0326dee9..27ffc31a 100644
--- a/test/core/src/lombok/LombokTestSource.java
+++ b/test/core/src/lombok/LombokTestSource.java
@@ -161,6 +161,7 @@ public class LombokTestSource {
private static final Pattern UNCHANGED_PATTERN = Pattern.compile("^\\s*unchanged\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
private static final Pattern SKIP_COMPARE_CONTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?compare[- ]?contents?\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
private static final Pattern SKIP_IDEMPOTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?idempotent\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
+ private static final Pattern ISSUE_REF_PATTERN = Pattern.compile("^\\s*issue #?\\d+(:?\\s+.*)?$", Pattern.CASE_INSENSITIVE);
private LombokTestSource(File file, String content, List<CompilerMessageMatcher> messages, List<String> directives) {
this.file = file;
@@ -200,6 +201,9 @@ public class LombokTestSource {
skipIdempotent = true;
continue;
}
+ if (ISSUE_REF_PATTERN.matcher(directive).matches()) {
+ continue;
+ }
if (lc.startsWith("platform ")) {
String platformDesc = lc.substring("platform ".length());
diff --git a/test/transform/resource/after-delombok/BuilderNestedInEnum.java b/test/transform/resource/after-delombok/BuilderNestedInEnum.java
new file mode 100644
index 00000000..26dc2a06
--- /dev/null
+++ b/test/transform/resource/after-delombok/BuilderNestedInEnum.java
@@ -0,0 +1,70 @@
+class BuilderNestedInEnum {
+ public enum TestEnum {
+ FOO, BAR;
+ public static final class TestBuilder {
+ private final String field;
+ @java.lang.SuppressWarnings("all")
+ TestBuilder(final String field) {
+ this.field = field;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static class TestBuilderBuilder {
+ @java.lang.SuppressWarnings("all")
+ private String field;
+ @java.lang.SuppressWarnings("all")
+ TestBuilderBuilder() {
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public BuilderNestedInEnum.TestEnum.TestBuilder.TestBuilderBuilder field(final String field) {
+ this.field = field;
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ public BuilderNestedInEnum.TestEnum.TestBuilder build() {
+ return new BuilderNestedInEnum.TestEnum.TestBuilder(this.field);
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "BuilderNestedInEnum.TestEnum.TestBuilder.TestBuilderBuilder(field=" + this.field + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ public static BuilderNestedInEnum.TestEnum.TestBuilder.TestBuilderBuilder builder() {
+ return new BuilderNestedInEnum.TestEnum.TestBuilder.TestBuilderBuilder();
+ }
+ @java.lang.SuppressWarnings("all")
+ public String getField() {
+ return this.field;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof BuilderNestedInEnum.TestEnum.TestBuilder)) return false;
+ final BuilderNestedInEnum.TestEnum.TestBuilder other = (BuilderNestedInEnum.TestEnum.TestBuilder) o;
+ final java.lang.Object this$field = this.getField();
+ final java.lang.Object other$field = other.getField();
+ if (this$field == null ? other$field != null : !this$field.equals(other$field)) return false;
+ return true;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $field = this.getField();
+ result = result * PRIME + ($field == null ? 43 : $field.hashCode());
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "BuilderNestedInEnum.TestEnum.TestBuilder(field=" + this.getField() + ")";
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/BuilderNestedInEnum.java b/test/transform/resource/after-ecj/BuilderNestedInEnum.java
new file mode 100644
index 00000000..b3fb54f3
--- /dev/null
+++ b/test/transform/resource/after-ecj/BuilderNestedInEnum.java
@@ -0,0 +1,68 @@
+class BuilderNestedInEnum {
+ public enum TestEnum {
+ public static final @lombok.Builder @lombok.Value class TestBuilder {
+ public static @java.lang.SuppressWarnings("all") class TestBuilderBuilder {
+ private @java.lang.SuppressWarnings("all") String field;
+ @java.lang.SuppressWarnings("all") TestBuilderBuilder() {
+ super();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") BuilderNestedInEnum.TestEnum.TestBuilder.TestBuilderBuilder field(final String field) {
+ this.field = field;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") BuilderNestedInEnum.TestEnum.TestBuilder build() {
+ return new BuilderNestedInEnum.TestEnum.TestBuilder(this.field);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("BuilderNestedInEnum.TestEnum.TestBuilder.TestBuilderBuilder(field=" + this.field) + ")");
+ }
+ }
+ private final String field;
+ @java.lang.SuppressWarnings("all") TestBuilder(final String field) {
+ super();
+ this.field = field;
+ }
+ public static @java.lang.SuppressWarnings("all") BuilderNestedInEnum.TestEnum.TestBuilder.TestBuilderBuilder builder() {
+ return new BuilderNestedInEnum.TestEnum.TestBuilder.TestBuilderBuilder();
+ }
+ public @java.lang.SuppressWarnings("all") String getField() {
+ return this.field;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof BuilderNestedInEnum.TestEnum.TestBuilder)))
+ return false;
+ final BuilderNestedInEnum.TestEnum.TestBuilder other = (BuilderNestedInEnum.TestEnum.TestBuilder) o;
+ final java.lang.Object this$field = this.getField();
+ final java.lang.Object other$field = other.getField();
+ if (((this$field == null) ? (other$field != null) : (! this$field.equals(other$field))))
+ return false;
+ return true;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $field = this.getField();
+ result = ((result * PRIME) + (($field == null) ? 43 : $field.hashCode()));
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("BuilderNestedInEnum.TestEnum.TestBuilder(field=" + this.getField()) + ")");
+ }
+ }
+ FOO(),
+ BAR(),
+ <clinit>() {
+ }
+ public TestEnum() {
+ super();
+ }
+ }
+ BuilderNestedInEnum() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/BuilderNestedInEnum.java b/test/transform/resource/before/BuilderNestedInEnum.java
new file mode 100644
index 00000000..99348002
--- /dev/null
+++ b/test/transform/resource/before/BuilderNestedInEnum.java
@@ -0,0 +1,12 @@
+// issue #3014: Builder check if its on a non-static inner class and errors if it is. But it was erroring here even though it is on a static inner class.
+class BuilderNestedInEnum {
+ public enum TestEnum {
+ FOO, BAR;
+
+ @lombok.Builder
+ @lombok.Value
+ public static class TestBuilder {
+ String field;
+ }
+ }
+} \ No newline at end of file
diff --git a/website/usageExamples/ValueExample_pre.jpage b/website/usageExamples/ValueExample_pre.jpage
index d9550c25..27b28eb7 100644
--- a/website/usageExamples/ValueExample_pre.jpage
+++ b/website/usageExamples/ValueExample_pre.jpage
@@ -1,12 +1,12 @@
import lombok.AccessLevel;
import lombok.experimental.NonFinal;
import lombok.experimental.Value;
-import lombok.experimental.Wither;
+import lombok.experimental.With;
import lombok.ToString;
@Value public class ValueExample {
String name;
- @Wither(AccessLevel.PACKAGE) @NonFinal int age;
+ @With(AccessLevel.PACKAGE) @NonFinal int age;
double score;
protected String[] tags;