Search in sources :

Example 6 with TextDocumentIdentifierDTO

use of org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO in project che by eclipse.

the class DtoBuildHelper method createTDPP.

public TextDocumentPositionParamsDTO createTDPP(Document document, int cursorOffset) {
    TextDocumentPositionParamsDTO paramsDTO = dtoFactory.createDto(TextDocumentPositionParamsDTO.class);
    TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
    identifierDTO.setUri(document.getFile().getLocation().toString());
    PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class);
    TextPosition position = document.getPositionFromIndex(cursorOffset);
    positionDTO.setCharacter(position.getCharacter());
    positionDTO.setLine(position.getLine());
    paramsDTO.setUri(document.getFile().getLocation().toString());
    paramsDTO.setTextDocument(identifierDTO);
    paramsDTO.setPosition(positionDTO);
    return paramsDTO;
}
Also used : TextDocumentPositionParamsDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO) TextDocumentIdentifierDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) PositionDTO(org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO)

Example 7 with TextDocumentIdentifierDTO

use of org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO in project che by eclipse.

the class FindReferencesAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    //TODO replace this
    if (!(activeEditor instanceof TextEditor)) {
        return;
    }
    TextEditor textEditor = ((TextEditor) activeEditor);
    String path = activeEditor.getEditorInput().getFile().getLocation().toString();
    ReferenceParamsDTO paramsDTO = dtoFactory.createDto(ReferenceParamsDTO.class);
    PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class);
    positionDTO.setLine(textEditor.getCursorPosition().getLine());
    positionDTO.setCharacter(textEditor.getCursorPosition().getCharacter());
    TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
    identifierDTO.setUri(path);
    ReferenceContextDTO contextDTO = dtoFactory.createDto(ReferenceContextDTO.class);
    contextDTO.setIncludeDeclaration(true);
    paramsDTO.setUri(path);
    paramsDTO.setPosition(positionDTO);
    paramsDTO.setTextDocument(identifierDTO);
    paramsDTO.setContext(contextDTO);
    Promise<List<LocationDTO>> promise = client.references(paramsDTO);
    presenter.openLocation(promise);
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) ReferenceContextDTO(org.eclipse.che.api.languageserver.shared.lsapi.ReferenceContextDTO) TextDocumentIdentifierDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO) ReferenceParamsDTO(org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) PositionDTO(org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO)

Aggregations

TextDocumentIdentifierDTO (org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO)7 List (java.util.List)4 PositionDTO (org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO)4 TextDocumentPositionParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO)3 Collections.singletonList (java.util.Collections.singletonList)2 Operation (org.eclipse.che.api.promises.client.Operation)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 PromiseError (org.eclipse.che.api.promises.client.PromiseError)2 ArrayList (java.util.ArrayList)1 CompletionListDTO (org.eclipse.che.api.languageserver.shared.lsapi.CompletionListDTO)1 DocumentFormattingParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.DocumentFormattingParamsDTO)1 DocumentRangeFormattingParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO)1 DocumentSymbolParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.DocumentSymbolParamsDTO)1 RangeDTO (org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO)1 ReferenceContextDTO (org.eclipse.che.api.languageserver.shared.lsapi.ReferenceContextDTO)1 ReferenceParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO)1 SymbolInformationDTO (org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 TextPosition (org.eclipse.che.ide.api.editor.text.TextPosition)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1