aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java10
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleConstructor.java9
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java5
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java10
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java8
-rwxr-xr-xsrc/eclipseAgent/lombok/launch/PatchFixesHider.java17
-rw-r--r--src/utils/lombok/eclipse/Eclipse.java1
7 files changed, 41 insertions, 19 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index c313cf51..93b0028d 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -2770,15 +2770,7 @@ public class EclipseHandlerUtil {
* Returns {@code true} if the provided node supports static methods and types (top level or static class)
*/
public static boolean isStaticAllowed(EclipseNode typeNode) {
- boolean staticAllowed = true;
-
- while (typeNode.getKind() != Kind.COMPILATION_UNIT) {
- if (!staticAllowed) return false;
-
- staticAllowed = typeNode.isStatic();
- typeNode = typeNode.up();
- }
- return true;
+ return typeNode.isStatic() || typeNode.up() == null || typeNode.up().getKind() == Kind.COMPILATION_UNIT || isRecord(typeNode);
}
public static AbstractVariableDeclaration[] getRecordComponents(TypeDeclaration typeDeclaration) {
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index e69c3267..52213846 100755
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -41,6 +41,7 @@ import lombok.RequiredArgsConstructor;
import lombok.core.AST.Kind;
import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.AnnotationValues;
+import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
@@ -414,6 +415,10 @@ public class HandleConstructor {
if (nullCheck != null) nullChecks.add(nullCheck);
}
parameter.annotations = copyAnnotations(source, copyableAnnotations);
+ if (parameter.annotations != null) {
+ parameter.bits |= Eclipse.HasTypeAnnotations;
+ constructor.bits |= Eclipse.HasTypeAnnotations;
+ }
params.add(parameter);
}
@@ -555,6 +560,10 @@ public class HandleConstructor {
Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL);
parameter.annotations = copyAnnotations(source, findCopyableAnnotations(fieldNode));
+ if (parameter.annotations != null) {
+ parameter.bits |= Eclipse.HasTypeAnnotations;
+ constructor.bits |= Eclipse.HasTypeAnnotations;
+ }
params.add(parameter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index fda1651d..f09f1485 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -35,6 +35,7 @@ import lombok.ConfigurationKeys;
import lombok.Setter;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
+import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.Accessors;
@@ -256,6 +257,10 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
}
method.statements = statements.toArray(new Statement[0]);
param.annotations = copyAnnotations(source, copyableAnnotations, onParam.toArray(new Annotation[0]));
+ if (param.annotations != null) {
+ param.bits |= Eclipse.HasTypeAnnotations;
+ method.bits |= Eclipse.HasTypeAnnotations;
+ }
if (returnType != null && returnStatement != null) createRelevantNonNullAnnotation(sourceNode, method);
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 53a518b4..b17e34d8 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -2096,15 +2096,7 @@ public class JavacHandlerUtil {
* Returns {@code true} if the provided node supports static methods and types (top level or static class)
*/
public static boolean isStaticAllowed(JavacNode typeNode) {
- boolean staticAllowed = true;
-
- while (typeNode.getKind() != Kind.COMPILATION_UNIT) {
- if (!staticAllowed) return false;
-
- staticAllowed = typeNode.isStatic();
- typeNode = typeNode.up();
- }
- return true;
+ return typeNode.isStatic() || typeNode.up() == null || typeNode.up().getKind() == Kind.COMPILATION_UNIT || isRecord(typeNode);
}
public static JavacNode upToTypeNode(JavacNode node) {
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index 2e35cf57..d893b724 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -332,12 +332,18 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
private static void patchHideGeneratedNodes(ScriptManager sm) {
sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
- .target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode"))
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode", "org.eclipse.jdt.core.dom.SimpleName[]", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.core.dom.SimpleName"))
.target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByBinding"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedSimpleNames", "org.eclipse.jdt.core.dom.SimpleName[]",
"org.eclipse.jdt.core.dom.SimpleName[]"))
.request(StackRequest.RETURN_VALUE).build());
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode", "org.eclipse.jdt.core.dom.Name[]", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.core.dom.Name"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNames", "org.eclipse.jdt.core.dom.Name[]",
+ "org.eclipse.jdt.core.dom.Name[]"))
+ .request(StackRequest.RETURN_VALUE).build());
+
sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTNode", "accept", "void", "org.eclipse.jdt.core.dom.ASTVisitor"))
.decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isBlockedVisitorAndGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.core.dom.ASTVisitor"))
diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
index e0c330a2..a844239f 100755
--- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java
+++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
@@ -39,6 +39,7 @@ import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.Type;
@@ -780,6 +781,22 @@ final class PatchFixesHider {
return newSimpleNames;
}
+ public static Name[] removeGeneratedNames(Name[] in) throws Exception {
+ Field f = Name.class.getField("$isGenerated");
+
+ int count = 0;
+ for (int i = 0; i < in.length; i++) {
+ if (in[i] == null || !((Boolean)f.get(in[i])).booleanValue()) count++;
+ }
+ if (count == in.length) return in;
+ Name[] newNames = new Name[count];
+ count = 0;
+ for (int i = 0; i < in.length; i++) {
+ if (in[i] == null || !((Boolean)f.get(in[i])).booleanValue()) newNames[count++] = in[i];
+ }
+ return newNames;
+ }
+
public static Annotation[] convertAnnotations(Annotation[] out, IAnnotatable annotatable) {
IAnnotation[] in;
diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java
index 0f42ddc6..624e521a 100644
--- a/src/utils/lombok/eclipse/Eclipse.java
+++ b/src/utils/lombok/eclipse/Eclipse.java
@@ -66,6 +66,7 @@ public class Eclipse {
public static final int AccRecord = ASTNode.Bit25; // ECM.AccRecord
public static final int IsCanonicalConstructor = ASTNode.Bit10; // ASTNode.IsCanonicalConstructor
public static final int IsImplicit = ASTNode.Bit11; // ASTNode.IsImplicit
+ public static final int HasTypeAnnotations = ASTNode.Bit21; // ASTNode.HasTypeAnnotations
private static final Pattern SPLIT_AT_DOT = Pattern.compile("\\.");