@Override public CompletableFuture<List<? extends TextEdit>> onTypeFormatting(final DocumentOnTypeFormattingParams params) { throw new UnsupportedOperationException("TODO: auto-generated method stub"); }
private List<TextEditDto> onTypeFormatting( DocumentOnTypeFormattingParams documentOnTypeFormattingParams) { try { String uri = prefixURI(documentOnTypeFormattingParams.getTextDocument().getUri()); documentOnTypeFormattingParams.getTextDocument().setUri(uri); InitializedLanguageServer server = languageServerRegistry .getApplicableLanguageServers(uri) .stream() .flatMap(Collection::stream) .filter( s -> s.getInitializeResult() .getCapabilities() .getDocumentOnTypeFormattingProvider() != null) .findFirst() .get(); return server == null ? Collections.emptyList() : server .getServer() .getTextDocumentService() .onTypeFormatting(documentOnTypeFormattingParams) .get() .stream() .map(TextEditDto::new) .collect(Collectors.toList()); } catch (InterruptedException | ExecutionException | LanguageServerException e) { throw new JsonRpcException(-27000, e.getMessage()); } }
@Override public CompletableFuture<List<? extends TextEdit>> onTypeFormatting(DocumentOnTypeFormattingParams params) { LOGGER.info("onTypeFormatting: " + params.getTextDocument()); return CompletableFuture.completedFuture(Collections.emptyList()); }
@Override public CompletableFuture<List<? extends TextEdit>> onTypeFormatting( final DocumentOnTypeFormattingParams params) { // TODO Auto-generated method stub return null; }
@Override public CompletableFuture<List<? extends TextEdit>> onTypeFormatting(DocumentOnTypeFormattingParams params) { logInfo(">> document/onTypeFormatting"); // Not yet implemented return null; }
@Override public CompletableFuture<List<? extends TextEdit>> onTypeFormatting(DocumentOnTypeFormattingParams params) { throw new UnsupportedOperationException(); }
@Override public void install(TextEditor editor) { this.editor = editor; if (capabilities.getDocumentOnTypeFormattingProvider() != null && capabilities.getDocumentOnTypeFormattingProvider().getFirstTriggerCharacter() != null) { editor .getDocument() .getDocumentHandle() .getDocEventBus() .addHandler( DocumentChangedEvent.TYPE, new DocumentChangedHandler() { @Override public void onDocumentChanged(DocumentChangedEvent event) { if (capabilities .getDocumentOnTypeFormattingProvider() .getFirstTriggerCharacter() .equals(event.getText())) { Document document = event.getDocument().getDocument(); DocumentOnTypeFormattingParams params = dtoFactory.createDto(DocumentOnTypeFormattingParams.class); TextDocumentIdentifier identifier = dtoFactory.createDto(TextDocumentIdentifier.class); identifier.setUri(document.getFile().getLocation().toString()); params.setTextDocument(identifier); params.setOptions(getFormattingOptions()); params.setCh(event.getText()); TextPosition position = document.getPositionFromIndex(event.getOffset()); Position start = dtoFactory.createDto(Position.class); start.setLine(position.getLine()); start.setCharacter(position.getCharacter()); params.setPosition(start); Promise<List<TextEdit>> promise = client.onTypeFormatting(params); handleFormatting(promise, document); } } }); } }
@Override public CompletableFuture<List<? extends TextEdit>> onTypeFormatting( DocumentOnTypeFormattingParams params) { return null; }
@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); }
/** * The document on type formatting request is sent from the client to the * server to format parts of the document during typing. * * Registration Options: DocumentOnTypeFormattingRegistrationOptions */ @JsonRequest CompletableFuture<List<? extends TextEdit>> onTypeFormatting(DocumentOnTypeFormattingParams params);
/** * GWT client implementation of {@link TextDocumentService#formatting(DocumentFormattingParams)} * * @param params * @return */ public Promise<List<TextEdit>> onTypeFormatting(DocumentOnTypeFormattingParams params) { return transmitDtoAndReceiveDtoList(params, "textDocument/onTypeFormatting", TextEdit.class); }