我正在根据示例“语言服务器”(https://code.visualstudio.com/docs/extensions/example-language-server)开展语言扩展。
在服务器端,我需要知道vscode使用的当前文件夹,在客户端,它将通过以下方式检索:
import * as vscode from 'vscode';
[...]
let curFolder : string = vscode.workspace.rootPath;
[...]
但如果我尝试在服务器端使用它,
我的服务器和客户端package.json都指定:
"devDependencies": {
"typescript": "^1.8.9",
"vscode": "^0.11.12"
}
我的理解是服务器只通过IConnection对象与客户端通信,因此无法访问客户端维护的vscode。*数据。
我目前的工作是在服务器端使用它:
connection.sendRequest({ method: "getRootPath" })
.then( (rootPath : string) => {
[...]
和客户端的代码:
languageClient.onRequest({method: "getRootPath"}, (params : any) : string => {
return vscode.workspace.rootPath;
} );
有没有更好的方法呢?
答案 0 :(得分:0)
实际上非常简单。 rootPath在初始化时提供给语言服务器,参数为“connection.onInitialize”。
EndpointImpl jaxWsEndpoint = (EndpointImpl) Endpoint.publish(endPointAddress, httpWebService);