-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Adding package search functionality (#62)
Signed-off-by: Shawn Hurley <[email protected]>
- Loading branch information
1 parent
6e1ec1c
commit ff460a2
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...e.core/src/main/java/io/konveyor/tackle/core/internal/symbol/ReferenceSymbolProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.konveyor.tackle.core.internal.symbol; | ||
|
||
import static org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.logInfo; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.jdt.core.IJavaElement; | ||
import org.eclipse.jdt.core.search.ReferenceMatch; | ||
import org.eclipse.jdt.core.search.SearchMatch; | ||
import org.eclipse.lsp4j.SymbolInformation; | ||
import org.eclipse.lsp4j.SymbolKind; | ||
|
||
public class ReferenceSymbolProvider implements SymbolProvider, WithQuery { | ||
private String query; | ||
|
||
@Override | ||
public List<SymbolInformation> get(SearchMatch match) { | ||
SymbolKind k = convertSymbolKind((IJavaElement) match.getElement()); | ||
List<SymbolInformation> symbols = new ArrayList<>(); | ||
// For Method Calls we will need to do the local variable trick | ||
try { | ||
ReferenceMatch m = (ReferenceMatch) match; | ||
|
||
IJavaElement e = (IJavaElement) m.getElement(); | ||
SymbolInformation symbol = new SymbolInformation(); | ||
symbol.setName(e.getElementName()); | ||
symbol.setKind(convertSymbolKind(e)); | ||
symbol.setContainerName(e.getParent().getElementName()); | ||
symbol.setLocation(getLocation(e, match)); | ||
symbols.add(symbol); | ||
} catch (Exception e) { | ||
logInfo("unable to convert for variable: " + e); | ||
} | ||
|
||
return symbols; | ||
} | ||
@Override | ||
public void setQuery(String query) { | ||
this.query = query; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters