类型CalculatorLanguageServer必须实现继承的抽象方法StreamConnectionProvider.getErrorStream()

时间:2018-11-02 06:13:20

标签: java eclipse

我尝试按照this repo中自述文件的指导创建Xtext计算器DSL。它是具有语言服务器和LSP4E实现的Xtext DSL,并且具有两个名为:

的子项目。

我下载了该存储库,并在Eclipse IDE中将其打开。在主项目下,有两个子项目,分别为:org.xtext.calc.parent(即xtext项目)和org.xtext.calc.lsp4e(lsp4e实现项目)。

在org.xtext.calc.lsp4e项目的src文件夹中,有3个Java文件,分别名为:Activator,CalculatorLanguageServer,SocketStreamConnectionProvider。在后两者中,出现一个我无法解决的错误。

下面是两个文件:-

1。)CalculatorLanguageServer.java

var mystring=JSON.stringify(resdata.serverReferenceCode);
  mystring=mystring.replace(/["']/g, "");

2。)SocketStreamConnectionProvider.java

package org.xtext.calc.lsp4e;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
import org.eclipse.lsp4e.server.StreamConnectionProvider;
import org.eclipse.lsp4j.jsonrpc.messages.Message;
import org.eclipse.lsp4j.services.LanguageServer;
import org.osgi.framework.Bundle;

public class CalculatorLanguageServer implements StreamConnectionProvider {

    private final static boolean SOCKET_MODE = true;
    private StreamConnectionProvider delegate;

    public CalculatorLanguageServer() {
        if (SOCKET_MODE) {
            this.delegate = new SocketStreamConnectionProvider(5007) {
            };
        } else {
            List<String> commands = new ArrayList<>();
            commands.add("java");
            commands.add("-Xdebug");
            commands.add("-Xrunjdwp:server=y,transport=dt_socket,address=4001,suspend=n,quiet=y");
            commands.add("-jar");
            Bundle bundle = Activator.getDefault().getBundle();
            URL resource = bundle.getResource("/language-server/calculator-language-server-jar");
            try {
                commands.add(new File(FileLocator.resolve(resource).toURI()).getAbsolutePath());
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
            this.delegate = new ProcessStreamConnectionProvider(commands, Platform.getLocation().toOSString()) {};
        }
    }

    public void start() throws IOException {
        delegate.start();
    }

    public InputStream getInputStream() {
        return delegate.getInputStream();
    }

    public OutputStream getOutputStream() {
        return delegate.getOutputStream();
    }

    public Object getInitializationOptions(URI rootUri) {
        return delegate.getInitializationOptions(rootUri);
    }

    public void stop() {
        delegate.stop();
    }

    public void handleMessage(Message message, LanguageServer languageServer, URI rootURI) {
        delegate.handleMessage(message, languageServer, rootURI);
    }


    @Override
    public String toString() {
        return "Calculator Language Server: " + super.toString();
    }
}

在这两个文件中,类名都出现错误:

  

1。)类型CalculatorLanguageServer必须实现继承的抽象方法StreamConnectionProvider.getErrorStream()

     

2。)类型SocketStreamConnectionProvider必须实现继承的抽象方法StreamConnectionProvider.getErrorStream()

如何解决这些错误?

谢谢!

0 个答案:

没有答案