use of org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO in project che by eclipse.
the class GoToSymbolAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
DocumentSymbolParamsDTO paramsDTO = dtoFactory.createDto(DocumentSymbolParamsDTO.class);
TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
identifierDTO.setUri(editorAgent.getActiveEditor().getEditorInput().getFile().getLocation().toString());
paramsDTO.setTextDocument(identifierDTO);
activeEditor = (TextEditor) editorAgent.getActiveEditor();
cursorPosition = activeEditor.getDocument().getCursorPosition();
client.documentSymbol(paramsDTO).then(new Operation<List<SymbolInformationDTO>>() {
@Override
public void apply(List<SymbolInformationDTO> arg) throws OperationException {
cachedItems = arg;
presenter.run(GoToSymbolAction.this);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify("Can't fetch document symbols.", arg.getMessage(), StatusNotification.Status.FAIL, StatusNotification.DisplayMode.FLOAT_MODE);
}
});
}
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, TextPosition position) {
TextDocumentPositionParamsDTO paramsDTO = dtoFactory.createDto(TextDocumentPositionParamsDTO.class);
TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
identifierDTO.setUri(document.getFile().getLocation().toString());
PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class);
positionDTO.setCharacter(position.getCharacter());
positionDTO.setLine(position.getLine());
paramsDTO.setUri(document.getFile().getLocation().toString());
paramsDTO.setTextDocument(identifierDTO);
paramsDTO.setPosition(positionDTO);
return paramsDTO;
}
use of org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO in project che by eclipse.
the class LanguageServerFormatter method formatRange.
private void formatRange(TextRange selectedRange, Document document) {
DocumentRangeFormattingParamsDTO params = dtoFactory.createDto(DocumentRangeFormattingParamsDTO.class);
TextDocumentIdentifierDTO identifier = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
identifier.setUri(document.getFile().getLocation().toString());
params.setTextDocument(identifier);
params.setOptions(getFormattingOptions());
RangeDTO range = dtoFactory.createDto(RangeDTO.class);
PositionDTO start = dtoFactory.createDto(PositionDTO.class);
PositionDTO end = dtoFactory.createDto(PositionDTO.class);
start.setLine(selectedRange.getFrom().getLine());
start.setCharacter(selectedRange.getFrom().getCharacter());
end.setLine(selectedRange.getTo().getLine());
end.setCharacter(selectedRange.getTo().getCharacter());
range.setStart(start);
range.setEnd(end);
params.setRange(range);
Promise<List<TextEditDTO>> promise = client.rangeFormatting(params);
handleFormatting(promise, document);
}
use of org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO in project che by eclipse.
the class LanguageServerFormatter method formatFullDocument.
private void formatFullDocument(Document document) {
DocumentFormattingParamsDTO params = dtoFactory.createDto(DocumentFormattingParamsDTO.class);
TextDocumentIdentifierDTO identifier = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
identifier.setUri(document.getFile().getLocation().toString());
params.setTextDocument(identifier);
params.setOptions(getFormattingOptions());
Promise<List<TextEditDTO>> promise = client.formatting(params);
handleFormatting(promise, document);
}
use of org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO in project che by eclipse.
the class LanguageServerCodeAssistProcessor method computeCompletionProposals.
@Override
public void computeCompletionProposals(TextEditor editor, final int offset, final boolean triggered, final CodeAssistCallback callback) {
this.lastErrorMessage = null;
TextDocumentPositionParamsDTO documentPosition = dtoBuildHelper.createTDPP(editor.getDocument(), offset);
final TextDocumentIdentifierDTO documentId = documentPosition.getTextDocument();
String currentLine = editor.getDocument().getLineContent(documentPosition.getPosition().getLine());
final String currentWord = getCurrentWord(currentLine, documentPosition.getPosition().getCharacter());
if (!triggered && latestCompletionResult.isGoodFor(documentId, offset, currentWord)) {
// no need to send new completion request
computeProposals(currentWord, offset - latestCompletionResult.getOffset(), callback);
} else {
documentServiceClient.completion(documentPosition).then(new Operation<CompletionListDTO>() {
@Override
public void apply(CompletionListDTO list) throws OperationException {
latestCompletionResult.update(documentId, offset, currentWord, list);
computeProposals(currentWord, 0, callback);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
lastErrorMessage = error.getMessage();
}
});
}
}
Aggregations