@difizen/libro-language-client 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/es/common/api.d.ts +38 -0
- package/es/common/api.d.ts.map +1 -0
- package/es/common/api.js +9 -0
- package/es/common/callHierarchy.d.ts +39 -0
- package/es/common/callHierarchy.d.ts.map +1 -0
- package/es/common/callHierarchy.js +139 -0
- package/es/common/client.d.ts +482 -0
- package/es/common/client.d.ts.map +1 -0
- package/es/common/client.js +2731 -0
- package/es/common/codeAction.d.ts +22 -0
- package/es/common/codeAction.d.ts.map +1 -0
- package/es/common/codeAction.js +149 -0
- package/es/common/codeConverter.d.ts +81 -0
- package/es/common/codeConverter.d.ts.map +1 -0
- package/es/common/codeConverter.js +1040 -0
- package/es/common/codeLens.d.ts +26 -0
- package/es/common/codeLens.d.ts.map +1 -0
- package/es/common/codeLens.js +125 -0
- package/es/common/colorProvider.d.ts +27 -0
- package/es/common/colorProvider.d.ts.map +1 -0
- package/es/common/colorProvider.js +104 -0
- package/es/common/completion.d.ts +22 -0
- package/es/common/completion.d.ts.map +1 -0
- package/es/common/completion.js +130 -0
- package/es/common/configuration.d.ts +71 -0
- package/es/common/configuration.d.ts.map +1 -0
- package/es/common/configuration.js +292 -0
- package/es/common/declaration.d.ts +18 -0
- package/es/common/declaration.d.ts.map +1 -0
- package/es/common/declaration.js +88 -0
- package/es/common/definition.d.ts +18 -0
- package/es/common/definition.d.ts.map +1 -0
- package/es/common/definition.js +80 -0
- package/es/common/diagnostic.d.ts +125 -0
- package/es/common/diagnostic.d.ts.map +1 -0
- package/es/common/diagnostic.js +1442 -0
- package/es/common/documentHighlight.d.ts +17 -0
- package/es/common/documentHighlight.d.ts.map +1 -0
- package/es/common/documentHighlight.js +73 -0
- package/es/common/documentLink.d.ts +21 -0
- package/es/common/documentLink.d.ts.map +1 -0
- package/es/common/documentLink.js +90 -0
- package/es/common/documentSymbol.d.ts +20 -0
- package/es/common/documentSymbol.d.ts.map +1 -0
- package/es/common/documentSymbol.js +134 -0
- package/es/common/executeCommand.d.ts +22 -0
- package/es/common/executeCommand.d.ts.map +1 -0
- package/es/common/executeCommand.js +117 -0
- package/es/common/features.d.ts +421 -0
- package/es/common/features.d.ts.map +1 -0
- package/es/common/features.js +576 -0
- package/es/common/fileOperations.d.ts +118 -0
- package/es/common/fileOperations.d.ts.map +1 -0
- package/es/common/fileOperations.js +705 -0
- package/es/common/fileSystemWatcher.d.ts +19 -0
- package/es/common/fileSystemWatcher.d.ts.map +1 -0
- package/es/common/fileSystemWatcher.js +173 -0
- package/es/common/foldingRange.d.ts +22 -0
- package/es/common/foldingRange.d.ts.map +1 -0
- package/es/common/foldingRange.js +127 -0
- package/es/common/formatting.d.ts +41 -0
- package/es/common/formatting.d.ts.map +1 -0
- package/es/common/formatting.js +233 -0
- package/es/common/hover.d.ts +18 -0
- package/es/common/hover.d.ts.map +1 -0
- package/es/common/hover.js +80 -0
- package/es/common/implementation.d.ts +18 -0
- package/es/common/implementation.d.ts.map +1 -0
- package/es/common/implementation.js +88 -0
- package/es/common/inlayHint.d.ts +23 -0
- package/es/common/inlayHint.d.ts.map +1 -0
- package/es/common/inlayHint.js +187 -0
- package/es/common/inlineCompletion.d.ts +20 -0
- package/es/common/inlineCompletion.d.ts.map +1 -0
- package/es/common/inlineCompletion.js +74 -0
- package/es/common/inlineValue.d.ts +21 -0
- package/es/common/inlineValue.d.ts.map +1 -0
- package/es/common/inlineValue.js +124 -0
- package/es/common/linkedEditingRange.d.ts +23 -0
- package/es/common/linkedEditingRange.d.ts.map +1 -0
- package/es/common/linkedEditingRange.js +94 -0
- package/es/common/notebook.d.ts +97 -0
- package/es/common/notebook.d.ts.map +1 -0
- package/es/common/notebook.js +1444 -0
- package/es/common/progress.d.ts +12 -0
- package/es/common/progress.d.ts.map +1 -0
- package/es/common/progress.js +75 -0
- package/es/common/progressPart.d.ts +25 -0
- package/es/common/progressPart.d.ts.map +1 -0
- package/es/common/progressPart.js +147 -0
- package/es/common/protocolCallHierarchyItem.d.ts +9 -0
- package/es/common/protocolCallHierarchyItem.d.ts.map +1 -0
- package/es/common/protocolCallHierarchyItem.js +34 -0
- package/es/common/protocolCodeAction.d.ts +7 -0
- package/es/common/protocolCodeAction.d.ts.map +1 -0
- package/es/common/protocolCodeAction.js +32 -0
- package/es/common/protocolCodeLens.d.ts +7 -0
- package/es/common/protocolCodeLens.d.ts.map +1 -0
- package/es/common/protocolCodeLens.js +29 -0
- package/es/common/protocolCompletionItem.d.ts +13 -0
- package/es/common/protocolCompletionItem.d.ts.map +1 -0
- package/es/common/protocolCompletionItem.js +29 -0
- package/es/common/protocolConverter.d.ts +174 -0
- package/es/common/protocolConverter.d.ts.map +1 -0
- package/es/common/protocolConverter.js +1982 -0
- package/es/common/protocolDiagnostic.d.ts +20 -0
- package/es/common/protocolDiagnostic.d.ts.map +1 -0
- package/es/common/protocolDiagnostic.js +46 -0
- package/es/common/protocolDocumentLink.d.ts +8 -0
- package/es/common/protocolDocumentLink.d.ts.map +1 -0
- package/es/common/protocolDocumentLink.js +29 -0
- package/es/common/protocolInlayHint.d.ts +8 -0
- package/es/common/protocolInlayHint.d.ts.map +1 -0
- package/es/common/protocolInlayHint.js +29 -0
- package/es/common/protocolTypeHierarchyItem.d.ts +9 -0
- package/es/common/protocolTypeHierarchyItem.d.ts.map +1 -0
- package/es/common/protocolTypeHierarchyItem.js +34 -0
- package/es/common/protocolWorkspaceSymbol.d.ts +9 -0
- package/es/common/protocolWorkspaceSymbol.d.ts.map +1 -0
- package/es/common/protocolWorkspaceSymbol.js +36 -0
- package/es/common/reference.d.ts +22 -0
- package/es/common/reference.d.ts.map +1 -0
- package/es/common/reference.js +78 -0
- package/es/common/rename.d.ts +29 -0
- package/es/common/rename.d.ts.map +1 -0
- package/es/common/rename.js +132 -0
- package/es/common/selectionRange.d.ts +18 -0
- package/es/common/selectionRange.d.ts.map +1 -0
- package/es/common/selectionRange.js +108 -0
- package/es/common/semanticTokens.d.ts +36 -0
- package/es/common/semanticTokens.d.ts.map +1 -0
- package/es/common/semanticTokens.js +226 -0
- package/es/common/signatureHelp.d.ts +18 -0
- package/es/common/signatureHelp.d.ts.map +1 -0
- package/es/common/signatureHelp.js +103 -0
- package/es/common/textSynchronization.d.ts +104 -0
- package/es/common/textSynchronization.d.ts.map +1 -0
- package/es/common/textSynchronization.js +771 -0
- package/es/common/typeDefinition.d.ts +18 -0
- package/es/common/typeDefinition.d.ts.map +1 -0
- package/es/common/typeDefinition.js +89 -0
- package/es/common/typeHierarchy.d.ts +33 -0
- package/es/common/typeHierarchy.d.ts.map +1 -0
- package/es/common/typeHierarchy.js +138 -0
- package/es/common/utils/async.d.ts +42 -0
- package/es/common/utils/async.d.ts.map +1 -0
- package/es/common/utils/async.js +441 -0
- package/es/common/utils/is.d.ts +13 -0
- package/es/common/utils/is.d.ts.map +1 -0
- package/es/common/utils/is.js +52 -0
- package/es/common/utils/uuid.d.ts +23 -0
- package/es/common/utils/uuid.d.ts.map +1 -0
- package/es/common/utils/uuid.js +85 -0
- package/es/common/vscodeAdaptor/convertor.d.ts +7 -0
- package/es/common/vscodeAdaptor/convertor.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/convertor.js +66 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.d.ts +33 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.js +310 -0
- package/es/common/vscodeAdaptor/extHostTypes.d.ts +1496 -0
- package/es/common/vscodeAdaptor/extHostTypes.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/extHostTypes.js +3825 -0
- package/es/common/vscodeAdaptor/fileWatcher.d.ts +19 -0
- package/es/common/vscodeAdaptor/fileWatcher.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/fileWatcher.js +45 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.d.ts +192 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.js +566 -0
- package/es/common/vscodeAdaptor/libro-fs.d.ts +21 -0
- package/es/common/vscodeAdaptor/libro-fs.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libro-fs.js +64 -0
- package/es/common/vscodeAdaptor/libroWindow.d.ts +21 -0
- package/es/common/vscodeAdaptor/libroWindow.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libroWindow.js +75 -0
- package/es/common/vscodeAdaptor/libroWorkspace.d.ts +33 -0
- package/es/common/vscodeAdaptor/libroWorkspace.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libroWorkspace.js +250 -0
- package/es/common/vscodeAdaptor/lspEnv.d.ts +8 -0
- package/es/common/vscodeAdaptor/lspEnv.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/lspEnv.js +31 -0
- package/es/common/vscodeAdaptor/monaco-converter.d.ts +229 -0
- package/es/common/vscodeAdaptor/monaco-converter.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/monaco-converter.js +1613 -0
- package/es/common/vscodeAdaptor/monacoLanguages.d.ts +48 -0
- package/es/common/vscodeAdaptor/monacoLanguages.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/monacoLanguages.js +484 -0
- package/es/common/vscodeAdaptor/services.d.ts +85 -0
- package/es/common/vscodeAdaptor/services.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/services.js +3 -0
- package/es/common/vscodeAdaptor/typings.d.ts +10 -0
- package/es/common/vscodeAdaptor/util.d.ts +3 -0
- package/es/common/vscodeAdaptor/util.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/util.js +6 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts +77 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.js +124 -0
- package/es/common/workspaceFolder.d.ts +32 -0
- package/es/common/workspaceFolder.d.ts.map +1 -0
- package/es/common/workspaceFolder.js +204 -0
- package/es/common/workspaceSymbol.d.ts +21 -0
- package/es/common/workspaceSymbol.d.ts.map +1 -0
- package/es/common/workspaceSymbol.js +101 -0
- package/es/constants.d.ts +2 -0
- package/es/constants.d.ts.map +1 -0
- package/es/constants.js +1 -0
- package/es/index.d.ts +6 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +5 -0
- package/es/libro-language-client-contribution.d.ts +10 -0
- package/es/libro-language-client-contribution.d.ts.map +1 -0
- package/es/libro-language-client-contribution.js +143 -0
- package/es/libro-language-client-manager.d.ts +34 -0
- package/es/libro-language-client-manager.d.ts.map +1 -0
- package/es/libro-language-client-manager.js +277 -0
- package/es/libro-language-client.d.ts +27 -0
- package/es/libro-language-client.d.ts.map +1 -0
- package/es/libro-language-client.js +141 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +13 -0
- package/package.json +69 -0
- package/src/common/api.ts +155 -0
- package/src/common/callHierarchy.ts +269 -0
- package/src/common/client.ts +3192 -0
- package/src/common/codeAction.ts +237 -0
- package/src/common/codeConverter.ts +1409 -0
- package/src/common/codeLens.ts +188 -0
- package/src/common/colorProvider.ts +192 -0
- package/src/common/completion.ts +281 -0
- package/src/common/configuration.ts +338 -0
- package/src/common/declaration.ts +140 -0
- package/src/common/definition.ts +138 -0
- package/src/common/diagnostic.ts +1408 -0
- package/src/common/documentHighlight.ts +140 -0
- package/src/common/documentLink.ts +180 -0
- package/src/common/documentSymbol.ts +186 -0
- package/src/common/executeCommand.ts +129 -0
- package/src/common/features.ts +1157 -0
- package/src/common/fileOperations.ts +635 -0
- package/src/common/fileSystemWatcher.ts +184 -0
- package/src/common/foldingRange.ts +160 -0
- package/src/common/formatting.ts +465 -0
- package/src/common/hover.ts +133 -0
- package/src/common/implementation.ts +142 -0
- package/src/common/inlayHint.ts +201 -0
- package/src/common/inlineCompletion.ts +160 -0
- package/src/common/inlineValue.ts +158 -0
- package/src/common/linkedEditingRange.ts +141 -0
- package/src/common/notebook.ts +1443 -0
- package/src/common/progress.ts +61 -0
- package/src/common/progressPart.ts +151 -0
- package/src/common/protocolCallHierarchyItem.ts +29 -0
- package/src/common/protocolCodeAction.ts +17 -0
- package/src/common/protocolCodeLens.ts +15 -0
- package/src/common/protocolCompletionItem.ts +22 -0
- package/src/common/protocolConverter.ts +2627 -0
- package/src/common/protocolDiagnostic.ts +47 -0
- package/src/common/protocolDocumentLink.ts +17 -0
- package/src/common/protocolInlayHint.ts +21 -0
- package/src/common/protocolTypeHierarchyItem.ts +29 -0
- package/src/common/protocolWorkspaceSymbol.ts +39 -0
- package/src/common/reference.ts +144 -0
- package/src/common/rename.ts +230 -0
- package/src/common/selectionRange.ts +136 -0
- package/src/common/semanticTokens.ts +383 -0
- package/src/common/signatureHelp.ts +170 -0
- package/src/common/textSynchronization.ts +819 -0
- package/src/common/typeDefinition.ts +146 -0
- package/src/common/typeHierarchy.ts +248 -0
- package/src/common/utils/async.ts +354 -0
- package/src/common/utils/is.ts +63 -0
- package/src/common/utils/uuid.ts +136 -0
- package/src/common/vscodeAdaptor/convertor.ts +73 -0
- package/src/common/vscodeAdaptor/diagnosticCollection.ts +238 -0
- package/src/common/vscodeAdaptor/extHostTypes.ts +4498 -0
- package/src/common/vscodeAdaptor/fileWatcher.ts +36 -0
- package/src/common/vscodeAdaptor/hostTypeUtil.ts +539 -0
- package/src/common/vscodeAdaptor/libro-fs.ts +51 -0
- package/src/common/vscodeAdaptor/libroWindow.ts +85 -0
- package/src/common/vscodeAdaptor/libroWorkspace.ts +261 -0
- package/src/common/vscodeAdaptor/lspEnv.ts +16 -0
- package/src/common/vscodeAdaptor/monaco-converter.ts +1800 -0
- package/src/common/vscodeAdaptor/monacoLanguages.ts +511 -0
- package/src/common/vscodeAdaptor/services.ts +278 -0
- package/src/common/vscodeAdaptor/typings.d.ts +10 -0
- package/src/common/vscodeAdaptor/util.ts +7 -0
- package/src/common/vscodeAdaptor/vscodeAdaptor.ts +122 -0
- package/src/common/workspaceFolder.ts +236 -0
- package/src/common/workspaceSymbol.ts +166 -0
- package/src/constants.ts +1 -0
- package/src/index.spec.ts +7 -0
- package/src/index.ts +5 -0
- package/src/libro-language-client-contribution.ts +49 -0
- package/src/libro-language-client-manager.ts +131 -0
- package/src/libro-language-client.ts +100 -0
- package/src/module.ts +19 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ClientCapabilities,
|
|
8
|
+
DidChangeConfigurationRegistrationOptions,
|
|
9
|
+
RegistrationType,
|
|
10
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
11
|
+
import {
|
|
12
|
+
ConfigurationRequest,
|
|
13
|
+
DidChangeConfigurationNotification,
|
|
14
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
15
|
+
import type {
|
|
16
|
+
Uri,
|
|
17
|
+
Disposable,
|
|
18
|
+
ConfigurationChangeEvent,
|
|
19
|
+
FileSystemWatcher as VFileSystemWatcher,
|
|
20
|
+
WorkspaceFolder as VWorkspaceFolder,
|
|
21
|
+
} from 'vscode';
|
|
22
|
+
|
|
23
|
+
import type {
|
|
24
|
+
StaticFeature,
|
|
25
|
+
FeatureClient,
|
|
26
|
+
FeatureState,
|
|
27
|
+
DynamicFeature,
|
|
28
|
+
RegistrationData,
|
|
29
|
+
} from './features.js';
|
|
30
|
+
import { ensure } from './features.js';
|
|
31
|
+
import * as Is from './utils/is.js';
|
|
32
|
+
import * as UUID from './utils/uuid.js';
|
|
33
|
+
import { workspace } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
34
|
+
|
|
35
|
+
export interface ConfigurationMiddleware {
|
|
36
|
+
configuration?: ConfigurationRequest.MiddlewareSignature;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface ConfigurationWorkspaceMiddleware {
|
|
40
|
+
workspace?: ConfigurationMiddleware;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Configuration pull model. From server to client.
|
|
45
|
+
*/
|
|
46
|
+
export class ConfigurationFeature implements StaticFeature {
|
|
47
|
+
private readonly _client: FeatureClient<ConfigurationWorkspaceMiddleware>;
|
|
48
|
+
|
|
49
|
+
constructor(client: FeatureClient<ConfigurationWorkspaceMiddleware>) {
|
|
50
|
+
this._client = client;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getState(): FeatureState {
|
|
54
|
+
return { kind: 'static' };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
58
|
+
capabilities.workspace = capabilities.workspace || {};
|
|
59
|
+
capabilities.workspace!.configuration = true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public initialize(): void {
|
|
63
|
+
const client = this._client;
|
|
64
|
+
client.onRequest(ConfigurationRequest.type, (params, token) => {
|
|
65
|
+
const configuration: ConfigurationRequest.HandlerSignature = (params) => {
|
|
66
|
+
const result: any[] = [];
|
|
67
|
+
for (const item of params.items) {
|
|
68
|
+
const resource =
|
|
69
|
+
item.scopeUri !== void 0 && item.scopeUri !== null
|
|
70
|
+
? this._client.protocol2CodeConverter.asUri(item.scopeUri)
|
|
71
|
+
: undefined;
|
|
72
|
+
result.push(
|
|
73
|
+
this.getConfiguration(
|
|
74
|
+
resource,
|
|
75
|
+
item.section !== null ? item.section : undefined,
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
const middleware = client.middleware.workspace;
|
|
82
|
+
return middleware && middleware.configuration
|
|
83
|
+
? middleware.configuration(params, token, configuration)
|
|
84
|
+
: configuration(params, token);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private getConfiguration(
|
|
89
|
+
resource: Uri | undefined,
|
|
90
|
+
section: string | undefined,
|
|
91
|
+
): any {
|
|
92
|
+
let result: any = null;
|
|
93
|
+
if (section) {
|
|
94
|
+
const index = section.lastIndexOf('.');
|
|
95
|
+
if (index === -1) {
|
|
96
|
+
result = toJSONObject(
|
|
97
|
+
workspace.getConfiguration(undefined, resource).get(section),
|
|
98
|
+
);
|
|
99
|
+
} else {
|
|
100
|
+
const config = workspace.getConfiguration(section.substr(0, index), resource);
|
|
101
|
+
if (config) {
|
|
102
|
+
result = toJSONObject(config.get(section.substr(index + 1)));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
const config = workspace.getConfiguration(undefined, resource);
|
|
107
|
+
result = {};
|
|
108
|
+
for (const key of Object.keys(config)) {
|
|
109
|
+
if (config.has(key)) {
|
|
110
|
+
result[key] = toJSONObject(config.get(key));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (result === undefined) {
|
|
115
|
+
result = null;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public clear(): void {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function toJSONObject(obj: any): any {
|
|
126
|
+
if (obj) {
|
|
127
|
+
if (Array.isArray(obj)) {
|
|
128
|
+
return obj.map(toJSONObject);
|
|
129
|
+
} else if (typeof obj === 'object') {
|
|
130
|
+
const res = Object.create(null);
|
|
131
|
+
for (const key in obj) {
|
|
132
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
133
|
+
res[key] = toJSONObject(obj[key]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return res;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return obj;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface DidChangeConfigurationSignature {
|
|
143
|
+
(this: void, sections: string[] | undefined): Promise<void>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface DidChangeConfigurationMiddleware {
|
|
147
|
+
didChangeConfiguration?: (
|
|
148
|
+
this: void,
|
|
149
|
+
sections: string[] | undefined,
|
|
150
|
+
next: DidChangeConfigurationSignature,
|
|
151
|
+
) => Promise<void>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
interface DidChangeConfigurationWorkspaceMiddleware {
|
|
155
|
+
workspace?: DidChangeConfigurationMiddleware;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type SynchronizeOptions = {
|
|
159
|
+
/**
|
|
160
|
+
* The configuration sections to synchronize. Pushing settings from the
|
|
161
|
+
* client to the server is deprecated in favour of the new pull model
|
|
162
|
+
* that allows servers to query settings scoped on resources. In this
|
|
163
|
+
* model the client can only deliver an empty change event since the
|
|
164
|
+
* actually setting value can vary on the provided resource scope.
|
|
165
|
+
*
|
|
166
|
+
* @deprecated Use the new pull model (`workspace/configuration` request)
|
|
167
|
+
*/
|
|
168
|
+
configurationSection?: string | string[];
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Asks the client to send file change events to the server. Watchers
|
|
172
|
+
* operate on workspace folders. The LSP client doesn't support watching
|
|
173
|
+
* files outside a workspace folder.
|
|
174
|
+
*/
|
|
175
|
+
fileEvents?: VFileSystemWatcher | VFileSystemWatcher[];
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export type $ConfigurationOptions = {
|
|
179
|
+
synchronize?: SynchronizeOptions;
|
|
180
|
+
workspaceFolder?: VWorkspaceFolder;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export class SyncConfigurationFeature
|
|
184
|
+
implements DynamicFeature<DidChangeConfigurationRegistrationOptions>
|
|
185
|
+
{
|
|
186
|
+
private isCleared: boolean;
|
|
187
|
+
private readonly _listeners: Map<string, Disposable>;
|
|
188
|
+
|
|
189
|
+
constructor(
|
|
190
|
+
private _client: FeatureClient<
|
|
191
|
+
DidChangeConfigurationWorkspaceMiddleware,
|
|
192
|
+
$ConfigurationOptions
|
|
193
|
+
>,
|
|
194
|
+
) {
|
|
195
|
+
this.isCleared = false;
|
|
196
|
+
this._listeners = new Map();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public getState(): FeatureState {
|
|
200
|
+
return {
|
|
201
|
+
kind: 'workspace',
|
|
202
|
+
id: this.registrationType.method,
|
|
203
|
+
registrations: this._listeners.size > 0,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
public get registrationType(): RegistrationType<DidChangeConfigurationRegistrationOptions> {
|
|
208
|
+
return DidChangeConfigurationNotification.type;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
212
|
+
ensure(
|
|
213
|
+
ensure(capabilities, 'workspace')!,
|
|
214
|
+
'didChangeConfiguration',
|
|
215
|
+
)!.dynamicRegistration = true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public initialize(): void {
|
|
219
|
+
this.isCleared = false;
|
|
220
|
+
const section = this._client.clientOptions.synchronize?.configurationSection;
|
|
221
|
+
if (section !== undefined) {
|
|
222
|
+
this.register({
|
|
223
|
+
id: UUID.generateUuid(),
|
|
224
|
+
registerOptions: {
|
|
225
|
+
section: section,
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public register(
|
|
232
|
+
data: RegistrationData<DidChangeConfigurationRegistrationOptions>,
|
|
233
|
+
): void {
|
|
234
|
+
const disposable = workspace.onDidChangeConfiguration((event) => {
|
|
235
|
+
this.onDidChangeConfiguration(data.registerOptions.section, event);
|
|
236
|
+
});
|
|
237
|
+
this._listeners.set(data.id, disposable);
|
|
238
|
+
if (data.registerOptions.section !== undefined) {
|
|
239
|
+
this.onDidChangeConfiguration(data.registerOptions.section, undefined);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
public unregister(id: string): void {
|
|
244
|
+
const disposable = this._listeners.get(id);
|
|
245
|
+
if (disposable) {
|
|
246
|
+
this._listeners.delete(id);
|
|
247
|
+
disposable.dispose();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
public clear(): void {
|
|
252
|
+
for (const disposable of this._listeners.values()) {
|
|
253
|
+
disposable.dispose();
|
|
254
|
+
}
|
|
255
|
+
this._listeners.clear();
|
|
256
|
+
this.isCleared = true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private onDidChangeConfiguration(
|
|
260
|
+
configurationSection: string | string[] | undefined,
|
|
261
|
+
event: ConfigurationChangeEvent | undefined,
|
|
262
|
+
): void {
|
|
263
|
+
if (this.isCleared) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
let sections: string[] | undefined;
|
|
267
|
+
if (Is.string(configurationSection)) {
|
|
268
|
+
sections = [configurationSection];
|
|
269
|
+
} else {
|
|
270
|
+
sections = configurationSection;
|
|
271
|
+
}
|
|
272
|
+
if (sections !== undefined && event !== undefined) {
|
|
273
|
+
const affected = sections.some((section) => event.affectsConfiguration(section));
|
|
274
|
+
if (!affected) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const didChangeConfiguration = async (
|
|
279
|
+
sections: string[] | undefined,
|
|
280
|
+
): Promise<void> => {
|
|
281
|
+
if (sections === undefined) {
|
|
282
|
+
return this._client.sendNotification(DidChangeConfigurationNotification.type, {
|
|
283
|
+
settings: null,
|
|
284
|
+
});
|
|
285
|
+
} else {
|
|
286
|
+
return this._client.sendNotification(DidChangeConfigurationNotification.type, {
|
|
287
|
+
settings: this.extractSettingsInformation(sections),
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const middleware = this._client.middleware.workspace?.didChangeConfiguration;
|
|
292
|
+
(middleware
|
|
293
|
+
? middleware(sections, didChangeConfiguration)
|
|
294
|
+
: didChangeConfiguration(sections)
|
|
295
|
+
).catch((error) => {
|
|
296
|
+
this._client.error(
|
|
297
|
+
`Sending notification ${DidChangeConfigurationNotification.type.method} failed`,
|
|
298
|
+
error,
|
|
299
|
+
);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private extractSettingsInformation(keys: string[]): any {
|
|
304
|
+
function ensurePath(config: any, path: string[]): any {
|
|
305
|
+
let current = config;
|
|
306
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
307
|
+
let obj = current[path[i]];
|
|
308
|
+
if (!obj) {
|
|
309
|
+
obj = Object.create(null);
|
|
310
|
+
current[path[i]] = obj;
|
|
311
|
+
}
|
|
312
|
+
current = obj;
|
|
313
|
+
}
|
|
314
|
+
return current;
|
|
315
|
+
}
|
|
316
|
+
const resource: Uri | undefined = this._client.clientOptions.workspaceFolder
|
|
317
|
+
? this._client.clientOptions.workspaceFolder.uri
|
|
318
|
+
: undefined;
|
|
319
|
+
const result = Object.create(null);
|
|
320
|
+
for (let i = 0; i < keys.length; i++) {
|
|
321
|
+
const key = keys[i];
|
|
322
|
+
const index: number = key.indexOf('.');
|
|
323
|
+
let config: any = null;
|
|
324
|
+
if (index >= 0) {
|
|
325
|
+
config = workspace
|
|
326
|
+
.getConfiguration(key.substr(0, index), resource)
|
|
327
|
+
.get(key.substr(index + 1));
|
|
328
|
+
} else {
|
|
329
|
+
config = workspace.getConfiguration(undefined, resource).get(key);
|
|
330
|
+
}
|
|
331
|
+
if (config) {
|
|
332
|
+
const path = keys[i].split('.');
|
|
333
|
+
ensurePath(result, path)[path[path.length - 1]] = toJSONObject(config);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ClientCapabilities,
|
|
8
|
+
CancellationToken,
|
|
9
|
+
ServerCapabilities,
|
|
10
|
+
DocumentSelector,
|
|
11
|
+
DeclarationRegistrationOptions,
|
|
12
|
+
DeclarationOptions,
|
|
13
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
14
|
+
import { DeclarationRequest } from '@difizen/vscode-languageserver-protocol';
|
|
15
|
+
import type {
|
|
16
|
+
Disposable,
|
|
17
|
+
TextDocument,
|
|
18
|
+
ProviderResult,
|
|
19
|
+
Position as VPosition,
|
|
20
|
+
Declaration as VDeclaration,
|
|
21
|
+
DeclarationProvider,
|
|
22
|
+
} from 'vscode';
|
|
23
|
+
|
|
24
|
+
import type { FeatureClient } from './features.js';
|
|
25
|
+
import { TextDocumentLanguageFeature, ensure } from './features.js';
|
|
26
|
+
import { languages as Languages } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
27
|
+
|
|
28
|
+
export interface ProvideDeclarationSignature {
|
|
29
|
+
(
|
|
30
|
+
this: void,
|
|
31
|
+
document: TextDocument,
|
|
32
|
+
position: VPosition,
|
|
33
|
+
token: CancellationToken,
|
|
34
|
+
): ProviderResult<VDeclaration>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface DeclarationMiddleware {
|
|
38
|
+
provideDeclaration?: (
|
|
39
|
+
this: void,
|
|
40
|
+
document: TextDocument,
|
|
41
|
+
position: VPosition,
|
|
42
|
+
token: CancellationToken,
|
|
43
|
+
next: ProvideDeclarationSignature,
|
|
44
|
+
) => ProviderResult<VDeclaration>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class DeclarationFeature extends TextDocumentLanguageFeature<
|
|
48
|
+
boolean | DeclarationOptions,
|
|
49
|
+
DeclarationRegistrationOptions,
|
|
50
|
+
DeclarationProvider,
|
|
51
|
+
DeclarationMiddleware
|
|
52
|
+
> {
|
|
53
|
+
constructor(client: FeatureClient<DeclarationMiddleware>) {
|
|
54
|
+
super(client, DeclarationRequest.type);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
58
|
+
const declarationSupport = ensure(
|
|
59
|
+
ensure(capabilities, 'textDocument')!,
|
|
60
|
+
'declaration',
|
|
61
|
+
)!;
|
|
62
|
+
declarationSupport.dynamicRegistration = true;
|
|
63
|
+
declarationSupport.linkSupport = true;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public initialize(
|
|
67
|
+
capabilities: ServerCapabilities,
|
|
68
|
+
documentSelector: DocumentSelector,
|
|
69
|
+
): void {
|
|
70
|
+
const [id, options] = this.getRegistration(
|
|
71
|
+
documentSelector,
|
|
72
|
+
capabilities.declarationProvider,
|
|
73
|
+
);
|
|
74
|
+
if (!id || !options) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.register({ id: id, registerOptions: options });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected registerLanguageProvider(
|
|
81
|
+
options: DeclarationRegistrationOptions,
|
|
82
|
+
): [Disposable, DeclarationProvider] {
|
|
83
|
+
const selector = options.documentSelector!;
|
|
84
|
+
const provider: DeclarationProvider = {
|
|
85
|
+
provideDeclaration: (
|
|
86
|
+
document: TextDocument,
|
|
87
|
+
position: VPosition,
|
|
88
|
+
token: CancellationToken,
|
|
89
|
+
): ProviderResult<VDeclaration> => {
|
|
90
|
+
const client = this._client;
|
|
91
|
+
const provideDeclaration: ProvideDeclarationSignature = (
|
|
92
|
+
document,
|
|
93
|
+
position,
|
|
94
|
+
token,
|
|
95
|
+
) => {
|
|
96
|
+
return client
|
|
97
|
+
.sendRequest(
|
|
98
|
+
DeclarationRequest.type,
|
|
99
|
+
client.code2ProtocolConverter.asTextDocumentPositionParams(
|
|
100
|
+
document,
|
|
101
|
+
position,
|
|
102
|
+
),
|
|
103
|
+
token,
|
|
104
|
+
)
|
|
105
|
+
.then(
|
|
106
|
+
(result) => {
|
|
107
|
+
if (token.isCancellationRequested) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return client.protocol2CodeConverter.asDeclarationResult(result, token);
|
|
111
|
+
},
|
|
112
|
+
(error) => {
|
|
113
|
+
return client.handleFailedRequest(
|
|
114
|
+
DeclarationRequest.type,
|
|
115
|
+
token,
|
|
116
|
+
error,
|
|
117
|
+
null,
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
const middleware = client.middleware;
|
|
123
|
+
return middleware.provideDeclaration
|
|
124
|
+
? middleware.provideDeclaration(document, position, token, provideDeclaration)
|
|
125
|
+
: provideDeclaration(document, position, token);
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
return [this.registerProvider(selector, provider), provider];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private registerProvider(
|
|
132
|
+
selector: DocumentSelector,
|
|
133
|
+
provider: DeclarationProvider,
|
|
134
|
+
): Disposable {
|
|
135
|
+
return Languages.registerDeclarationProvider(
|
|
136
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
137
|
+
provider,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ClientCapabilities,
|
|
8
|
+
DefinitionOptions,
|
|
9
|
+
DefinitionRegistrationOptions,
|
|
10
|
+
DocumentSelector,
|
|
11
|
+
ServerCapabilities,
|
|
12
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
13
|
+
import { DefinitionRequest } from '@difizen/vscode-languageserver-protocol';
|
|
14
|
+
import type {
|
|
15
|
+
TextDocument,
|
|
16
|
+
Disposable,
|
|
17
|
+
Position as VPosition,
|
|
18
|
+
CancellationToken,
|
|
19
|
+
ProviderResult,
|
|
20
|
+
DefinitionProvider,
|
|
21
|
+
Definition as VDefinition,
|
|
22
|
+
DefinitionLink as VDefinitionLink,
|
|
23
|
+
} from 'vscode';
|
|
24
|
+
|
|
25
|
+
import type { FeatureClient } from './features.js';
|
|
26
|
+
import { ensure, TextDocumentLanguageFeature } from './features.js';
|
|
27
|
+
import * as UUID from './utils/uuid.js';
|
|
28
|
+
import { languages as Languages } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
29
|
+
|
|
30
|
+
export interface ProvideDefinitionSignature {
|
|
31
|
+
(
|
|
32
|
+
this: void,
|
|
33
|
+
document: TextDocument,
|
|
34
|
+
position: VPosition,
|
|
35
|
+
token: CancellationToken,
|
|
36
|
+
): ProviderResult<VDefinition | VDefinitionLink[]>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DefinitionMiddleware {
|
|
40
|
+
provideDefinition?: (
|
|
41
|
+
this: void,
|
|
42
|
+
document: TextDocument,
|
|
43
|
+
position: VPosition,
|
|
44
|
+
token: CancellationToken,
|
|
45
|
+
next: ProvideDefinitionSignature,
|
|
46
|
+
) => ProviderResult<VDefinition | VDefinitionLink[]>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class DefinitionFeature extends TextDocumentLanguageFeature<
|
|
50
|
+
boolean | DefinitionOptions,
|
|
51
|
+
DefinitionRegistrationOptions,
|
|
52
|
+
DefinitionProvider,
|
|
53
|
+
DefinitionMiddleware
|
|
54
|
+
> {
|
|
55
|
+
constructor(client: FeatureClient<DefinitionMiddleware>) {
|
|
56
|
+
super(client, DefinitionRequest.type);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
60
|
+
const definitionSupport = ensure(
|
|
61
|
+
ensure(capabilities, 'textDocument')!,
|
|
62
|
+
'definition',
|
|
63
|
+
)!;
|
|
64
|
+
definitionSupport.dynamicRegistration = true;
|
|
65
|
+
definitionSupport.linkSupport = true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public initialize(
|
|
69
|
+
capabilities: ServerCapabilities,
|
|
70
|
+
documentSelector: DocumentSelector,
|
|
71
|
+
): void {
|
|
72
|
+
const options = this.getRegistrationOptions(
|
|
73
|
+
documentSelector,
|
|
74
|
+
capabilities.definitionProvider,
|
|
75
|
+
);
|
|
76
|
+
if (!options) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.register({ id: UUID.generateUuid(), registerOptions: options });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected registerLanguageProvider(
|
|
83
|
+
options: DefinitionRegistrationOptions,
|
|
84
|
+
): [Disposable, DefinitionProvider] {
|
|
85
|
+
const selector = options.documentSelector!;
|
|
86
|
+
const provider: DefinitionProvider = {
|
|
87
|
+
provideDefinition: (document, position, token) => {
|
|
88
|
+
const client = this._client;
|
|
89
|
+
const provideDefinition: ProvideDefinitionSignature = (
|
|
90
|
+
document,
|
|
91
|
+
position,
|
|
92
|
+
token,
|
|
93
|
+
) => {
|
|
94
|
+
return client
|
|
95
|
+
.sendRequest(
|
|
96
|
+
DefinitionRequest.type,
|
|
97
|
+
client.code2ProtocolConverter.asTextDocumentPositionParams(
|
|
98
|
+
document,
|
|
99
|
+
position,
|
|
100
|
+
),
|
|
101
|
+
token,
|
|
102
|
+
)
|
|
103
|
+
.then(
|
|
104
|
+
(result) => {
|
|
105
|
+
if (token.isCancellationRequested) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return client.protocol2CodeConverter.asDefinitionResult(result, token);
|
|
109
|
+
},
|
|
110
|
+
(error) => {
|
|
111
|
+
return client.handleFailedRequest(
|
|
112
|
+
DefinitionRequest.type,
|
|
113
|
+
token,
|
|
114
|
+
error,
|
|
115
|
+
null,
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
const middleware = client.middleware;
|
|
121
|
+
return middleware.provideDefinition
|
|
122
|
+
? middleware.provideDefinition(document, position, token, provideDefinition)
|
|
123
|
+
: provideDefinition(document, position, token);
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
return [this.registerProvider(selector, provider), provider];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private registerProvider(
|
|
130
|
+
selector: DocumentSelector,
|
|
131
|
+
provider: DefinitionProvider,
|
|
132
|
+
): Disposable {
|
|
133
|
+
return Languages.registerDefinitionProvider(
|
|
134
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
135
|
+
provider,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|