package org.xtext.example.mydsl.ide;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.function.Function;

import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.jsonrpc.MessageConsumer;
import org.eclipse.lsp4j.services.LanguageClient;
import org.eclipse.xtext.ide.server.LanguageServerImpl;
import org.eclipse.xtext.ide.server.ServerModule;

import com.google.inject.Guice;
import com.google.inject.Injector;

/**
 * @author dietrich - Initial contribution and API
 */
public class RunServer {

	public static void main(String[] args) throws InterruptedException, IOException {
		Injector injector = Guice.createInjector(new ServerModule());
		LanguageServerImpl languageServer = injector.getInstance(LanguageServerImpl.class);
		Function<MessageConsumer, MessageConsumer> wrapper = consumer -> {
			MessageConsumer result = consumer;
			return result;
		};
		Launcher<LanguageClient> launcher = Launcher.createSocketLauncher(languageServer, LanguageClient.class, new InetSocketAddress("localhost", 5007), Executors.newCachedThreadPool(), wrapper);
		languageServer.connect(launcher.getRemoteProxy());
		Future<?> future = launcher.startListening();
		while (!future.isDone()) {
			Thread.sleep(10_000l);
		}
	}

}
@@ -93,16 +93,285 @@
 ddress;%0A
+import java.net.SocketAddress;%0Aimport java.nio.channels.AsynchronousServerSocketChannel;%0Aimport java.nio.channels.AsynchronousSocketChannel;%0Aimport java.nio.channels.Channels;%0Aimport java.util.concurrent.ExecutionException;%0Aimport java.util.concurrent.ExecutorService;%0A
 import j
@@ -1282,17 +1282,8 @@
 r = 
-Launcher.
 crea
@@ -1584,11 +1584,796 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%09%0A    static %3CT%3E Launcher%3CT%3E createSocketLauncher(Object localService, Class%3CT%3E remoteInterface, SocketAddress socketAddress, ExecutorService executorService, Function%3CMessageConsumer, MessageConsumer%3E wrapper) throws IOException %7B%0A        AsynchronousServerSocketChannel serverSocket = AsynchronousServerSocketChannel.open().bind(socketAddress);%0A        AsynchronousSocketChannel socketChannel;%0A        try %7B%0A            socketChannel = serverSocket.accept().get();%0A            return Launcher.createIoLauncher(localService, remoteInterface, Channels.newInputStream(socketChannel), Channels.newOutputStream(socketChannel), executorService, wrapper);%0A        %7D catch (InterruptedException %7C ExecutionException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        return null;%0A    %7D
 %0A%0A%7D

Use AsynchronousServerSocketChannel for socket communication.