本文整理汇总了Java中org.eclipse.lsp4j.DocumentRangeFormattingParams类的典型用法代码示例。如果您正苦于以下问题:Java DocumentRangeFormattingParams类的具体用法?Java DocumentRangeFormattingParams怎么用?Java DocumentRangeFormattingParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentRangeFormattingParams类属于org.eclipse.lsp4j包,在下文中一共展示了DocumentRangeFormattingParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testRangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
@Test
public void testRangeFormatting() throws Exception {
ICompilationUnit unit = getWorkingCopy("src/org/sample/Baz.java",
//@formatter:off
"package org.sample;\n" +
" public class Baz {\n"+
"\tvoid foo(){\n" +
" }\n"+
" }\n"
//@formatter:on
);
String uri = JDTUtils.toURI(unit);
TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri);
Range range = new Range(new Position(2, 0), new Position(3, 5));// range around foo()
DocumentRangeFormattingParams params = new DocumentRangeFormattingParams(range);
params.setTextDocument(textDocument);
params.setOptions(new FormattingOptions(3, true));// ident == 3 spaces
List<? extends TextEdit> edits = server.rangeFormatting(params).get();
//@formatter:off
String expectedText =
"package org.sample;\n" +
" public class Baz {\n"+
" void foo() {\n" +
" }\n"+
" }\n";
//@formatter:on
String newText = TextEditUtil.apply(unit, edits);
assertEquals(expectedText, newText);
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:33,代码来源:FormatterHandlerTest.java
示例2: testRangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
protected void testRangeFormatting(final Procedure1<? super RangeFormattingConfiguration> configurator) {
try {
@Extension
final RangeFormattingConfiguration configuration = new RangeFormattingConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final FileInfo fileInfo = this.initializeContext(configuration);
DocumentRangeFormattingParams _documentRangeFormattingParams = new DocumentRangeFormattingParams();
final Procedure1<DocumentRangeFormattingParams> _function = (DocumentRangeFormattingParams it) -> {
String _uri = fileInfo.getUri();
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(_uri);
it.setTextDocument(_textDocumentIdentifier);
it.setRange(configuration.getRange());
};
DocumentRangeFormattingParams _doubleArrow = ObjectExtensions.<DocumentRangeFormattingParams>operator_doubleArrow(_documentRangeFormattingParams, _function);
final CompletableFuture<List<? extends TextEdit>> changes = this.languageServer.rangeFormatting(_doubleArrow);
String _contents = fileInfo.getContents();
final Document result = new Document(1, _contents).applyChanges(ListExtensions.<TextEdit>reverse(CollectionLiterals.<TextEdit>newArrayList(((TextEdit[])Conversions.unwrapArray(changes.get(), TextEdit.class)))));
this.assertEquals(configuration.getExpectedText(), result.getContents());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:AbstractLanguageServerTest.java
示例3: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends TextEdit>> rangeFormatting(final DocumentRangeFormattingParams params) {
final Function1<CancelIndicator, List<? extends TextEdit>> _function = (CancelIndicator cancelIndicator) -> {
final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
FormattingService _get = null;
if (resourceServiceProvider!=null) {
_get=resourceServiceProvider.<FormattingService>get(FormattingService.class);
}
final FormattingService formatterService = _get;
if ((formatterService == null)) {
return CollectionLiterals.<TextEdit>emptyList();
}
final Function2<Document, XtextResource, List<? extends TextEdit>> _function_1 = (Document document, XtextResource resource) -> {
return formatterService.format(document, resource, params, cancelIndicator);
};
return this.workspaceManager.<List<? extends TextEdit>>doRead(uri, _function_1);
};
return this.requestManager.<List<? extends TextEdit>>runRead(_function);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:LanguageServerImpl.java
示例4: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
private List<TextEditDto> rangeFormatting(
DocumentRangeFormattingParams documentRangeFormattingParams) {
try {
String uri = prefixURI(documentRangeFormattingParams.getTextDocument().getUri());
documentRangeFormattingParams.getTextDocument().setUri(uri);
InitializedLanguageServer server =
languageServerRegistry
.getApplicableLanguageServers(uri)
.stream()
.flatMap(Collection::stream)
.filter(
s ->
truish(
s.getInitializeResult()
.getCapabilities()
.getDocumentRangeFormattingProvider()))
.findFirst()
.get();
return server == null
? Collections.emptyList()
: server
.getServer()
.getTextDocumentService()
.rangeFormatting(documentRangeFormattingParams)
.get()
.stream()
.map(TextEditDto::new)
.collect(Collectors.toList());
} catch (InterruptedException | ExecutionException | LanguageServerException e) {
throw new JsonRpcException(-27000, e.getMessage());
}
}
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:TextDocumentService.java
示例5: formatRange
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
private void formatRange(TextRange selectedRange, Document document) {
DocumentRangeFormattingParams params =
dtoFactory.createDto(DocumentRangeFormattingParams.class);
TextDocumentIdentifier identifier = dtoFactory.createDto(TextDocumentIdentifier.class);
identifier.setUri(document.getFile().getLocation().toString());
params.setTextDocument(identifier);
params.setOptions(getFormattingOptions());
Range range = dtoFactory.createDto(Range.class);
Position start = dtoFactory.createDto(Position.class);
Position end = dtoFactory.createDto(Position.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<TextEdit>> promise = client.rangeFormatting(params);
handleFormatting(promise, document);
}
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:LanguageServerFormatter.java
示例6: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends TextEdit>> rangeFormatting(DocumentRangeFormattingParams params) {
LOGGER.info("rangeFormatting: " + params.getTextDocument());
return CompletableFuture.completedFuture(Collections.emptyList());
}
开发者ID:lhein,项目名称:camel-language-server,代码行数:6,代码来源:CamelTextDocumentService.java
示例7: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends TextEdit>> rangeFormatting(
final DocumentRangeFormattingParams params) {
// TODO Auto-generated method stub
return null;
}
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:7,代码来源:SomLanguageServer.java
示例8: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
List<? extends org.eclipse.lsp4j.TextEdit> rangeFormatting(DocumentRangeFormattingParams params,
IProgressMonitor monitor) {
return format(params.getTextDocument().getUri(), params.getOptions(), params.getRange(), monitor);
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:5,代码来源:FormatterHandler.java
示例9: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends TextEdit>> rangeFormatting(DocumentRangeFormattingParams params) {
logInfo(">> document/rangeFormatting");
FormatterHandler handler = new FormatterHandler(preferenceManager);
return computeAsync((cc) -> handler.rangeFormatting(params, toMonitor(cc)));
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:7,代码来源:JDTLanguageServer.java
示例10: format
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
public List<? extends TextEdit> format(final Document document, final XtextResource resource, final DocumentRangeFormattingParams params, final CancelIndicator cancelIndicator) {
final int offset = document.getOffSet(params.getRange().getStart());
int _offSet = document.getOffSet(params.getRange().getEnd());
final int length = (_offSet - offset);
return this.format(resource, document, offset, length);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:7,代码来源:FormattingService.java
示例11: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends TextEdit>> rangeFormatting(DocumentRangeFormattingParams params) {
throw new UnsupportedOperationException();
}
开发者ID:eclipse,项目名称:lsp4j,代码行数:5,代码来源:MockLanguageServer.java
示例12: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends TextEdit>> rangeFormatting(
DocumentRangeFormattingParams params) {
return null;
}
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:MavenTextDocumentService.java
示例13: configureMethods
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
@PostConstruct
public void configureMethods() {
dtoToDtoList(
"definition", TextDocumentPositionParams.class, LocationDto.class, this::definition);
dtoToDtoList("codeAction", CodeActionParams.class, CommandDto.class, this::codeAction);
dtoToDtoList(
"documentSymbol",
DocumentSymbolParams.class,
SymbolInformationDto.class,
this::documentSymbol);
dtoToDtoList("formatting", DocumentFormattingParams.class, TextEditDto.class, this::formatting);
dtoToDtoList(
"rangeFormatting",
DocumentRangeFormattingParams.class,
TextEditDto.class,
this::rangeFormatting);
dtoToDtoList("references", ReferenceParams.class, LocationDto.class, this::references);
dtoToDtoList(
"onTypeFormatting",
DocumentOnTypeFormattingParams.class,
TextEditDto.class,
this::onTypeFormatting);
dtoToDto(
"completionItem/resolve",
ExtendedCompletionItem.class,
ExtendedCompletionItemDto.class,
this::completionItemResolve);
dtoToDto(
"documentHighlight",
TextDocumentPositionParams.class,
DocumentHighlight.class,
this::documentHighlight);
dtoToDto(
"completion",
TextDocumentPositionParams.class,
ExtendedCompletionListDto.class,
this::completion);
dtoToDto("hover", TextDocumentPositionParams.class, HoverDto.class, this::hover);
dtoToDto(
"signatureHelp",
TextDocumentPositionParams.class,
SignatureHelpDto.class,
this::signatureHelp);
dtoToDto("rename", RenameParams.class, RenameResultDto.class, this::rename);
dtoToNothing("didChange", DidChangeTextDocumentParams.class, this::didChange);
dtoToNothing("didClose", DidCloseTextDocumentParams.class, this::didClose);
dtoToNothing("didOpen", DidOpenTextDocumentParams.class, this::didOpen);
dtoToNothing("didSave", DidSaveTextDocumentParams.class, this::didSave);
}
开发者ID:eclipse,项目名称:che,代码行数:53,代码来源:TextDocumentService.java
示例14: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
/**
* The document range formatting request is sent from the client to the
* server to format a given range in a document.
*
* Registration Options: TextDocumentRegistrationOptions
*/
@JsonRequest
CompletableFuture<List<? extends TextEdit>> rangeFormatting(DocumentRangeFormattingParams params);
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:9,代码来源:TextDocumentService.java
示例15: rangeFormatting
import org.eclipse.lsp4j.DocumentRangeFormattingParams; //导入依赖的package包/类
/**
* GWT client implementation of {@link TextDocumentService#formatting(DocumentFormattingParams)}
*
* @param params
* @return
*/
public Promise<List<TextEdit>> rangeFormatting(DocumentRangeFormattingParams params) {
return transmitDtoAndReceiveDtoList(params, "textDocument/rangeFormatting", TextEdit.class);
}
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:TextDocumentServiceClient.java
注:本文中的org.eclipse.lsp4j.DocumentRangeFormattingParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论