Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 adding log for counting search matches found #102

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@
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;
import org.eclipse.core.runtime.Path;
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;
Expand Down Expand Up @@ -243,6 +238,8 @@ private static List<SymbolInformation> search(String projectName, ArrayList<Stri
logInfo("unable to get search " + e);
}

logInfo("got: " + requestor.getAllSearchMatches() + " search matches for " + query + " location " + location);

return requestor.getSymbols();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
public class SymbolInformationTypeRequestor extends SearchRequestor {
private List<SymbolInformation> symbols;
private int maxResults;
private int numberSearchMatches;
private boolean sourceOnly;
private boolean isSymbolTagSupported;
private IProgressMonitor monitor;
Expand All @@ -35,6 +36,7 @@ public SymbolInformationTypeRequestor(List<SymbolInformation> symbols, int maxRe
this.monitor = monitor;
this.symbolKind = symbolKind;
this.query = query;
this.numberSearchMatches = 0;
if (maxResults == 0) {
this.maxResults = 10000;
}
Expand All @@ -43,6 +45,7 @@ public SymbolInformationTypeRequestor(List<SymbolInformation> 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");
Expand Down Expand Up @@ -80,6 +83,10 @@ public List<SymbolInformation> 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
Expand Down
Loading