摩纳哥客户端无法连接到 Eclipse JDT 服务器

问题描述

我想将 Java Intellisense 添加到我的摩纳哥客户端。为此,我将 Eclipse JDT 服务器与 Monaco 客户端连接。

摩纳哥客户链接https://github.com/TypeFox/monaco-languageclient Eclipse JDT 服务器:https://github.com/eclipse/eclipse.jdt.ls.git

我能够按照他们的文档构建和运行 JDT 服务器和 Monaco 客户端。

我正在运行 Monaco express 服务器,该服务器位于 Monaco 存储库的 example 文件夹中。

我在运行之前在 Monaco 存储库中进行了以下更改:yarn run start

  1. 制作了一个文件夹Demo并在其中添加了Java文件夹,我添加的地方 file.java。 (Demo -> Java -> File.java)

  2. client.ts 文件进行了更改,如下所示:

     // register Monaco languages
    monaco.languages.register({
    id: 'java',extensions: ['.java'],aliases: [java],mimetypes: ['application/text']
      })
    
    
    monaco.editor.create(document.getElementById("container")!,{
        model: monaco.editor.createModel(value,'java',monaco.Uri.parse('file:///home/imocha/python-lang-cli/monaco-languageclient/example/src/java/file.java')),glyphMargin: true,lightbulb: {
            enabled: true
        }
    });
    
    // register Monaco languages
    monaco.languages.register({
        id: 'java',lightbulb: {
            enabled: true
        }
    });
    
    
    // register Monaco languages
    monaco.languages.register({
        id: 'java',lightbulb: {
            enabled: true
        }
    });
    
  3. 我的 server.ts 文件如下:

    import * as ws from "ws";
    import * as http from "http";
    import * as url from "url";
    import * as net from "net";
    import * as express from "express";
    import * as rpc from "@codingame/monaco-jsonrpc";
    import { launch } from "./json-server-launcher";
    
    
    process.on('uncaughtException',function (err: any) {
        console.error('Uncaught Exception: ',err.toString());
        if (err.stack) {
            console.error(err.stack);
        }
    });
    
    // create the express application
    const app = express();
    // server the static content,i.e. index.html
    app.use(express.static(__dirname));
    // start the server
    const server = app.listen(3000);
    // create the web socket
    const wss = new ws.Server({
        noServer: true,perMessageDeflate: false
    });
    server.on('upgrade',(request: http.IncomingMessage,socket: net.socket,head: Buffer) => {
        const pathname = request.url ? url.parse(request.url).pathname : undefined;
        if (pathname === '/sampleServer') {
            wss.handleUpgrade(request,socket,head,webSocket => {
                const socket: rpc.IWebSocket = {
                    send: content => webSocket.send(content,error => {
                        if (error) {
                            throw error;
                        }
                    }),onMessage: cb => webSocket.on('message',cb),onError: cb => webSocket.on('error',onClose: cb => webSocket.on('close',dispose: () => webSocket.close()
                };
                // launch the server when the web socket is opened
                if (webSocket.readyState === webSocket.OPEN) {
                    launch(socket);
                } else {
                    webSocket.on('open',() => launch(socket));
                }
            });
        }
    })
    
  4. 摩纳哥客户端 websocket 在端口 4000 上部署。

我使用代码运行我的 Eclipse JDT 服务器:

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044 -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar ./plugins/org.eclipse.equinox.launcher_1.6.100.v20201223-0822.jar -configuration ./config_linux -data /home/n --add-modules=ALL-SYstem --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -CLIENT_PORT=4000

我使用以下命令运行我的 monaco 客户端:

yarn run start

问题是两者(Eclipse JDT 和 Monaco 客户端以及 websocket)都在各自的端口上启动并处于活动状态,但没有进行通信。

如何将 Eclpse JDT 连接到 Monaco 客户端的 websocket?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)