org.eclipse.lsp4j.jsonrpc.Launcher.Builder Java Examples
The following examples show how to use
org.eclipse.lsp4j.jsonrpc.Launcher.Builder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LspServer.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void setupAndRun(ExecutorService threadPool, XLanguageServerImpl languageServer) throws InterruptedException, ExecutionException, IOException { Builder<LanguageClient> lsBuilder = new PatchedLauncherBuilder<LanguageClient>() .setLocalService(languageServer) .setRemoteInterface(LanguageClient.class) .setExecutorService(threadPool) .configureGson(gsonBuilder -> { gsonBuilder.registerTypeAdapterFactory(new ExecuteCommandParamsTypeAdapter.Factory(languageServer)); }) // .traceMessages(new PrintWriter(System.out)) // .wrapMessages(a -> a) ; if (options.isStdio()) { setupAndRunWithSystemIO(languageServer, lsBuilder); } else { setupAndRunWithSocket(languageServer, lsBuilder); } }
Example #2
Source File: LspServer.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void setupAndRunWithSocket(XLanguageServerImpl languageServer, Builder<LanguageClient> lsBuilder) throws InterruptedException, ExecutionException, IOException { InetSocketAddress address = new InetSocketAddress("localhost", options.getPort()); try (AsynchronousServerSocketChannel serverSocket = AsynchronousServerSocketChannel.open().bind(address);) { // Attention: the VSCode LSP extension is waiting for this line 'Listening for LSP clients'. N4jscConsole.println(LSP_SYNC_MESSAGE + " on port " + options.getPort() + "..."); try (AsynchronousSocketChannel socketChannel = serverSocket.accept().get(); InputStream in = Channels.newInputStream(socketChannel); OutputStream out = Channels.newOutputStream(socketChannel)) { N4jscConsole.println("Connected to LSP client"); run(languageServer, lsBuilder, in, out); } } }
Example #3
Source File: LspServer.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void run(XLanguageServerImpl languageServer, Builder<LanguageClient> lsBuilder, InputStream in, OutputStream out) { Launcher<LanguageClient> launcher = lsBuilder .setInput(in) .setOutput(out) .create(); languageServer.connect(launcher.getRemoteProxy()); Future<Void> future = launcher.startListening(); N4jscConsole.println("LSP Server connected"); Futures.getUnchecked(future); N4jscConsole.println("Shutdown connection to LSP client"); languageServer.getLSPExecutorService().shutdown(); }
Example #4
Source File: ExtendableConcurrentMessageProcessorTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
static <T> Builder<T> createBuilder(MessageContextStore<T> store) { return new Builder<T>() { @Override protected ConcurrentMessageProcessor createMessageProcessor(MessageProducer reader, MessageConsumer messageConsumer, T remoteProxy) { return new CustomConcurrentMessageProcessor<T>(reader, messageConsumer, remoteProxy, store); } }; }
Example #5
Source File: GLSPServerEndpoint.java From graphical-lsp with Eclipse Public License 2.0 | 4 votes |
@Override protected void configure(Builder<GLSPClient> builder) { builder.setLocalService(glspServer); builder.setRemoteInterface(GLSPClient.class); builder.configureGson(gsonConfigurator::configureGsonBuilder); }
Example #6
Source File: CamelLSPWebSocketEndpoint.java From camel-language-server with Apache License 2.0 | 4 votes |
@Override protected void configure(Builder<LanguageClient> builder) { builder.setLocalService(new CamelLanguageServer()); builder.setRemoteInterface(LanguageClient.class); }
Example #7
Source File: LspServer.java From n4js with Eclipse Public License 1.0 | 4 votes |
private void setupAndRunWithSystemIO(XLanguageServerImpl languageServer, Builder<LanguageClient> lsBuilder) { N4jscConsole.println(LSP_SYNC_MESSAGE + " on stdio"); N4jscConsole.setSuppress(true); run(languageServer, lsBuilder, System.in, System.out); }
Example #8
Source File: ExtendableConcurrentMessageProcessorTest.java From lsp4j with Eclipse Public License 2.0 | 4 votes |
static <T> Launcher<T> createLauncher(Builder<T> builder, Object localService, Class<T> remoteInterface, InputStream in, OutputStream out) { return builder.setLocalService(localService) .setRemoteInterface(remoteInterface) .setInput(in).setOutput(out) .create(); }