diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2022-03-13 12:55:53 +0100 |
---|---|---|
committer | Rawi01 <Rawi01@users.noreply.github.com> | 2022-03-13 12:55:53 +0100 |
commit | 017df4c72a755707366bfb6271e2df46a76f3aa4 (patch) | |
tree | 6a855581a4060d6aa34c1d1b76015459996f8bcb /src/eclipseAgent | |
parent | 8c3ff7e9b08c4bf9c2b23cffb6042c31258e3ebb (diff) | |
download | lombok-017df4c72a755707366bfb6271e2df46a76f3aa4.tar.gz lombok-017df4c72a755707366bfb6271e2df46a76f3aa4.tar.bz2 lombok-017df4c72a755707366bfb6271e2df46a76f3aa4.zip |
[fixes #3134] Search patched method also by parameters
Diffstat (limited to 'src/eclipseAgent')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 8 | ||||
-rwxr-xr-x | src/eclipseAgent/lombok/launch/PatchFixesHider.java | 17 |
2 files changed, 24 insertions, 1 deletions
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; |