use of org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO 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);
}
Aggregations