From de74997b2b0357490cd8a20ace02b8f45a000366 Mon Sep 17 00:00:00 2001 From: tsanders Date: Wed, 12 Nov 2025 22:21:19 -0500 Subject: [PATCH] fix: Strip parameter types from METHOD_CALL patterns Fixes konveyor/analyzer-lsp#854 When users specify METHOD_CALL patterns with parameter types like 'java.util.Properties.setProperty(java.lang.String, java.lang.String)', the CustomASTVisitor was failing to match these patterns because: 1. The AST resolves method names as 'ClassName.methodName' without parameter types 2. The query pattern still contained parameter types like '(Type1, Type2)' 3. The regex match would fail because of this mismatch This commit adds preprocessing in the CustomASTVisitor constructor to strip parameter types (everything within parentheses) from the query pattern before applying other transformations. This allows patterns with parameter types to match correctly against the AST-resolved method names. Example: - Input pattern: 'java.util.Properties.setProperty(java.lang.String, java.lang.String)' - Processed pattern: 'java.util.Properties.setProperty' - AST method name: 'java.util.Properties.setProperty' - Result: Match successful Signed-off-by: tsanders --- .../tackle/core/internal/symbol/CustomASTVisitor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/CustomASTVisitor.java b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/CustomASTVisitor.java index f53459e..1828e94 100644 --- a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/CustomASTVisitor.java +++ b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/CustomASTVisitor.java @@ -41,12 +41,20 @@ public enum QueryLocation { } public CustomASTVisitor(String query, SearchMatch match, QueryLocation location) { + /* + * Strip parameter types from the query pattern before matching + * The AST provides method names without parameter types, but users + * may specify patterns like "ClassName.method(ParamType1, ParamType2)" + * We need to remove the parameter types to match correctly + */ + String processedQuery = query.replaceAll("\\([^)]*\\)", ""); + /* * When comparing query pattern with an actual java element's fqn * we need to make sure that * not preceded with a . are replaced * by .* so that java regex works as expected on them */ - this.query = query.replaceAll("(?