Skip to content

Commit

Permalink
🐛 handle when a default search will have invalid query for a particul…
Browse files Browse the repository at this point in the history
…ar location (#105)

Signed-off-by: Shawn Hurley <shawn@hurley.page>
  • Loading branch information
shawn-hurley committed Jul 22, 2024
1 parent f1fc8a3 commit 90c6314
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.List;
import java.util.regex.Pattern;

import io.konveyor.tackle.core.internal.query.AnnotationQuery;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
Expand All @@ -26,6 +25,8 @@
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
import org.eclipse.lsp4j.SymbolInformation;

import io.konveyor.tackle.core.internal.query.AnnotationQuery;

public class SampleDelegateCommandHandler implements IDelegateCommandHandler {

public static final String COMMAND_ID = "io.konveyor.tackle.samplecommand";
Expand Down Expand Up @@ -96,15 +97,25 @@ private static SearchPattern mapLocationToSearchPatternLocation(int location, St
}

if (location == 0) {
logInfo("default query passed, searching everything");
logInfo("default query passed " + query + ", searching everything");
ArrayList<SearchPattern> l = new ArrayList<SearchPattern>();
// Searching for Type, Method, and Constructor's.
l.add(getPatternSingleQuery(10, query));
l.add(getPatternSingleQuery(2, query));
l.add(getPatternSingleQuery(3, query));

var p = getPatternSingleQuery(10, query);
if (p != null) {
l.add(p);
}
p = getPatternSingleQuery(2, query);
if (p != null) {
l.add(p);
}
p = getPatternSingleQuery(3, query);
if (p != null) {
l.add(p);
}
logInfo("list of p: " + p);

// Get the end pattern
SearchPattern p = l.subList(1, l.size()).stream().reduce(l.get(0), (SearchPattern::createOrPattern));
p = l.subList(1, l.size()).stream().reduce(l.get(0), (SearchPattern::createOrPattern));
return p;
}

Expand Down

0 comments on commit 90c6314

Please sign in to comment.