Language server respond with error missing header in mac [message #1857349] |
Wed, 01 February 2023 07:40  |
Eclipse User |
|
|
|
I have installed vscode extension in mac book, language server responded with error missing header.
I found this github issue https://github.com/eclipse/lsp4j/issues/210 with the same stack trace.
We have a server which is IO mode.
Why i am facing this issue in macbook only? It works in windows.
It bits strange for me why language client will send request without header.
Installed extension in vscode version 1.74.3(Both windows and mac have same vscode)
Any hint and suggestions it would be great help.
Thanks
Nagaraj
[Updated on: Wed, 01 February 2023 07:47] by Moderator
|
|
|
|
|
|
|
|
|
|
Re: Language server failed to respond with error missing header in mac [message #1857364 is a reply to message #1857363] |
Wed, 01 February 2023 15:08   |
Eclipse User |
|
|
|
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
[Updated on: Wed, 01 February 2023 15:33] by Moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03937 seconds