use of org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO in project che by eclipse.
the class OpenLocationViewImpl method setLocations.
@Override
public void setLocations(List<LocationDTO> locations) {
tree.getNodeStorage().clear();
//TODO workaround, tree has bug with adding list of nodes
for (LocationDTO location : locations) {
tree.getNodeStorage().add(new LocationNode(location));
}
tree.expandAll();
if (!tree.getRootNodes().isEmpty()) {
tree.getSelectionModel().select(tree.getRootNodes().get(0), false);
}
}
use of org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO in project che by eclipse.
the class FindSymbolAction method toSymbolEntries.
private List<SymbolEntry> toSymbolEntries(List<SymbolInformationDTO> types, String value) {
List<SymbolEntry> result = new ArrayList<>();
for (SymbolInformationDTO element : types) {
if (!SUPPORTED_OPEN_TYPES.contains(symbolKindHelper.from(element.getKind()))) {
continue;
}
List<Match> matches = fuzzyMatches.fuzzyMatch(value, element.getName());
if (matches != null) {
LocationDTO location = element.getLocation();
if (location != null && location.getUri() != null) {
String filePath = location.getUri();
RangeDTO locationRange = location.getRange();
TextRange range = null;
if (locationRange != null) {
range = new TextRange(new TextPosition(locationRange.getStart().getLine(), locationRange.getStart().getCharacter()), new TextPosition(locationRange.getEnd().getLine(), locationRange.getEnd().getCharacter()));
}
result.add(new SymbolEntry(element.getName(), "", filePath, filePath, symbolKindHelper.from(element.getKind()), range, symbolKindHelper.getIcon(element.getKind()), editorHelper, matches));
}
}
}
//TODO add sorting
return result;
}
use of org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO in project che by eclipse.
the class FindDefinitionAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
TextEditor textEditor = ((TextEditor) activeEditor);
TextDocumentPositionParamsDTO paramsDTO = dtoBuildHelper.createTDPP(textEditor.getDocument(), textEditor.getCursorPosition());
final Promise<List<LocationDTO>> promise = client.definition(paramsDTO);
promise.then(new Operation<List<LocationDTO>>() {
@Override
public void apply(List<LocationDTO> arg) throws OperationException {
if (arg.size() == 1) {
presenter.onLocationSelected(arg.get(0));
} else {
presenter.openLocation(promise);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
presenter.showError(arg);
}
});
}
Aggregations