MCPcopy
hub / github.com/microsoft/vscode-languageserver-node / WorkspaceFoldersFeature

Class WorkspaceFoldersFeature

client/src/workspaceFolders.ts:29–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29export class WorkspaceFoldersFeature implements DynamicFeature<undefined> {
30
31 private _listeners: Map<string, Disposable> = new Map<string, Disposable>();
32
33 constructor(private _client: BaseLanguageClient) {
34 }
35
36 public get messages(): RPCMessageType {
37 return DidChangeWorkspaceFoldersNotification.type;
38 }
39
40 public fillInitializeParams(params: InitializeParams): void {
41 let folders = workspace.workspaceFolders;
42
43 if (folders === void 0) {
44 params.workspaceFolders = null;
45 } else {
46 params.workspaceFolders = folders.map(folder => this.asProtocol(folder));
47 }
48 }
49
50 public fillClientCapabilities(capabilities: ClientCapabilities): void {
51 capabilities.workspace = capabilities.workspace || {};
52 capabilities.workspace.workspaceFolders = true;
53 }
54
55 public initialize(capabilities: ServerCapabilities): void {
56 let client = this._client;
57 client.onRequest(WorkspaceFoldersRequest.type, (token: CancellationToken) => {
58 let workspaceFolders: WorkspaceFoldersRequest.HandlerSignature = () => {
59 let folders = workspace.workspaceFolders;
60 if (folders === void 0) {
61 return null;
62 }
63 let result: WorkspaceFolder[] = folders.map((folder) => {
64 return this.asProtocol(folder);
65 });
66 return result;
67 };
68 let middleware = client.clientOptions.middleware!.workspace;
69 return middleware && middleware.workspaceFolders
70 ? middleware.workspaceFolders(token, workspaceFolders)
71 : workspaceFolders(token);
72 });
73 let value = access(access(access(capabilities, 'workspace'), 'workspaceFolders'), 'changeNotifications');
74 let id: string | undefined;
75 if (typeof value === 'string') {
76 id = value;
77 } else if (value === true) {
78 id = UUID.generateUuid();
79 }
80 if (id) {
81 this.register(this.messages, {
82 id: id,
83 registerOptions: undefined
84 });
85 }
86 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected