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 996ec03..8d30c30 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 @@ -4,11 +4,7 @@ import static org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.logInfo; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.Map; -import java.util.HashMap; -import java.io.File; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -16,7 +12,6 @@ import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; @@ -162,18 +157,20 @@ private static List search(String projectName, ArrayList search(String projectName, ArrayList search(String projectName, ArrayList symbols; private int maxResults; + private int numberSearchMatches; private boolean sourceOnly; private boolean isSymbolTagSupported; private IProgressMonitor monitor; @@ -35,6 +36,7 @@ public SymbolInformationTypeRequestor(List symbols, int maxRe this.monitor = monitor; this.symbolKind = symbolKind; this.query = query; + this.numberSearchMatches = 0; if (maxResults == 0) { this.maxResults = 10000; } @@ -43,6 +45,7 @@ public SymbolInformationTypeRequestor(List symbols, int maxRe @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { + this.numberSearchMatches = this.numberSearchMatches + 1; if (maxResults > 0 && symbols.size() >= maxResults) { monitor.setCanceled(true); logInfo("maxResults > 0 && symbols.size() >= maxResults"); @@ -80,6 +83,10 @@ public List getSymbols() { return this.symbols; } + public int getAllSearchMatches() { + return this.numberSearchMatches; + } + // This will determine if there are error markers for the primary element that is associated with this // element. This then will tell us if there is a reason that some results may be inaccurrate. // TODO: We still need for each provider, to actually determine if it is a match when 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 33568b4..04327af 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 @@ -1,16 +1,16 @@ package io.konveyor.tackle.core.internal.symbol; +import static org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.logInfo; + +import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ASTVisitor; import org.eclipse.jdt.core.dom.ClassInstanceCreation; import org.eclipse.jdt.core.dom.ConstructorInvocation; -import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.IMethodBinding; import org.eclipse.jdt.core.dom.ITypeBinding; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.search.SearchMatch; -import static org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.logInfo; - /* * SearchEngine we use often gives us more matches than needed when * query contains a * and/or contains a fqn. e.g. java.io.paths.get* @@ -78,6 +78,10 @@ public boolean visit(MethodInvocation node) { // get fqn of the method being called ITypeBinding declaringClass = binding.getDeclaringClass(); if (declaringClass != null) { + // Handle Erasure results + if (declaringClass.getErasure() != null) { + declaringClass = declaringClass.getErasure(); + } String fullyQualifiedName = declaringClass.getQualifiedName() + "." + binding.getName(); // match fqn with query pattern if (fullyQualifiedName.matches(this.query)) { diff --git a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/SymbolProvider.java b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/SymbolProvider.java index f69ad34..7ebb0e9 100644 --- a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/SymbolProvider.java +++ b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/SymbolProvider.java @@ -188,6 +188,13 @@ default boolean queryQualificationMatches(String query, ICompilationUnit unit, L // for a query, java.io.paths.File*, queryQualification is java.io.paths queryQualification = query.substring(0, dotIndex); } + String packageQueryQualification = ""; + int packageDotIndex = queryQualification.lastIndexOf('.'); + if (packageDotIndex > 0) { + // for a query, java.io.paths.File*, queryQualification is java.io.paths + packageQueryQualification = queryQualification.substring(0, packageDotIndex); + } + // check if the match was found in the same package as the query was looking for if (queryQualification != "" && location.getUri().contains(queryQualification.replaceAll(".", "/"))) { return true; @@ -196,7 +203,7 @@ default boolean queryQualificationMatches(String query, ICompilationUnit unit, L try { // check if the package declaration on the unit matches query for (IPackageDeclaration packageDecl : unit.getPackageDeclarations()) { - if (queryQualification != "" && packageDecl.getElementName().matches(queryQualification)) { + if (packageQueryQualification!= "" && packageDecl.getElementName().matches(packageQueryQualification)) { return true; } }