diff --git a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SampleDelegateCommandHandler.java b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SampleDelegateCommandHandler.java index 4da3d45..1fd3f48 100644 --- a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SampleDelegateCommandHandler.java +++ b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SampleDelegateCommandHandler.java @@ -104,28 +104,31 @@ private static SearchPattern mapLocationToSearchPatternLocation(int location, St } private static SearchPattern getPatternSingleQuery(int location, String query) throws Exception { + var pattern = SearchPattern.R_PATTERN_MATCH; + if ((!query.contains("?") || !query.contains("*")) && (location != 11)) { + logInfo("Using full match"); + pattern = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE; + } switch (location) { // Using type for both type and annotation. // Type and annotation case 10: case 4: - return SearchPattern.createPattern(query, IJavaSearchConstants.TYPE, IJavaSearchConstants.ALL_OCCURRENCES, SearchPattern.R_PATTERN_MATCH); + case 8: + return SearchPattern.createPattern(query, IJavaSearchConstants.TYPE, IJavaSearchConstants.ALL_OCCURRENCES, pattern); case 5: case 1: - return SearchPattern.createPattern(query, IJavaSearchConstants.TYPE, IJavaSearchConstants.IMPLEMENTORS, SearchPattern.R_PATTERN_MATCH); + return SearchPattern.createPattern(query, IJavaSearchConstants.TYPE, IJavaSearchConstants.IMPLEMENTORS, pattern); + case 7: + case 9: + return SearchPattern.createPattern(query, IJavaSearchConstants.TYPE, IJavaSearchConstants.REFERENCES, pattern); case 2: // Switched back to referenced return SearchPattern.createPattern(query, IJavaSearchConstants.METHOD, IJavaSearchConstants.REFERENCES, SearchPattern.R_PATTERN_MATCH | SearchPattern.R_ERASURE_MATCH); case 3: - return SearchPattern.createPattern(query, IJavaSearchConstants.CONSTRUCTOR, IJavaSearchConstants.ALL_OCCURRENCES, SearchPattern.R_PATTERN_MATCH); - case 7: - return SearchPattern.createPattern(query, IJavaSearchConstants.TYPE, IJavaSearchConstants.REFERENCES, SearchPattern.R_PATTERN_MATCH); - case 8: - return SearchPattern.createPattern(query, IJavaSearchConstants.TYPE, IJavaSearchConstants.ALL_OCCURRENCES, SearchPattern.R_PATTERN_MATCH); - case 9: - return SearchPattern.createPattern(query, IJavaSearchConstants.TYPE, IJavaSearchConstants.REFERENCES, SearchPattern.R_PATTERN_MATCH); + return SearchPattern.createPattern(query, IJavaSearchConstants.CONSTRUCTOR, IJavaSearchConstants.ALL_OCCURRENCES, pattern); case 11: - return SearchPattern.createPattern(query, IJavaSearchConstants.PACKAGE, IJavaSearchConstants.ALL_OCCURRENCES, SearchPattern.R_PATTERN_MATCH); + return SearchPattern.createPattern(query, IJavaSearchConstants.PACKAGE, IJavaSearchConstants.ALL_OCCURRENCES, pattern); } throw new Exception("unable to create search pattern"); } 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 c43ca5a..b34bf24 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 @@ -9,6 +9,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.search.SearchMatch; import org.eclipse.jdt.core.search.SearchRequestor; import org.eclipse.lsp4j.SymbolInformation; @@ -53,6 +54,23 @@ public void acceptSearchMatch(SearchMatch match) throws CoreException { return; } + if ((!this.query.contains("?") && !this.query.contains("*")) && match.getAccuracy() == SearchMatch.A_INACCURATE) { + var e = (IJavaElement) match.getElement(); + //TODO: This is a hack, this will give use some clue of what we are looking at, if the search is exact then this should match + // I don't love this, but seems to be the right way + logInfo("attempting: " + e.getHandleIdentifier()); + if (!e.getHandleIdentifier().contains(query)) { + logInfo("exact match is looking for accurate results" + match); + return; + } + } + + if ((this.query.contains("?") && (this.query.contains("(") || this.query.contains(")"))) && match.getAccuracy() == SearchMatch.A_INACCURATE) { + if(!this.query.contains("*")) { + logInfo("exact match is looking for accurate results " + match); + return; + } + } SymbolProvider symbolProvider = SymbolProviderResolver.resolve(this.symbolKind, match); if (symbolProvider instanceof WithQuery) {