use of org.eclipse.lsp4j.services.LanguageClient in project xtext-core by eclipse.
the class SocketServerLauncher method main.
public static void main(final String[] args) {
try {
ServerModule _serverModule = new ServerModule();
final Injector injector = Guice.createInjector(_serverModule);
final LanguageServer languageServer = injector.<LanguageServer>getInstance(LanguageServer.class);
final ServerSocketChannel serverSocket = ServerSocketChannel.open();
InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 5007);
serverSocket.bind(_inetSocketAddress);
final SocketChannel socketChannel = serverSocket.accept();
InputStream _newInputStream = Channels.newInputStream(socketChannel);
OutputStream _newOutputStream = Channels.newOutputStream(socketChannel);
PrintWriter _printWriter = new PrintWriter(System.out);
final Launcher<LanguageClient> launcher = LSPLauncher.createServerLauncher(languageServer, _newInputStream, _newOutputStream, true, _printWriter);
launcher.startListening().get();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.services.LanguageClient in project ballerina by ballerina-lang.
the class Main method startServer.
public static void startServer(InputStream in, OutputStream out) throws InterruptedException, ExecutionException {
BallerinaLanguageServer server = new BallerinaLanguageServer();
Launcher<LanguageClient> l = LSPLauncher.createServerLauncher(server, in, out);
LanguageClient client = l.getRemoteProxy();
((LanguageClientAware) server).connect(client);
Future<?> startListening = l.startListening();
startListening.get();
}
use of org.eclipse.lsp4j.services.LanguageClient in project sts4 by spring-projects.
the class SimpleTextDocumentService method publishDiagnostics.
public void publishDiagnostics(TextDocumentIdentifier docId, Collection<Diagnostic> diagnostics) {
LanguageClient client = server.getClient();
if (client != null && diagnostics != null) {
PublishDiagnosticsParams params = new PublishDiagnosticsParams();
params.setUri(docId.getUri());
params.setDiagnostics(ImmutableList.copyOf(diagnostics));
client.publishDiagnostics(params);
}
}
use of org.eclipse.lsp4j.services.LanguageClient in project sts4 by spring-projects.
the class LaunguageServerApp method run.
/**
* Listen for requests from the parent node process.
* Send replies asynchronously.
* When the request stream is closed, wait for 5s for all outstanding responses to compute, then return.
* @throws ExecutionException
* @throws InterruptedException
*/
protected void run(Connection connection) throws InterruptedException, ExecutionException {
LanguageServer server = createServer();
ExecutorService executor = createServerThreads();
Function<MessageConsumer, MessageConsumer> wrapper = (MessageConsumer consumer) -> {
return (msg) -> {
try {
consumer.consume(msg);
} catch (UnsupportedOperationException e) {
// log a warning and ignore. We are getting some messages from vsCode the server doesn't know about
Log.warn("Unsupported message was ignored!", e);
}
};
};
Launcher<STS4LanguageClient> launcher = Launcher.createLauncher(server, STS4LanguageClient.class, connection.in, connection.out, executor, wrapper);
if (server instanceof LanguageClientAware) {
LanguageClient client = launcher.getRemoteProxy();
((LanguageClientAware) server).connect(client);
}
launcher.startListening().get();
}
use of org.eclipse.lsp4j.services.LanguageClient in project vscode-nextgenas by BowlerHatLLC.
the class Main method main.
/**
* The main entry point when the JAR is run. Opens a socket to communicate
* with Visual Studio Code using the port specified with the
* -Dnextgeas.vscode.port command line option. Then, instantiates the
* ActionScriptLanguageServer, and passes it to the LSP4J library,
* which handles all of the language server protocol communication.
* LSP4J calls methods on ActionScriptLanguageServer as requests come in
* from the text editor.
*/
public static void main(String[] args) {
String port = System.getProperty(SYSTEM_PROPERTY_PORT);
if (port == null) {
System.err.println("NextGen ActionScript language server encountered an error: System property nextgeas.vscode.port is required.");
System.exit(MISSING_PORT);
}
try {
Socket socket = new Socket(SOCKET_HOST, Integer.parseInt(port));
ActionScriptLanguageServer server = new ActionScriptLanguageServer();
Launcher<LanguageClient> launcher = LSPLauncher.createServerLauncher(server, socket.getInputStream(), socket.getOutputStream());
server.connect(launcher.getRemoteProxy());
launcher.startListening();
} catch (Exception e) {
System.err.println("NextGen ActionScript language server failed to connect.");
System.err.println("Visit the following URL to file an issue, and please include this log: https://github.com/BowlerHatLLC/vscode-nextgenas/issues");
e.printStackTrace(System.err);
System.exit(SERVER_CONNECT_ERROR);
}
}
Aggregations