@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,47 @@
|
|
|
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 { LSPAny } from '@difizen/vscode-languageserver-protocol';
|
|
7
|
+
|
|
8
|
+
import * as Is from './utils/is.js';
|
|
9
|
+
import type { Range, DiagnosticSeverity } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
10
|
+
import { Diagnostic } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* We keep this for a while to not break servers which adopted
|
|
14
|
+
* proposed API.
|
|
15
|
+
*/
|
|
16
|
+
export interface DiagnosticCode {
|
|
17
|
+
value: string | number;
|
|
18
|
+
target: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export namespace DiagnosticCode {
|
|
22
|
+
export function is(value: any): value is DiagnosticCode {
|
|
23
|
+
const candidate: DiagnosticCode = value as DiagnosticCode;
|
|
24
|
+
return (
|
|
25
|
+
candidate !== undefined &&
|
|
26
|
+
candidate !== null &&
|
|
27
|
+
(Is.number(candidate.value) || Is.string(candidate.value)) &&
|
|
28
|
+
Is.string(candidate.target)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class ProtocolDiagnostic extends Diagnostic {
|
|
34
|
+
public readonly data: LSPAny | undefined;
|
|
35
|
+
public hasDiagnosticCode: boolean;
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
range: Range,
|
|
39
|
+
message: string,
|
|
40
|
+
severity: DiagnosticSeverity,
|
|
41
|
+
data: LSPAny | undefined,
|
|
42
|
+
) {
|
|
43
|
+
super(range, message, severity);
|
|
44
|
+
this.data = data;
|
|
45
|
+
this.hasDiagnosticCode = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { Uri } from 'vscode';
|
|
7
|
+
|
|
8
|
+
import type { Range } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
9
|
+
import { DocumentLink } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
10
|
+
|
|
11
|
+
export default class ProtocolDocumentLink extends DocumentLink {
|
|
12
|
+
public data: any;
|
|
13
|
+
|
|
14
|
+
constructor(range: Range, target?: Uri | undefined) {
|
|
15
|
+
super(range, target);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { InlayHintKind } from 'vscode';
|
|
7
|
+
|
|
8
|
+
import type { InlayHintLabelPart, Position } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
9
|
+
import { InlayHint } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
10
|
+
|
|
11
|
+
export default class ProtocolInlayHint extends InlayHint {
|
|
12
|
+
public data: any;
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
position: Position,
|
|
16
|
+
label: string | InlayHintLabelPart[],
|
|
17
|
+
kind?: InlayHintKind,
|
|
18
|
+
) {
|
|
19
|
+
super(position, label, kind);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { LSPAny } from '@difizen/vscode-languageserver-protocol';
|
|
7
|
+
import type { SymbolKind, Uri } from 'vscode';
|
|
8
|
+
|
|
9
|
+
import type { Range } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
10
|
+
import { TypeHierarchyItem } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
11
|
+
|
|
12
|
+
export default class ProtocolTypeHierarchyItem extends TypeHierarchyItem {
|
|
13
|
+
public data?: LSPAny;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
kind: SymbolKind,
|
|
17
|
+
name: string,
|
|
18
|
+
detail: string,
|
|
19
|
+
uri: Uri,
|
|
20
|
+
range: Range,
|
|
21
|
+
selectionRange: Range,
|
|
22
|
+
data?: LSPAny,
|
|
23
|
+
) {
|
|
24
|
+
super(kind, name, detail, uri, range, selectionRange);
|
|
25
|
+
if (data !== undefined) {
|
|
26
|
+
this.data = data;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { LSPAny } from '@difizen/vscode-languageserver-protocol';
|
|
7
|
+
import type { SymbolKind } from 'vscode';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
SymbolInformation,
|
|
11
|
+
Location,
|
|
12
|
+
Range,
|
|
13
|
+
Uri,
|
|
14
|
+
} from './vscodeAdaptor/vscodeAdaptor.js';
|
|
15
|
+
|
|
16
|
+
export default class WorkspaceSymbol extends SymbolInformation {
|
|
17
|
+
public data?: LSPAny;
|
|
18
|
+
public readonly hasRange: boolean;
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
name: string,
|
|
22
|
+
kind: SymbolKind,
|
|
23
|
+
containerName: string,
|
|
24
|
+
locationOrUri: Location | Uri,
|
|
25
|
+
data: LSPAny | undefined,
|
|
26
|
+
) {
|
|
27
|
+
const hasRange = !(locationOrUri instanceof Uri);
|
|
28
|
+
super(
|
|
29
|
+
name,
|
|
30
|
+
kind,
|
|
31
|
+
containerName,
|
|
32
|
+
hasRange ? locationOrUri : new Location(locationOrUri, new Range(0, 0, 0, 0)),
|
|
33
|
+
);
|
|
34
|
+
this.hasRange = hasRange;
|
|
35
|
+
if (data !== undefined) {
|
|
36
|
+
this.data = data;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
DocumentSelector,
|
|
9
|
+
ReferenceOptions,
|
|
10
|
+
ReferenceRegistrationOptions,
|
|
11
|
+
ServerCapabilities,
|
|
12
|
+
TextDocumentRegistrationOptions,
|
|
13
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
14
|
+
import { ReferencesRequest } from '@difizen/vscode-languageserver-protocol';
|
|
15
|
+
import type {
|
|
16
|
+
TextDocument,
|
|
17
|
+
Disposable,
|
|
18
|
+
Position as VPosition,
|
|
19
|
+
CancellationToken,
|
|
20
|
+
ProviderResult,
|
|
21
|
+
ReferenceProvider,
|
|
22
|
+
Location as VLocation,
|
|
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 ProvideReferencesSignature {
|
|
31
|
+
(
|
|
32
|
+
this: void,
|
|
33
|
+
document: TextDocument,
|
|
34
|
+
position: VPosition,
|
|
35
|
+
options: { includeDeclaration: boolean },
|
|
36
|
+
token: CancellationToken,
|
|
37
|
+
): ProviderResult<VLocation[]>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ReferencesMiddleware {
|
|
41
|
+
provideReferences?: (
|
|
42
|
+
this: void,
|
|
43
|
+
document: TextDocument,
|
|
44
|
+
position: VPosition,
|
|
45
|
+
options: { includeDeclaration: boolean },
|
|
46
|
+
token: CancellationToken,
|
|
47
|
+
next: ProvideReferencesSignature,
|
|
48
|
+
) => ProviderResult<VLocation[]>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class ReferencesFeature extends TextDocumentLanguageFeature<
|
|
52
|
+
boolean | ReferenceOptions,
|
|
53
|
+
ReferenceRegistrationOptions,
|
|
54
|
+
ReferenceProvider,
|
|
55
|
+
ReferencesMiddleware
|
|
56
|
+
> {
|
|
57
|
+
constructor(client: FeatureClient<ReferencesMiddleware>) {
|
|
58
|
+
super(client, ReferencesRequest.type);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
62
|
+
ensure(ensure(capabilities, 'textDocument')!, 'references')!.dynamicRegistration =
|
|
63
|
+
true;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public initialize(
|
|
67
|
+
capabilities: ServerCapabilities,
|
|
68
|
+
documentSelector: DocumentSelector,
|
|
69
|
+
): void {
|
|
70
|
+
const options = this.getRegistrationOptions(
|
|
71
|
+
documentSelector,
|
|
72
|
+
capabilities.referencesProvider,
|
|
73
|
+
);
|
|
74
|
+
if (!options) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.register({ id: UUID.generateUuid(), registerOptions: options });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected registerLanguageProvider(
|
|
81
|
+
options: TextDocumentRegistrationOptions,
|
|
82
|
+
): [Disposable, ReferenceProvider] {
|
|
83
|
+
const selector = options.documentSelector!;
|
|
84
|
+
const provider: ReferenceProvider = {
|
|
85
|
+
provideReferences: (document, position, options, token) => {
|
|
86
|
+
const client = this._client;
|
|
87
|
+
const _providerReferences: ProvideReferencesSignature = (
|
|
88
|
+
document,
|
|
89
|
+
position,
|
|
90
|
+
options,
|
|
91
|
+
token,
|
|
92
|
+
) => {
|
|
93
|
+
return client
|
|
94
|
+
.sendRequest(
|
|
95
|
+
ReferencesRequest.type,
|
|
96
|
+
client.code2ProtocolConverter.asReferenceParams(
|
|
97
|
+
document,
|
|
98
|
+
position,
|
|
99
|
+
options,
|
|
100
|
+
),
|
|
101
|
+
token,
|
|
102
|
+
)
|
|
103
|
+
.then(
|
|
104
|
+
(result) => {
|
|
105
|
+
if (token.isCancellationRequested) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return client.protocol2CodeConverter.asReferences(result, token);
|
|
109
|
+
},
|
|
110
|
+
(error) => {
|
|
111
|
+
return client.handleFailedRequest(
|
|
112
|
+
ReferencesRequest.type,
|
|
113
|
+
token,
|
|
114
|
+
error,
|
|
115
|
+
null,
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
const middleware = client.middleware;
|
|
121
|
+
return middleware.provideReferences
|
|
122
|
+
? middleware.provideReferences(
|
|
123
|
+
document,
|
|
124
|
+
position,
|
|
125
|
+
options,
|
|
126
|
+
token,
|
|
127
|
+
_providerReferences,
|
|
128
|
+
)
|
|
129
|
+
: _providerReferences(document, position, options, token);
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
return [this.registerProvider(selector, provider), provider];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private registerProvider(
|
|
136
|
+
selector: DocumentSelector,
|
|
137
|
+
provider: ReferenceProvider,
|
|
138
|
+
): Disposable {
|
|
139
|
+
return Languages.registerReferenceProvider(
|
|
140
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
141
|
+
provider,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
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
|
+
RenameOptions,
|
|
12
|
+
RenameRegistrationOptions,
|
|
13
|
+
RenameParams,
|
|
14
|
+
ResponseError,
|
|
15
|
+
TextDocumentPositionParams,
|
|
16
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
17
|
+
import {
|
|
18
|
+
RenameRequest,
|
|
19
|
+
PrepareSupportDefaultBehavior,
|
|
20
|
+
PrepareRenameRequest,
|
|
21
|
+
Range,
|
|
22
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
23
|
+
import type {
|
|
24
|
+
Disposable,
|
|
25
|
+
TextDocument,
|
|
26
|
+
ProviderResult,
|
|
27
|
+
Range as VRange,
|
|
28
|
+
Position as VPosition,
|
|
29
|
+
WorkspaceEdit as VWorkspaceEdit,
|
|
30
|
+
RenameProvider,
|
|
31
|
+
} from 'vscode';
|
|
32
|
+
|
|
33
|
+
import type { FeatureClient, DocumentSelectorOptions } from './features.js';
|
|
34
|
+
import { TextDocumentLanguageFeature, ensure } from './features.js';
|
|
35
|
+
import * as Is from './utils/is.js';
|
|
36
|
+
import * as UUID from './utils/uuid.js';
|
|
37
|
+
import { languages as Languages } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
38
|
+
|
|
39
|
+
export interface ProvideRenameEditsSignature {
|
|
40
|
+
(
|
|
41
|
+
this: void,
|
|
42
|
+
document: TextDocument,
|
|
43
|
+
position: VPosition,
|
|
44
|
+
newName: string,
|
|
45
|
+
token: CancellationToken,
|
|
46
|
+
): ProviderResult<VWorkspaceEdit>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface PrepareRenameSignature {
|
|
50
|
+
(
|
|
51
|
+
this: void,
|
|
52
|
+
document: TextDocument,
|
|
53
|
+
position: VPosition,
|
|
54
|
+
token: CancellationToken,
|
|
55
|
+
): ProviderResult<VRange | { range: VRange; placeholder: string }>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface RenameMiddleware {
|
|
59
|
+
provideRenameEdits?: (
|
|
60
|
+
this: void,
|
|
61
|
+
document: TextDocument,
|
|
62
|
+
position: VPosition,
|
|
63
|
+
newName: string,
|
|
64
|
+
token: CancellationToken,
|
|
65
|
+
next: ProvideRenameEditsSignature,
|
|
66
|
+
) => ProviderResult<VWorkspaceEdit>;
|
|
67
|
+
prepareRename?: (
|
|
68
|
+
this: void,
|
|
69
|
+
document: TextDocument,
|
|
70
|
+
position: VPosition,
|
|
71
|
+
token: CancellationToken,
|
|
72
|
+
next: PrepareRenameSignature,
|
|
73
|
+
) => ProviderResult<VRange | { range: VRange; placeholder: string }>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type DefaultBehavior = {
|
|
77
|
+
defaultBehavior: boolean;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export class RenameFeature extends TextDocumentLanguageFeature<
|
|
81
|
+
boolean | RenameOptions,
|
|
82
|
+
RenameRegistrationOptions,
|
|
83
|
+
RenameProvider,
|
|
84
|
+
RenameMiddleware
|
|
85
|
+
> {
|
|
86
|
+
constructor(client: FeatureClient<RenameMiddleware>) {
|
|
87
|
+
super(client, RenameRequest.type);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
91
|
+
const rename = ensure(ensure(capabilities, 'textDocument')!, 'rename')!;
|
|
92
|
+
rename.dynamicRegistration = true;
|
|
93
|
+
rename.prepareSupport = true;
|
|
94
|
+
rename.prepareSupportDefaultBehavior = PrepareSupportDefaultBehavior.Identifier;
|
|
95
|
+
rename.honorsChangeAnnotations = true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public initialize(
|
|
99
|
+
capabilities: ServerCapabilities,
|
|
100
|
+
documentSelector: DocumentSelector,
|
|
101
|
+
): void {
|
|
102
|
+
const options = this.getRegistrationOptions(
|
|
103
|
+
documentSelector,
|
|
104
|
+
capabilities.renameProvider,
|
|
105
|
+
);
|
|
106
|
+
if (!options) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (Is.boolean(capabilities.renameProvider)) {
|
|
110
|
+
options.prepareProvider = false;
|
|
111
|
+
}
|
|
112
|
+
this.register({ id: UUID.generateUuid(), registerOptions: options });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
protected registerLanguageProvider(
|
|
116
|
+
options: RenameRegistrationOptions & DocumentSelectorOptions,
|
|
117
|
+
): [Disposable, RenameProvider] {
|
|
118
|
+
const selector = options.documentSelector;
|
|
119
|
+
const provider: RenameProvider = {
|
|
120
|
+
provideRenameEdits: (document, position, newName, token) => {
|
|
121
|
+
const client = this._client;
|
|
122
|
+
const provideRenameEdits: ProvideRenameEditsSignature = (
|
|
123
|
+
document,
|
|
124
|
+
position,
|
|
125
|
+
newName,
|
|
126
|
+
token,
|
|
127
|
+
) => {
|
|
128
|
+
const params: RenameParams = {
|
|
129
|
+
textDocument:
|
|
130
|
+
client.code2ProtocolConverter.asTextDocumentIdentifier(document),
|
|
131
|
+
position: client.code2ProtocolConverter.asPosition(position),
|
|
132
|
+
newName: newName,
|
|
133
|
+
};
|
|
134
|
+
return client.sendRequest(RenameRequest.type, params, token).then(
|
|
135
|
+
(result) => {
|
|
136
|
+
if (token.isCancellationRequested) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return client.protocol2CodeConverter.asWorkspaceEdit(result, token);
|
|
140
|
+
},
|
|
141
|
+
(error: ResponseError<void>) => {
|
|
142
|
+
return client.handleFailedRequest(
|
|
143
|
+
RenameRequest.type,
|
|
144
|
+
token,
|
|
145
|
+
error,
|
|
146
|
+
null,
|
|
147
|
+
false,
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
const middleware = client.middleware;
|
|
153
|
+
return middleware.provideRenameEdits
|
|
154
|
+
? middleware.provideRenameEdits(
|
|
155
|
+
document,
|
|
156
|
+
position,
|
|
157
|
+
newName,
|
|
158
|
+
token,
|
|
159
|
+
provideRenameEdits,
|
|
160
|
+
)
|
|
161
|
+
: provideRenameEdits(document, position, newName, token);
|
|
162
|
+
},
|
|
163
|
+
prepareRename: options.prepareProvider
|
|
164
|
+
? (document, position, token) => {
|
|
165
|
+
const client = this._client;
|
|
166
|
+
const prepareRename: PrepareRenameSignature = (
|
|
167
|
+
document,
|
|
168
|
+
position,
|
|
169
|
+
token,
|
|
170
|
+
) => {
|
|
171
|
+
const params: TextDocumentPositionParams = {
|
|
172
|
+
textDocument:
|
|
173
|
+
client.code2ProtocolConverter.asTextDocumentIdentifier(document),
|
|
174
|
+
position: client.code2ProtocolConverter.asPosition(position),
|
|
175
|
+
};
|
|
176
|
+
return client.sendRequest(PrepareRenameRequest.type, params, token).then(
|
|
177
|
+
(result) => {
|
|
178
|
+
if (token.isCancellationRequested) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
if (Range.is(result)) {
|
|
182
|
+
return client.protocol2CodeConverter.asRange(result);
|
|
183
|
+
} else if (this.isDefaultBehavior(result)) {
|
|
184
|
+
return result.defaultBehavior === true
|
|
185
|
+
? null
|
|
186
|
+
: Promise.reject(new Error(`The element can't be renamed.`));
|
|
187
|
+
} else if (result && Range.is(result.range)) {
|
|
188
|
+
return {
|
|
189
|
+
range: client.protocol2CodeConverter.asRange(result.range),
|
|
190
|
+
placeholder: result.placeholder,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
// To cancel the rename vscode API expects a rejected promise.
|
|
194
|
+
// eslint-disable-next-line promise/no-return-wrap
|
|
195
|
+
return Promise.reject(new Error(`The element can't be renamed.`));
|
|
196
|
+
},
|
|
197
|
+
(error: ResponseError<void>) => {
|
|
198
|
+
if (typeof error.message === 'string') {
|
|
199
|
+
throw new Error(error.message);
|
|
200
|
+
} else {
|
|
201
|
+
throw new Error(`The element can't be renamed.`);
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
);
|
|
205
|
+
};
|
|
206
|
+
const middleware = client.middleware;
|
|
207
|
+
return middleware.prepareRename
|
|
208
|
+
? middleware.prepareRename(document, position, token, prepareRename)
|
|
209
|
+
: prepareRename(document, position, token);
|
|
210
|
+
}
|
|
211
|
+
: undefined,
|
|
212
|
+
};
|
|
213
|
+
return [this.registerProvider(selector, provider), provider];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private registerProvider(
|
|
217
|
+
selector: RenameOptions & DocumentSelector,
|
|
218
|
+
provider: RenameProvider,
|
|
219
|
+
): Disposable {
|
|
220
|
+
return Languages.registerRenameProvider(
|
|
221
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
222
|
+
provider,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private isDefaultBehavior(value: any): value is DefaultBehavior {
|
|
227
|
+
const candidate: DefaultBehavior = value;
|
|
228
|
+
return candidate && Is.boolean(candidate.defaultBehavior);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
SelectionRangeParams,
|
|
12
|
+
SelectionRangeOptions,
|
|
13
|
+
SelectionRangeRegistrationOptions,
|
|
14
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
15
|
+
import { SelectionRangeRequest } from '@difizen/vscode-languageserver-protocol';
|
|
16
|
+
import type {
|
|
17
|
+
Disposable,
|
|
18
|
+
TextDocument,
|
|
19
|
+
ProviderResult,
|
|
20
|
+
Position as VPosition,
|
|
21
|
+
SelectionRange as VSelectionRange,
|
|
22
|
+
SelectionRangeProvider,
|
|
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 ProvideSelectionRangeSignature {
|
|
30
|
+
(
|
|
31
|
+
this: void,
|
|
32
|
+
document: TextDocument,
|
|
33
|
+
positions: readonly VPosition[],
|
|
34
|
+
token: CancellationToken,
|
|
35
|
+
): ProviderResult<VSelectionRange[]>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SelectionRangeProviderMiddleware {
|
|
39
|
+
provideSelectionRanges?: (
|
|
40
|
+
this: void,
|
|
41
|
+
document: TextDocument,
|
|
42
|
+
positions: readonly VPosition[],
|
|
43
|
+
token: CancellationToken,
|
|
44
|
+
next: ProvideSelectionRangeSignature,
|
|
45
|
+
) => ProviderResult<VSelectionRange[]>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class SelectionRangeFeature extends TextDocumentLanguageFeature<
|
|
49
|
+
boolean | SelectionRangeOptions,
|
|
50
|
+
SelectionRangeRegistrationOptions,
|
|
51
|
+
SelectionRangeProvider,
|
|
52
|
+
SelectionRangeProviderMiddleware
|
|
53
|
+
> {
|
|
54
|
+
constructor(client: FeatureClient<SelectionRangeProviderMiddleware>) {
|
|
55
|
+
super(client, SelectionRangeRequest.type);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
59
|
+
const capability = ensure(ensure(capabilities, 'textDocument')!, 'selectionRange')!;
|
|
60
|
+
capability.dynamicRegistration = true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public initialize(
|
|
64
|
+
capabilities: ServerCapabilities,
|
|
65
|
+
documentSelector: DocumentSelector,
|
|
66
|
+
): void {
|
|
67
|
+
const [id, options] = this.getRegistration(
|
|
68
|
+
documentSelector,
|
|
69
|
+
capabilities.selectionRangeProvider,
|
|
70
|
+
);
|
|
71
|
+
if (!id || !options) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.register({ id: id, registerOptions: options });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected registerLanguageProvider(
|
|
78
|
+
options: SelectionRangeRegistrationOptions,
|
|
79
|
+
): [Disposable, SelectionRangeProvider] {
|
|
80
|
+
const selector = options.documentSelector!;
|
|
81
|
+
const provider: SelectionRangeProvider = {
|
|
82
|
+
provideSelectionRanges: (document, positions, token) => {
|
|
83
|
+
const client = this._client;
|
|
84
|
+
const provideSelectionRanges: ProvideSelectionRangeSignature = async (
|
|
85
|
+
document,
|
|
86
|
+
positions,
|
|
87
|
+
token,
|
|
88
|
+
) => {
|
|
89
|
+
const requestParams: SelectionRangeParams = {
|
|
90
|
+
textDocument:
|
|
91
|
+
client.code2ProtocolConverter.asTextDocumentIdentifier(document),
|
|
92
|
+
positions: client.code2ProtocolConverter.asPositionsSync(positions, token),
|
|
93
|
+
};
|
|
94
|
+
return client
|
|
95
|
+
.sendRequest(SelectionRangeRequest.type, requestParams, token)
|
|
96
|
+
.then(
|
|
97
|
+
(ranges) => {
|
|
98
|
+
if (token.isCancellationRequested) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return client.protocol2CodeConverter.asSelectionRanges(ranges, token);
|
|
102
|
+
},
|
|
103
|
+
(error: any) => {
|
|
104
|
+
return client.handleFailedRequest(
|
|
105
|
+
SelectionRangeRequest.type,
|
|
106
|
+
token,
|
|
107
|
+
error,
|
|
108
|
+
null,
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
const middleware = client.middleware;
|
|
114
|
+
return middleware.provideSelectionRanges
|
|
115
|
+
? middleware.provideSelectionRanges(
|
|
116
|
+
document,
|
|
117
|
+
positions,
|
|
118
|
+
token,
|
|
119
|
+
provideSelectionRanges,
|
|
120
|
+
)
|
|
121
|
+
: provideSelectionRanges(document, positions, token);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
return [this.registerProvider(selector, provider), provider];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private registerProvider(
|
|
128
|
+
selector: DocumentSelector,
|
|
129
|
+
provider: SelectionRangeProvider,
|
|
130
|
+
): Disposable {
|
|
131
|
+
return Languages.registerSelectionRangeProvider(
|
|
132
|
+
this._client.protocol2CodeConverter.asDocumentSelector(selector),
|
|
133
|
+
provider,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|