简体   繁体   English

VSCode扩展处于活动状态时运行节点脚本

[英]Run node script when VSCode extension is active

I'm developing a VSCode extension using LSP (Language Server Protocol) which is activated whenever the user opens a file with extension '.ext'. 我正在开发使用LSP(语言服务器协议)的VSCode扩展名,只要用户打开扩展名为“ .ext”的文件,该代码就会被激活。 It has the following structure: 它具有以下结构:

LSP结构

I'm already using the Language Client/Server libraries for VSCode, and the language validation consists on a web server deployed locally on a random free port containing ANTLR4 classes which receive the content of the file the user is modifying. 我已经在使用VSCode的语言客户端/服务器库,并且语言验证包括本地部署在包含ANTLR4类的随机免费端口上的本地Web服务器,该类接收用户正在修改的文件的内容。 After analysing this content, it sends a response via HTTP to the Language Server part containing the diagnostics about the received code snippet. 在分析了此内容之后,它将通过HTTP将响应发送到包含有关所接收代码段的诊断的Language Server部分。 Then, Server sends the adapted diagnostics to Client, so they can be used by VSCode to inform the user about the errors. 然后,服务器将调整后的诊断发送给客户端,以便VSCode可以使用它们来通知用户有关错误。

The extension works fine, but I have to run the language validation server manually whenever I want to use the extension (which is writen in Node.js). 该扩展程序工作正常,但是每当我想使用该扩展程序(在Node.js中编写)时,都必须手动运行语言验证服务器。 Is there a way to automatically start that node server whenever the extension is activated? 每当激活扩展时,是否可以自动启动该节点服务器?

Thanks in advance. 提前致谢。

The idea of starting an http server on another machine using a VS Code extension sounds strange to me, I think you can use the ANTLR-generated parser directly in your language server. 在另一台使用VS Code扩展名的计算机上启动http服务器的想法对我来说听起来很奇怪,我认为您可以直接在语言服务器中使用ANTLR生成的解析器。 If the parser is not generated in the same language as the server's, you can just re-generate it from the grammar. 如果解析器不是以与服务器相同的语言生成的,则可以从语法中重新生成它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM