From 5763789a18b8b62a5b14cfb13d4302dd5856a1cf Mon Sep 17 00:00:00 2001 From: Shawn Hurley Date: Mon, 15 Jul 2024 13:51:48 -0400 Subject: [PATCH] :bug: remove static map, so that each symbol provider for a seach is new Signed-off-by: Shawn Hurley --- .../core/internal/SymbolInformationTypeRequestor.java | 5 ++++- .../tackle/core/internal/symbol/CustomASTVisitor.java | 8 ++++---- .../core/internal/symbol/SymbolProviderResolver.java | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SymbolInformationTypeRequestor.java b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SymbolInformationTypeRequestor.java index 291e201..7e35cc7 100644 --- a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SymbolInformationTypeRequestor.java +++ b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SymbolInformationTypeRequestor.java @@ -29,6 +29,8 @@ public class SymbolInformationTypeRequestor extends SearchRequestor { private IProgressMonitor monitor; private int symbolKind; private String query; + private SymbolProviderResolver resolver; + public SymbolInformationTypeRequestor(List symbols, int maxResults, IProgressMonitor monitor, int symbolKind, String query) { this.symbols = symbols; @@ -40,6 +42,7 @@ public SymbolInformationTypeRequestor(List symbols, int maxRe if (maxResults == 0) { this.maxResults = 10000; } + resolver = new SymbolProviderResolver(); } @@ -66,7 +69,7 @@ public void acceptSearchMatch(SearchMatch match) throws CoreException { } - SymbolProvider symbolProvider = SymbolProviderResolver.resolve(this.symbolKind, match); + SymbolProvider symbolProvider = resolver.resolve(this.symbolKind, match); if (symbolProvider instanceof WithQuery) { ((WithQuery) symbolProvider).setQuery(this.query); } 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 04327af..8d72307 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 @@ -99,7 +99,7 @@ public boolean visit(MethodInvocation node) { this.symbolMatches = true; return false; } catch (Exception e) { - logInfo("error visiting MethodInvocation node: " + e); + logInfo("KONEYOR_LOG: error visiting MethodInvocation node: " + e); // this is so that we fallback and don't lose a match when we fail this.symbolMatches = true; return false; @@ -122,7 +122,7 @@ public boolean visit(ConstructorInvocation node) { // get fqn of the method being called ITypeBinding declaringClass = binding.getDeclaringClass(); if (declaringClass != null) { - String fullyQualifiedName = declaringClass.getQualifiedName() + "." + binding.getName(); + String fullyQualifiedName = declaringClass.getQualifiedName(); // match fqn with query pattern if (fullyQualifiedName.matches(this.query)) { this.symbolMatches = true; @@ -139,7 +139,7 @@ public boolean visit(ConstructorInvocation node) { this.symbolMatches = true; return false; } catch (Exception e) { - logInfo("error visiting ConstructorInvocation node: " + e); + logInfo("KONVEYOR_LOG: error visiting ConstructorInvocation node: " + e); // this is so that we fallback and don't lose a match when we fail this.symbolMatches = true; return false; @@ -162,7 +162,7 @@ public boolean visit(ClassInstanceCreation node) { // get fqn of the method being called ITypeBinding declaringClass = binding.getDeclaringClass(); if (declaringClass != null) { - String fullyQualifiedName = declaringClass.getQualifiedName() + "." + binding.getName(); + String fullyQualifiedName = declaringClass.getQualifiedName(); // match fqn with query pattern if (fullyQualifiedName.matches(this.query)) { this.symbolMatches = true; diff --git a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/SymbolProviderResolver.java b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/SymbolProviderResolver.java index c208529..76585d6 100644 --- a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/SymbolProviderResolver.java +++ b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/SymbolProviderResolver.java @@ -7,8 +7,9 @@ import org.eclipse.jdt.core.search.SearchMatch; public class SymbolProviderResolver { - private static Map map; - static { + private Map map; + + public SymbolProviderResolver() { map = new HashMap<>(); map.put(1, new InheritanceSymbolProvider()); map.put(2, new MethodCallSymbolProvider()); @@ -23,7 +24,7 @@ public class SymbolProviderResolver { map.put(11, new ReferenceSymbolProvider()); } - public static SymbolProvider resolve(Integer i, SearchMatch SearchMatch) { - return Optional.ofNullable(map.get(i)).orElse(new DefaultSymbolProvider()); + public SymbolProvider resolve(Integer i, SearchMatch SearchMatch) { + return Optional.ofNullable(this.map.get(i)).orElse(new DefaultSymbolProvider()); } }