@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,142 @@
|
|
|
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
|
+
ImplementationRegistrationOptions,
|
|
12
|
+
ImplementationOptions,
|
|
13
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
14
|
+
import { ImplementationRequest } from '@difizen/vscode-languageserver-protocol';
|
|
15
|
+
import type {
|
|
16
|
+
Disposable,
|
|
17
|
+
TextDocument,
|
|
18
|
+
ProviderResult,
|
|
19
|
+
Position as VPosition,
|
|
20
|
+
Definition as VDefinition,
|
|
21
|
+
DefinitionLink as VDefinitionLink,
|
|
22
|
+
ImplementationProvider,
|
|
23
|
+
} from 'vscode';
|
|
24
|
+
|
|
25
|
+
import type { FeatureClient } from './features.js';
|
|
26
|
+
import { TextDocumentLanguageFeature, ensure } from './features.js';
|
|
27
|
+
import { languages as Languages } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
28
|
+
|
|
29
|
+
export interface ProvideImplementationSignature {
|
|
30
|
+
(
|
|
31
|
+
this: void,
|
|
32
|
+
document: TextDocument,
|
|
33
|
+
position: VPosition,
|
|
34
|
+
token: CancellationToken,
|
|
35
|
+
): ProviderResult<VDefinition | VDefinitionLink[]>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ImplementationMiddleware {
|
|
39
|
+
provideImplementation?: (
|
|
40
|
+
this: void,
|
|
41
|
+
document: TextDocument,
|
|
42
|
+
position: VPosition,
|
|
43
|
+
token: CancellationToken,
|
|
44
|
+
next: ProvideImplementationSignature,
|
|
45
|
+
) => ProviderResult<VDefinition | VDefinitionLink[]>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class ImplementationFeature extends TextDocumentLanguageFeature<
|
|
49
|
+
boolean | ImplementationOptions,
|
|
50
|
+
ImplementationRegistrationOptions,
|
|
51
|
+
ImplementationProvider,
|
|
52
|
+
ImplementationMiddleware
|
|
53
|
+
> {
|
|
54
|
+
constructor(client: FeatureClient<ImplementationMiddleware>) {
|
|
55
|
+
super(client, ImplementationRequest.type);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
59
|
+
const implementationSupport = ensure(
|
|
60
|
+
ensure(capabilities, 'textDocument')!,
|
|
61
|
+
'implementation',
|
|
62
|
+
)!;
|
|
63
|
+
implementationSupport.dynamicRegistration = true;
|
|
64
|
+
implementationSupport.linkSupport = true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public initialize(
|
|
68
|
+
capabilities: ServerCapabilities,
|
|
69
|
+
documentSelector: DocumentSelector,
|
|
70
|
+
): void {
|
|
71
|
+
const [id, options] = this.getRegistration(
|
|
72
|
+
documentSelector,
|
|
73
|
+
capabilities.implementationProvider,
|
|
74
|
+
);
|
|
75
|
+
if (!id || !options) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.register({ id: id, registerOptions: options });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
protected registerLanguageProvider(
|
|
82
|
+
options: ImplementationRegistrationOptions,
|
|
83
|
+
): [Disposable, ImplementationProvider] {
|
|
84
|
+
const selector = options.documentSelector!;
|
|
85
|
+
const provider: ImplementationProvider = {
|
|
86
|
+
provideImplementation: (document, position, token) => {
|
|
87
|
+
const client = this._client;
|
|
88
|
+
const provideImplementation: ProvideImplementationSignature = (
|
|
89
|
+
document,
|
|
90
|
+
position,
|
|
91
|
+
token,
|
|
92
|
+
) => {
|
|
93
|
+
return client
|
|
94
|
+
.sendRequest(
|
|
95
|
+
ImplementationRequest.type,
|
|
96
|
+
client.code2ProtocolConverter.asTextDocumentPositionParams(
|
|
97
|
+
document,
|
|
98
|
+
position,
|
|
99
|
+
),
|
|
100
|
+
token,
|
|
101
|
+
)
|
|
102
|
+
.then(
|
|
103
|
+
(result) => {
|
|
104
|
+
if (token.isCancellationRequested) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return client.protocol2CodeConverter.asDefinitionResult(result, token);
|
|
108
|
+
},
|
|
109
|
+
(error) => {
|
|
110
|
+
return client.handleFailedRequest(
|
|
111
|
+
ImplementationRequest.type,
|
|
112
|
+
token,
|
|
113
|
+
error,
|
|
114
|
+
null,
|
|
115
|
+
);
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
const middleware = client.middleware;
|
|
120
|
+
return middleware.provideImplementation
|
|
121
|
+
? middleware.provideImplementation(
|
|
122
|
+
document,
|
|
123
|
+
position,
|
|
124
|
+
token,
|
|
125
|
+
provideImplementation,
|
|
126
|
+
)
|
|
127
|
+
: provideImplementation(document, position, token);
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
return [this.registerProvider(selector, provider), provider];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private registerProvider(
|
|
134
|
+
selector: DocumentSelector,
|
|
135
|
+
provider: ImplementationProvider,
|
|
136
|
+
): Disposable {
|
|
137
|
+
return Languages.registerImplementationProvider(
|
|
138
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
139
|
+
provider,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
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
|
+
InlayHintOptions,
|
|
12
|
+
InlayHintRegistrationOptions,
|
|
13
|
+
InlayHintParams,
|
|
14
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
15
|
+
import {
|
|
16
|
+
InlayHintRequest,
|
|
17
|
+
InlayHintRefreshRequest,
|
|
18
|
+
InlayHintResolveRequest,
|
|
19
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
20
|
+
import type {
|
|
21
|
+
Disposable,
|
|
22
|
+
TextDocument,
|
|
23
|
+
ProviderResult,
|
|
24
|
+
Range as VRange,
|
|
25
|
+
InlayHint as VInlayHint,
|
|
26
|
+
InlayHintsProvider,
|
|
27
|
+
} from 'vscode';
|
|
28
|
+
|
|
29
|
+
import type { FeatureClient } from './features.js';
|
|
30
|
+
import { TextDocumentLanguageFeature, ensure } from './features.js';
|
|
31
|
+
import { languages as Languages, EventEmitter } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
32
|
+
|
|
33
|
+
export type ProvideInlayHintsSignature = (
|
|
34
|
+
this: void,
|
|
35
|
+
document: TextDocument,
|
|
36
|
+
viewPort: VRange,
|
|
37
|
+
token: CancellationToken,
|
|
38
|
+
) => ProviderResult<VInlayHint[]>;
|
|
39
|
+
export type ResolveInlayHintSignature = (
|
|
40
|
+
this: void,
|
|
41
|
+
item: VInlayHint,
|
|
42
|
+
token: CancellationToken,
|
|
43
|
+
) => ProviderResult<VInlayHint>;
|
|
44
|
+
|
|
45
|
+
export type InlayHintsMiddleware = {
|
|
46
|
+
provideInlayHints?: (
|
|
47
|
+
this: void,
|
|
48
|
+
document: TextDocument,
|
|
49
|
+
viewPort: VRange,
|
|
50
|
+
token: CancellationToken,
|
|
51
|
+
next: ProvideInlayHintsSignature,
|
|
52
|
+
) => ProviderResult<VInlayHint[]>;
|
|
53
|
+
resolveInlayHint?: (
|
|
54
|
+
this: void,
|
|
55
|
+
item: VInlayHint,
|
|
56
|
+
token: CancellationToken,
|
|
57
|
+
next: ResolveInlayHintSignature,
|
|
58
|
+
) => ProviderResult<VInlayHint>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type InlayHintsProviderShape = {
|
|
62
|
+
provider: InlayHintsProvider;
|
|
63
|
+
onDidChangeInlayHints: EventEmitter<void>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export class InlayHintsFeature extends TextDocumentLanguageFeature<
|
|
67
|
+
boolean | InlayHintOptions,
|
|
68
|
+
InlayHintRegistrationOptions,
|
|
69
|
+
InlayHintsProviderShape,
|
|
70
|
+
InlayHintsMiddleware
|
|
71
|
+
> {
|
|
72
|
+
constructor(client: FeatureClient<InlayHintsMiddleware>) {
|
|
73
|
+
super(client, InlayHintRequest.type);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
77
|
+
const inlayHint = ensure(ensure(capabilities, 'textDocument')!, 'inlayHint')!;
|
|
78
|
+
inlayHint.dynamicRegistration = true;
|
|
79
|
+
inlayHint.resolveSupport = {
|
|
80
|
+
properties: [
|
|
81
|
+
'tooltip',
|
|
82
|
+
'textEdits',
|
|
83
|
+
'label.tooltip',
|
|
84
|
+
'label.location',
|
|
85
|
+
'label.command',
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
ensure(ensure(capabilities, 'workspace')!, 'inlayHint')!.refreshSupport = true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public initialize(
|
|
92
|
+
capabilities: ServerCapabilities,
|
|
93
|
+
documentSelector: DocumentSelector,
|
|
94
|
+
): void {
|
|
95
|
+
this._client.onRequest(InlayHintRefreshRequest.type, async () => {
|
|
96
|
+
for (const provider of this.getAllProviders()) {
|
|
97
|
+
provider.onDidChangeInlayHints.fire();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const [id, options] = this.getRegistration(
|
|
102
|
+
documentSelector,
|
|
103
|
+
capabilities.inlayHintProvider,
|
|
104
|
+
);
|
|
105
|
+
if (!id || !options) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.register({ id: id, registerOptions: options });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
protected registerLanguageProvider(
|
|
112
|
+
options: InlayHintRegistrationOptions,
|
|
113
|
+
): [Disposable, InlayHintsProviderShape] {
|
|
114
|
+
const selector = options.documentSelector!;
|
|
115
|
+
const eventEmitter: EventEmitter<void> = new EventEmitter<void>();
|
|
116
|
+
const provider: InlayHintsProvider = {
|
|
117
|
+
onDidChangeInlayHints: eventEmitter.event,
|
|
118
|
+
provideInlayHints: (document, viewPort, token) => {
|
|
119
|
+
const client = this._client;
|
|
120
|
+
const provideInlayHints: ProvideInlayHintsSignature = async (
|
|
121
|
+
document,
|
|
122
|
+
viewPort,
|
|
123
|
+
token,
|
|
124
|
+
) => {
|
|
125
|
+
const requestParams: InlayHintParams = {
|
|
126
|
+
textDocument:
|
|
127
|
+
client.code2ProtocolConverter.asTextDocumentIdentifier(document),
|
|
128
|
+
range: client.code2ProtocolConverter.asRange(viewPort),
|
|
129
|
+
};
|
|
130
|
+
try {
|
|
131
|
+
const values = await client.sendRequest(
|
|
132
|
+
InlayHintRequest.type,
|
|
133
|
+
requestParams,
|
|
134
|
+
token,
|
|
135
|
+
);
|
|
136
|
+
if (token.isCancellationRequested) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return client.protocol2CodeConverter.asInlayHints(values, token);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
return client.handleFailedRequest(
|
|
142
|
+
InlayHintRequest.type,
|
|
143
|
+
token,
|
|
144
|
+
error,
|
|
145
|
+
null,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const middleware = client.middleware;
|
|
150
|
+
return middleware.provideInlayHints
|
|
151
|
+
? middleware.provideInlayHints(document, viewPort, token, provideInlayHints)
|
|
152
|
+
: provideInlayHints(document, viewPort, token);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
provider.resolveInlayHint =
|
|
156
|
+
options.resolveProvider === true
|
|
157
|
+
? (hint, token) => {
|
|
158
|
+
const client = this._client;
|
|
159
|
+
const resolveInlayHint: ResolveInlayHintSignature = async (item, token) => {
|
|
160
|
+
try {
|
|
161
|
+
const value = await client.sendRequest(
|
|
162
|
+
InlayHintResolveRequest.type,
|
|
163
|
+
client.code2ProtocolConverter.asInlayHint(item),
|
|
164
|
+
token,
|
|
165
|
+
);
|
|
166
|
+
if (token.isCancellationRequested) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
const result = client.protocol2CodeConverter.asInlayHint(value, token);
|
|
170
|
+
return token.isCancellationRequested ? null : result;
|
|
171
|
+
} catch (error) {
|
|
172
|
+
return client.handleFailedRequest(
|
|
173
|
+
InlayHintResolveRequest.type,
|
|
174
|
+
token,
|
|
175
|
+
error,
|
|
176
|
+
null,
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const middleware = client.middleware;
|
|
181
|
+
return middleware.resolveInlayHint
|
|
182
|
+
? middleware.resolveInlayHint(hint, token, resolveInlayHint)
|
|
183
|
+
: resolveInlayHint(hint, token);
|
|
184
|
+
}
|
|
185
|
+
: undefined;
|
|
186
|
+
return [
|
|
187
|
+
this.registerProvider(selector, provider),
|
|
188
|
+
{ provider: provider, onDidChangeInlayHints: eventEmitter },
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private registerProvider(
|
|
193
|
+
selector: DocumentSelector,
|
|
194
|
+
provider: InlayHintsProvider,
|
|
195
|
+
): Disposable {
|
|
196
|
+
return Languages.registerInlayHintsProvider(
|
|
197
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
198
|
+
provider,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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
|
+
InlineCompletionOptions,
|
|
9
|
+
InlineCompletionRegistrationOptions,
|
|
10
|
+
DocumentSelector,
|
|
11
|
+
ServerCapabilities,
|
|
12
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
13
|
+
import { InlineCompletionRequest } from '@difizen/vscode-languageserver-protocol';
|
|
14
|
+
import type {
|
|
15
|
+
TextDocument,
|
|
16
|
+
Disposable,
|
|
17
|
+
Position as VPosition,
|
|
18
|
+
InlineCompletionContext as VInlineCompletionContext,
|
|
19
|
+
CancellationToken,
|
|
20
|
+
ProviderResult,
|
|
21
|
+
InlineCompletionItem as VInlineCompletionItem,
|
|
22
|
+
InlineCompletionList as VInlineCompletionList,
|
|
23
|
+
InlineCompletionItemProvider,
|
|
24
|
+
} from 'vscode';
|
|
25
|
+
|
|
26
|
+
import type { FeatureClient } from './features.js';
|
|
27
|
+
import { ensure, TextDocumentLanguageFeature } from './features.js';
|
|
28
|
+
import * as UUID from './utils/uuid.js';
|
|
29
|
+
import { languages as Languages } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
30
|
+
|
|
31
|
+
export interface ProvideInlineCompletionItemsSignature {
|
|
32
|
+
(
|
|
33
|
+
this: void,
|
|
34
|
+
document: TextDocument,
|
|
35
|
+
position: VPosition,
|
|
36
|
+
context: VInlineCompletionContext,
|
|
37
|
+
token: CancellationToken,
|
|
38
|
+
): ProviderResult<VInlineCompletionItem[] | VInlineCompletionList>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface InlineCompletionMiddleware {
|
|
42
|
+
provideInlineCompletionItems?: (
|
|
43
|
+
this: void,
|
|
44
|
+
document: TextDocument,
|
|
45
|
+
position: VPosition,
|
|
46
|
+
context: VInlineCompletionContext,
|
|
47
|
+
token: CancellationToken,
|
|
48
|
+
next: ProvideInlineCompletionItemsSignature,
|
|
49
|
+
) => ProviderResult<VInlineCompletionItem[] | VInlineCompletionList>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type InlineCompletionProviderShape = {
|
|
53
|
+
provider: InlineCompletionItemProvider;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export class InlineCompletionItemFeature extends TextDocumentLanguageFeature<
|
|
57
|
+
boolean | InlineCompletionOptions,
|
|
58
|
+
InlineCompletionRegistrationOptions,
|
|
59
|
+
InlineCompletionItemProvider,
|
|
60
|
+
InlineCompletionMiddleware
|
|
61
|
+
> {
|
|
62
|
+
constructor(client: FeatureClient<InlineCompletionMiddleware>) {
|
|
63
|
+
super(client, InlineCompletionRequest.type);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
67
|
+
const inlineCompletion = ensure(
|
|
68
|
+
ensure(capabilities, 'textDocument')!,
|
|
69
|
+
'inlineCompletion',
|
|
70
|
+
)!;
|
|
71
|
+
inlineCompletion.dynamicRegistration = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public initialize(
|
|
75
|
+
capabilities: ServerCapabilities,
|
|
76
|
+
documentSelector: DocumentSelector,
|
|
77
|
+
): void {
|
|
78
|
+
const options = this.getRegistrationOptions(
|
|
79
|
+
documentSelector,
|
|
80
|
+
capabilities.inlineCompletionProvider,
|
|
81
|
+
);
|
|
82
|
+
if (!options) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.register({
|
|
87
|
+
id: UUID.generateUuid(),
|
|
88
|
+
registerOptions: options,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected registerLanguageProvider(
|
|
93
|
+
options: InlineCompletionRegistrationOptions,
|
|
94
|
+
): [Disposable, InlineCompletionItemProvider] {
|
|
95
|
+
const selector = options.documentSelector!;
|
|
96
|
+
const provider: InlineCompletionItemProvider = {
|
|
97
|
+
provideInlineCompletionItems: (
|
|
98
|
+
document: TextDocument,
|
|
99
|
+
position: VPosition,
|
|
100
|
+
context: VInlineCompletionContext,
|
|
101
|
+
token: CancellationToken,
|
|
102
|
+
): ProviderResult<VInlineCompletionList | VInlineCompletionItem[]> => {
|
|
103
|
+
const client = this._client;
|
|
104
|
+
const middleware = this._client.middleware;
|
|
105
|
+
const provideInlineCompletionItems: ProvideInlineCompletionItemsSignature = (
|
|
106
|
+
document,
|
|
107
|
+
position,
|
|
108
|
+
context,
|
|
109
|
+
token,
|
|
110
|
+
) => {
|
|
111
|
+
return client
|
|
112
|
+
.sendRequest(
|
|
113
|
+
InlineCompletionRequest.type,
|
|
114
|
+
client.code2ProtocolConverter.asInlineCompletionParams(
|
|
115
|
+
document,
|
|
116
|
+
position,
|
|
117
|
+
context,
|
|
118
|
+
),
|
|
119
|
+
token,
|
|
120
|
+
)
|
|
121
|
+
.then(
|
|
122
|
+
(result) => {
|
|
123
|
+
if (token.isCancellationRequested) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return client.protocol2CodeConverter.asInlineCompletionResult(
|
|
127
|
+
result,
|
|
128
|
+
token,
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
(error) => {
|
|
132
|
+
return client.handleFailedRequest(
|
|
133
|
+
InlineCompletionRequest.type,
|
|
134
|
+
token,
|
|
135
|
+
error,
|
|
136
|
+
null,
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
return middleware.provideInlineCompletionItems
|
|
142
|
+
? middleware.provideInlineCompletionItems(
|
|
143
|
+
document,
|
|
144
|
+
position,
|
|
145
|
+
context,
|
|
146
|
+
token,
|
|
147
|
+
provideInlineCompletionItems,
|
|
148
|
+
)
|
|
149
|
+
: provideInlineCompletionItems(document, position, context, token);
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
return [
|
|
153
|
+
Languages.registerInlineCompletionItemProvider(
|
|
154
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
155
|
+
provider,
|
|
156
|
+
),
|
|
157
|
+
provider,
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
InlineValueOptions,
|
|
12
|
+
InlineValueRegistrationOptions,
|
|
13
|
+
InlineValueParams,
|
|
14
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
15
|
+
import {
|
|
16
|
+
InlineValueRefreshRequest,
|
|
17
|
+
InlineValueRequest,
|
|
18
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
19
|
+
import type {
|
|
20
|
+
Disposable,
|
|
21
|
+
TextDocument,
|
|
22
|
+
ProviderResult,
|
|
23
|
+
Range as VRange,
|
|
24
|
+
InlineValueContext as VInlineValueContext,
|
|
25
|
+
InlineValue as VInlineValue,
|
|
26
|
+
InlineValuesProvider,
|
|
27
|
+
} from 'vscode';
|
|
28
|
+
|
|
29
|
+
import type { FeatureClient } from './features.js';
|
|
30
|
+
import { TextDocumentLanguageFeature, ensure } from './features.js';
|
|
31
|
+
import { languages as Languages, EventEmitter } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
32
|
+
|
|
33
|
+
export type ProvideInlineValuesSignature = (
|
|
34
|
+
this: void,
|
|
35
|
+
document: TextDocument,
|
|
36
|
+
viewPort: VRange,
|
|
37
|
+
context: VInlineValueContext,
|
|
38
|
+
token: CancellationToken,
|
|
39
|
+
) => ProviderResult<VInlineValue[]>;
|
|
40
|
+
|
|
41
|
+
export type InlineValueMiddleware = {
|
|
42
|
+
provideInlineValues?: (
|
|
43
|
+
this: void,
|
|
44
|
+
document: TextDocument,
|
|
45
|
+
viewPort: VRange,
|
|
46
|
+
context: VInlineValueContext,
|
|
47
|
+
token: CancellationToken,
|
|
48
|
+
next: ProvideInlineValuesSignature,
|
|
49
|
+
) => ProviderResult<VInlineValue[]>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type InlineValueProviderShape = {
|
|
53
|
+
provider: InlineValuesProvider;
|
|
54
|
+
onDidChangeInlineValues: EventEmitter<void>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export class InlineValueFeature extends TextDocumentLanguageFeature<
|
|
58
|
+
boolean | InlineValueOptions,
|
|
59
|
+
InlineValueRegistrationOptions,
|
|
60
|
+
InlineValueProviderShape,
|
|
61
|
+
InlineValueMiddleware
|
|
62
|
+
> {
|
|
63
|
+
constructor(client: FeatureClient<InlineValueMiddleware>) {
|
|
64
|
+
super(client, InlineValueRequest.type);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
68
|
+
ensure(ensure(capabilities, 'textDocument')!, 'inlineValue')!.dynamicRegistration =
|
|
69
|
+
true;
|
|
70
|
+
ensure(ensure(capabilities, 'workspace')!, 'inlineValue')!.refreshSupport = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public initialize(
|
|
74
|
+
capabilities: ServerCapabilities,
|
|
75
|
+
documentSelector: DocumentSelector,
|
|
76
|
+
): void {
|
|
77
|
+
this._client.onRequest(InlineValueRefreshRequest.type, async () => {
|
|
78
|
+
for (const provider of this.getAllProviders()) {
|
|
79
|
+
provider.onDidChangeInlineValues.fire();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const [id, options] = this.getRegistration(
|
|
84
|
+
documentSelector,
|
|
85
|
+
capabilities.inlineValueProvider,
|
|
86
|
+
);
|
|
87
|
+
if (!id || !options) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.register({ id: id, registerOptions: options });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected registerLanguageProvider(
|
|
94
|
+
options: InlineValueRegistrationOptions,
|
|
95
|
+
): [Disposable, InlineValueProviderShape] {
|
|
96
|
+
const selector = options.documentSelector!;
|
|
97
|
+
const eventEmitter: EventEmitter<void> = new EventEmitter<void>();
|
|
98
|
+
const provider: InlineValuesProvider = {
|
|
99
|
+
onDidChangeInlineValues: eventEmitter.event,
|
|
100
|
+
provideInlineValues: (document, viewPort, context, token) => {
|
|
101
|
+
const client = this._client;
|
|
102
|
+
const provideInlineValues: ProvideInlineValuesSignature = (
|
|
103
|
+
document,
|
|
104
|
+
viewPort,
|
|
105
|
+
context,
|
|
106
|
+
token,
|
|
107
|
+
) => {
|
|
108
|
+
const requestParams: InlineValueParams = {
|
|
109
|
+
textDocument:
|
|
110
|
+
client.code2ProtocolConverter.asTextDocumentIdentifier(document),
|
|
111
|
+
range: client.code2ProtocolConverter.asRange(viewPort),
|
|
112
|
+
context: client.code2ProtocolConverter.asInlineValueContext(context),
|
|
113
|
+
};
|
|
114
|
+
return client.sendRequest(InlineValueRequest.type, requestParams, token).then(
|
|
115
|
+
(values) => {
|
|
116
|
+
if (token.isCancellationRequested) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return client.protocol2CodeConverter.asInlineValues(values, token);
|
|
120
|
+
},
|
|
121
|
+
(error: any) => {
|
|
122
|
+
return client.handleFailedRequest(
|
|
123
|
+
InlineValueRequest.type,
|
|
124
|
+
token,
|
|
125
|
+
error,
|
|
126
|
+
null,
|
|
127
|
+
);
|
|
128
|
+
},
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
const middleware = client.middleware;
|
|
132
|
+
return middleware.provideInlineValues
|
|
133
|
+
? middleware.provideInlineValues(
|
|
134
|
+
document,
|
|
135
|
+
viewPort,
|
|
136
|
+
context,
|
|
137
|
+
token,
|
|
138
|
+
provideInlineValues,
|
|
139
|
+
)
|
|
140
|
+
: provideInlineValues(document, viewPort, context, token);
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
return [
|
|
144
|
+
this.registerProvider(selector, provider),
|
|
145
|
+
{ provider: provider, onDidChangeInlineValues: eventEmitter },
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private registerProvider(
|
|
150
|
+
selector: DocumentSelector,
|
|
151
|
+
provider: InlineValuesProvider,
|
|
152
|
+
): Disposable {
|
|
153
|
+
return Languages.registerInlineValuesProvider(
|
|
154
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
155
|
+
provider,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|