Search in sources :

Example 1 with FormattingService

use of org.eclipse.xtext.ide.server.formatting.FormattingService in project xtext-core by eclipse.

the class LanguageServerImpl method rangeFormatting.

/**
 * Create the text edits for the formatter. Executed in a read request.
 * @since 2.20
 */
protected List<? extends TextEdit> rangeFormatting(DocumentRangeFormattingParams params, CancelIndicator cancelIndicator) {
    URI uri = getURI(params.getTextDocument());
    FormattingService formatterService = getService(uri, FormattingService.class);
    if (formatterService == null) {
        return Collections.emptyList();
    }
    return workspaceManager.doRead(uri, (document, resource) -> formatterService.format(document, resource, params, cancelIndicator));
}
Also used : FormattingService(org.eclipse.xtext.ide.server.formatting.FormattingService) URI(org.eclipse.emf.common.util.URI)

Example 2 with FormattingService

use of org.eclipse.xtext.ide.server.formatting.FormattingService in project xtext-core by eclipse.

the class LanguageServerImpl method formatting.

/**
 * Create the text edits for the formatter. Executed in a read request.
 * @since 2.20
 */
protected List<? extends TextEdit> formatting(DocumentFormattingParams params, CancelIndicator cancelIndicator) {
    URI uri = getURI(params.getTextDocument());
    FormattingService formatterService = getService(uri, FormattingService.class);
    if (formatterService == null) {
        return Collections.emptyList();
    }
    return workspaceManager.doRead(uri, (document, resource) -> formatterService.format(document, resource, params, cancelIndicator));
}
Also used : FormattingService(org.eclipse.xtext.ide.server.formatting.FormattingService) URI(org.eclipse.emf.common.util.URI)

Aggregations

URI (org.eclipse.emf.common.util.URI)2 FormattingService (org.eclipse.xtext.ide.server.formatting.FormattingService)2