protected CompletableFuture<Either<List<CompletionItem>, CompletionList>> getCompletionFor(CamelLanguageServer camelLanguageServer, Position position) { TextDocumentService textDocumentService = camelLanguageServer.getTextDocumentService(); TextDocumentPositionParams dummyCompletionPositionRequest = new TextDocumentPositionParams(new TextDocumentIdentifier(DUMMY_URI), position); CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = textDocumentService.completion(dummyCompletionPositionRequest); return completions; }
/** * @return the textDocumentService */ public TextDocumentService getTextDocumentService() { return this.textDocumentService; }
/** * @param textDocumentService the textDocumentService to set */ protected void setTextDocumentService(TextDocumentService textDocumentService) { this.textDocumentService = textDocumentService; }
@Override public TextDocumentService getTextDocumentService() { return textDocuments; }
@Override public TextDocumentService getTextDocumentService() { // TODO: perhaps break this out into separate object return this; }
@Override public TextDocumentService getTextDocumentService() { return this; }
@Test public void testDocumentSymbol() { Map<String, JsonRpcMethod> methods = ServiceEndpoints.getSupportedMethods(TextDocumentService.class); JsonRpcMethod jsonRpcMethod = methods.get("textDocument/documentSymbol"); Assert.assertNotNull(jsonRpcMethod); }
@Test public void testCodelensResolve() { Map<String, JsonRpcMethod> methods = ServiceEndpoints.getSupportedMethods(TextDocumentService.class); Assert.assertNotNull(methods.get("codeLens/resolve")); Assert.assertNotNull(methods.get("completionItem/resolve")); }
@Override public TextDocumentService getTextDocumentService() { return null; }
@BeforeMethod public void setUp() throws Exception { this.serverCapabilities = new ServerCapabilities(); serverDescription = new LanguageServerDescription( "foo", Collections.singletonList("id"), Collections.emptyList()); initializeResult = new InitializeResult(serverCapabilities); completableFuture = completedFuture(initializeResult); when(languageServerLauncher.isAbleToLaunch()).thenReturn(true); when(languageServerLauncher.getDescription()).thenReturn(serverDescription); when(languageServerLauncher.isLocal()).thenReturn(true); when(languageDescription.getLanguageId()).thenReturn("id"); when(languageDescription.getFileExtensions()).thenReturn(Collections.singletonList("txt")); when(languageDescription.getMimeType()).thenReturn("plain/text"); when(languageServer.getTextDocumentService()).thenReturn(mock(TextDocumentService.class)); when(languageServer.initialize(any(InitializeParams.class))).thenReturn(completableFuture); when(languageRecognizer.recognizeByPath(anyString())).thenReturn(languageDescription); when(languageRecognizer.recognizeById(anyString())).thenReturn(languageDescription); when(pmp.get()).thenReturn(pm); when(clientFactory.create(anyString())).thenReturn(languageClient); when(httpJsonRequestFactory.fromUrl(any(String.class))).thenReturn(httpJsonRequest); when(httpJsonRequest.useGetMethod()).thenReturn(httpJsonRequest); when(httpJsonRequest.request()).thenReturn(httpJsonResponse); when(httpJsonResponse.asDto(any())).thenReturn(workspace); registry = spy( new LanguageServerRegistryImpl( "", "", httpJsonRequestFactory, new HashSet<>(), Collections.singleton(languageServerLauncher), Collections.singleton(languageDescription), pmp, initializer, null, clientFactory, languageRecognizer) { @Override protected String extractProjectPath(String filePath) throws LanguageServerException { return PROJECT_PATH; } }); when(initializer.initialize( any(LanguageServerLauncher.class), any(LanguageClient.class), anyString())) .thenAnswer(invocation -> completedFuture(Pair.of(languageServer, initializeResult))); }
@Override public TextDocumentService getTextDocumentService() { return textDocumentService; }