diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2023-03-20 21:46:25 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2023-03-22 22:57:52 +0100 |
commit | afceb138e6e4ca2dca0f16fd5297d7451f5f4e80 (patch) | |
tree | ea8d5ddd944809b92f9a9ed857da90c00b521ac7 /src/eclipseAgent/lombok/eclipse/agent | |
parent | d56b576c26d6e6a0621997a9758151cf41e7a74e (diff) | |
download | lombok-afceb138e6e4ca2dca0f16fd5297d7451f5f4e80.tar.gz lombok-afceb138e6e4ca2dca0f16fd5297d7451f5f4e80.tar.bz2 lombok-afceb138e6e4ca2dca0f16fd5297d7451f5f4e80.zip |
[fixes #3373] Find references for extension methods
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 7 | ||||
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index c0bfbe09..aa548af0 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -918,6 +918,13 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .request(StackRequest.THIS) .wrapMethod(new Hook(PATCH_EXTENSIONMETHOD_COMPLETIONPROPOSAL_PORTAL, "getJavaCompletionProposals", I_JAVA_COMPLETION_PROPOSAL_SIG, "java.lang.Object[]", "java.lang.Object")) .build()); + + sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue() + .target(new MethodTarget("org.eclipse.jdt.core.search.SearchPattern", "createPattern", "org.eclipse.jdt.core.search.SearchPattern", "org.eclipse.jdt.core.IJavaElement", "int", "int")) + .wrapMethod(new Hook(PATCH_EXTENSIONMETHOD, "modifyMethodPattern", "java.lang.Object", "java.lang.Object")) + .cast() + .request(StackRequest.RETURN_VALUE) + .build()); } private static void patchNullCheck(ScriptManager sm) { diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java index 7743f9c6..9b2bde60 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java @@ -43,6 +43,7 @@ import lombok.eclipse.handlers.EclipseHandlerUtil; import lombok.experimental.ExtensionMethod; import lombok.permit.Permit; +import org.eclipse.jdt.core.search.SearchPattern; import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; @@ -66,6 +67,7 @@ import org.eclipse.jdt.internal.compiler.lookup.Scope; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; +import org.eclipse.jdt.internal.core.search.matching.MethodPattern; public class PatchExtensionMethod { static class Extension { @@ -378,6 +380,17 @@ public class PatchExtensionMethod { MessageSend_postponedErrors.clear(methodCall); return resolvedType; } + + public static SearchPattern modifyMethodPattern(SearchPattern original) { + if (original != null && original instanceof MethodPattern) { + MethodPattern methodPattern = (MethodPattern) original; + if (methodPattern.parameterCount > 0) { + methodPattern.varargs = true; + } + } + + return original; + } private static boolean requiresPolyBinding(Expression argument) { return Reflection.isFunctionalExpression(argument) || argument instanceof ConditionalExpression && Reflection.isPolyExpression(argument); |