Search in sources :

Example 1 with LocationDTO

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);
    }
}
Also used : LocationDTO(org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO)

Example 2 with LocationDTO

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;
}
Also used : SymbolInformationDTO(org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) ArrayList(java.util.ArrayList) TextRange(org.eclipse.che.ide.api.editor.text.TextRange) LocationDTO(org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO) RangeDTO(org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO) Match(org.eclipse.che.plugin.languageserver.ide.filters.Match)

Example 3 with LocationDTO

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);
        }
    });
}
Also used : TextDocumentPositionParamsDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) Operation(org.eclipse.che.api.promises.client.Operation) LocationDTO(org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

LocationDTO (org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO)3 ArrayList (java.util.ArrayList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 RangeDTO (org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO)1 SymbolInformationDTO (org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO)1 TextDocumentPositionParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 TextPosition (org.eclipse.che.ide.api.editor.text.TextPosition)1 TextRange (org.eclipse.che.ide.api.editor.text.TextRange)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 Match (org.eclipse.che.plugin.languageserver.ide.filters.Match)1