Search in sources :

Example 1 with DocumentRangeFormattingParamsDTO

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);
}
Also used : TextDocumentIdentifierDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO) List(java.util.List) RangeDTO(org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO) PositionDTO(org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO) DocumentRangeFormattingParamsDTO(org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO)

Aggregations

List (java.util.List)1 DocumentRangeFormattingParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO)1 PositionDTO (org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO)1 RangeDTO (org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO)1 TextDocumentIdentifierDTO (org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO)1