|
|
|
|
|
|
|
|
Re: Language server failed to respond with error missing header in mac [message #1857364 is a reply to message #1857363] |
Wed, 01 February 2023 20:08 |
|
you might also alter the launch script to do
-log debug -trace (dont know to what . dir this is written to)
set -- \
-classpath "$CLASSPATH" \
org.eclipse.xtext.ide.server.ServerLauncher \
"-log" "debug" "-trace"
may log into the folder/project you open in code to test.
so you might use this
launcher class instead
package org.xtext.example.mydsl.ide;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.concurrent.Future;
import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.services.LanguageClient;
import org.eclipse.xtext.ide.server.LanguageServerImpl;
import org.eclipse.xtext.ide.server.LaunchArgs;
import org.eclipse.xtext.ide.server.ServerModule;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.InputOutput;
import com.google.common.base.Objects;
import com.google.common.io.ByteStreams;
import com.google.inject.Guice;
import com.google.inject.Inject;
public class MyServerLauncher {
public static final String LOG = "-log";
public static final String TRACE = "-trace";
public static final String NO_VALIDATE = "-noValidate";
public static void main(String[] args) {
launch(MyServerLauncher.class.getName(), new String[] {"-log", "debug", "-trace"}, new ServerModule());
}
public static void launch(String prefix, String[] args, com.google.inject.Module... modules) {
LaunchArgs launchArgs = createLaunchArgs(prefix, args);
MyServerLauncher launcher = Guice.createInjector(modules).<MyServerLauncher>getInstance(MyServerLauncher.class);
launcher.start(launchArgs);
}
@Inject
private LanguageServerImpl languageServer;
public void start(LaunchArgs args) {
try {
InputOutput.println("Xtext Language Server is starting.");
Launcher<LanguageClient> launcher = Launcher.createLauncher(languageServer,
LanguageClient.class, args.getIn(), args.getOut(), args.isValidate(), args.getTrace());
languageServer.connect(launcher.getRemoteProxy());
Future<Void> future = launcher.startListening();
InputOutput.println("Xtext Language Server has been started.");
while (!future.isDone()) {
Thread.sleep(10_000L);
}
} catch (InterruptedException e) {
throw Exceptions.sneakyThrow(e);
}
}
public static LaunchArgs createLaunchArgs(String prefix, String[] args) {
LaunchArgs launchArgs = new LaunchArgs();
launchArgs.setIn(System.in);
launchArgs.setOut(System.out);
redirectStandardStreams(prefix, args);
launchArgs.setTrace(getTrace(args));
launchArgs.setValidate(shouldValidate(args));
return launchArgs;
}
public static PrintWriter getTrace(String[] args) {
if (shouldTrace(args)) {
return createTrace();
}
return null;
}
public static PrintWriter createTrace() {
return new PrintWriter(System.out);
}
public static void redirectStandardStreams(String prefix, String[] args) {
if (shouldLogStandardStreams(args)) {
logStandardStreams(prefix);
} else {
silentStandardStreams();
}
}
public static boolean shouldValidate(String[] args) {
return !testArg(args, MyServerLauncher.NO_VALIDATE);
}
public static boolean shouldTrace(String[] args) {
return testArg(args, MyServerLauncher.TRACE);
}
public static boolean shouldLogStandardStreams(String[] args) {
return testArg(args, MyServerLauncher.LOG, "debug");
}
public static boolean testArg(String[] args, String... values) {
for (String arg : args) {
if (testArg(arg, values)) {
return true;
}
}
return false;
}
public static boolean testArg(String arg, String... values) {
for(String value : values) {
if (Objects.equal(value, arg)) {
return true;
}
}
return false;
}
public static void logStandardStreams(String prefix) {
try {
FileOutputStream stdFileOut = new FileOutputStream(System.getProperty("user.home")+"/"+prefix + "-debug.log");
redirectStandardStreams(stdFileOut);
} catch (IOException e) {
throw Exceptions.sneakyThrow(e);
}
}
public static void silentStandardStreams() {
redirectStandardStreams(silentOut());
}
public static void redirectStandardStreams(OutputStream out) {
redirectStandardStreams(silentIn(), out);
}
public static void redirectStandardStreams(InputStream in, OutputStream out) {
System.setIn(in);
System.setOut(new PrintStream(out));
}
public static OutputStream silentOut() {
return ByteStreams.nullOutputStream();
}
public static InputStream silentIn() {
return new ByteArrayInputStream(new byte[0]);
}
}
which will log to ~/org.xtext.example.mydsl.ide.MyServerLauncher-debug.log
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
[Updated on: Wed, 01 February 2023 20:33] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04315 seconds