@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,166 @@
|
|
|
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
|
+
ServerCapabilities,
|
|
9
|
+
WorkspaceSymbolRegistrationOptions,
|
|
10
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
11
|
+
import {
|
|
12
|
+
WorkspaceSymbolRequest,
|
|
13
|
+
WorkspaceSymbolResolveRequest,
|
|
14
|
+
} from '@difizen/vscode-languageserver-protocol';
|
|
15
|
+
import type {
|
|
16
|
+
Disposable,
|
|
17
|
+
CancellationToken,
|
|
18
|
+
ProviderResult,
|
|
19
|
+
SymbolInformation as VSymbolInformation,
|
|
20
|
+
WorkspaceSymbolProvider,
|
|
21
|
+
} from 'vscode';
|
|
22
|
+
|
|
23
|
+
import { SupportedSymbolKinds, SupportedSymbolTags } from './documentSymbol.js';
|
|
24
|
+
import type { FeatureClient } from './features.js';
|
|
25
|
+
import { ensure, WorkspaceFeature } from './features.js';
|
|
26
|
+
import * as UUID from './utils/uuid.js';
|
|
27
|
+
import { languages as Languages } from './vscodeAdaptor/vscodeAdaptor.js';
|
|
28
|
+
|
|
29
|
+
export interface ProvideWorkspaceSymbolsSignature {
|
|
30
|
+
(
|
|
31
|
+
this: void,
|
|
32
|
+
query: string,
|
|
33
|
+
token: CancellationToken,
|
|
34
|
+
): ProviderResult<VSymbolInformation[]>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ResolveWorkspaceSymbolSignature {
|
|
38
|
+
(
|
|
39
|
+
this: void,
|
|
40
|
+
item: VSymbolInformation,
|
|
41
|
+
token: CancellationToken,
|
|
42
|
+
): ProviderResult<VSymbolInformation>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface WorkspaceSymbolMiddleware {
|
|
46
|
+
provideWorkspaceSymbols?: (
|
|
47
|
+
this: void,
|
|
48
|
+
query: string,
|
|
49
|
+
token: CancellationToken,
|
|
50
|
+
next: ProvideWorkspaceSymbolsSignature,
|
|
51
|
+
) => ProviderResult<VSymbolInformation[]>;
|
|
52
|
+
resolveWorkspaceSymbol?: (
|
|
53
|
+
this: void,
|
|
54
|
+
item: VSymbolInformation,
|
|
55
|
+
token: CancellationToken,
|
|
56
|
+
next: ResolveWorkspaceSymbolSignature,
|
|
57
|
+
) => ProviderResult<VSymbolInformation>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class WorkspaceSymbolFeature extends WorkspaceFeature<
|
|
61
|
+
WorkspaceSymbolRegistrationOptions,
|
|
62
|
+
WorkspaceSymbolProvider,
|
|
63
|
+
WorkspaceSymbolMiddleware
|
|
64
|
+
> {
|
|
65
|
+
constructor(client: FeatureClient<WorkspaceSymbolMiddleware>) {
|
|
66
|
+
super(client, WorkspaceSymbolRequest.type);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
|
70
|
+
const symbolCapabilities = ensure(ensure(capabilities, 'workspace')!, 'symbol')!;
|
|
71
|
+
symbolCapabilities.dynamicRegistration = true;
|
|
72
|
+
symbolCapabilities.symbolKind = {
|
|
73
|
+
valueSet: SupportedSymbolKinds,
|
|
74
|
+
};
|
|
75
|
+
symbolCapabilities.tagSupport = {
|
|
76
|
+
valueSet: SupportedSymbolTags,
|
|
77
|
+
};
|
|
78
|
+
symbolCapabilities.resolveSupport = { properties: ['location.range'] };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public initialize(capabilities: ServerCapabilities): void {
|
|
82
|
+
if (!capabilities.workspaceSymbolProvider) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.register({
|
|
86
|
+
id: UUID.generateUuid(),
|
|
87
|
+
registerOptions:
|
|
88
|
+
capabilities.workspaceSymbolProvider === true
|
|
89
|
+
? { workDoneProgress: false }
|
|
90
|
+
: capabilities.workspaceSymbolProvider,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
protected registerLanguageProvider(
|
|
95
|
+
options: WorkspaceSymbolRegistrationOptions,
|
|
96
|
+
): [Disposable, WorkspaceSymbolProvider] {
|
|
97
|
+
const provider: WorkspaceSymbolProvider = {
|
|
98
|
+
provideWorkspaceSymbols: (query, token) => {
|
|
99
|
+
const client = this._client;
|
|
100
|
+
const provideWorkspaceSymbols: ProvideWorkspaceSymbolsSignature = (
|
|
101
|
+
query,
|
|
102
|
+
token,
|
|
103
|
+
) => {
|
|
104
|
+
return client.sendRequest(WorkspaceSymbolRequest.type, { query }, token).then(
|
|
105
|
+
(result) => {
|
|
106
|
+
if (token.isCancellationRequested) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
return client.protocol2CodeConverter.asSymbolInformations(result, token);
|
|
110
|
+
},
|
|
111
|
+
(error) => {
|
|
112
|
+
return client.handleFailedRequest(
|
|
113
|
+
WorkspaceSymbolRequest.type,
|
|
114
|
+
token,
|
|
115
|
+
error,
|
|
116
|
+
null,
|
|
117
|
+
);
|
|
118
|
+
},
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
const middleware = client.middleware;
|
|
122
|
+
return middleware.provideWorkspaceSymbols
|
|
123
|
+
? middleware.provideWorkspaceSymbols(query, token, provideWorkspaceSymbols)
|
|
124
|
+
: provideWorkspaceSymbols(query, token);
|
|
125
|
+
},
|
|
126
|
+
resolveWorkspaceSymbol:
|
|
127
|
+
options.resolveProvider === true
|
|
128
|
+
? (item, token) => {
|
|
129
|
+
const client = this._client;
|
|
130
|
+
const resolveWorkspaceSymbol: ResolveWorkspaceSymbolSignature = (
|
|
131
|
+
item,
|
|
132
|
+
token,
|
|
133
|
+
) => {
|
|
134
|
+
return client
|
|
135
|
+
.sendRequest(
|
|
136
|
+
WorkspaceSymbolResolveRequest.type,
|
|
137
|
+
client.code2ProtocolConverter.asWorkspaceSymbol(item),
|
|
138
|
+
token,
|
|
139
|
+
)
|
|
140
|
+
.then(
|
|
141
|
+
(result) => {
|
|
142
|
+
if (token.isCancellationRequested) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
return client.protocol2CodeConverter.asSymbolInformation(result);
|
|
146
|
+
},
|
|
147
|
+
(error) => {
|
|
148
|
+
return client.handleFailedRequest(
|
|
149
|
+
WorkspaceSymbolResolveRequest.type,
|
|
150
|
+
token,
|
|
151
|
+
error,
|
|
152
|
+
null,
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
const middleware = client.middleware;
|
|
158
|
+
return middleware.resolveWorkspaceSymbol
|
|
159
|
+
? middleware.resolveWorkspaceSymbol(item, token, resolveWorkspaceSymbol)
|
|
160
|
+
: resolveWorkspaceSymbol(item, token);
|
|
161
|
+
}
|
|
162
|
+
: undefined,
|
|
163
|
+
};
|
|
164
|
+
return [Languages.registerWorkspaceSymbolProvider(provider), provider];
|
|
165
|
+
}
|
|
166
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const LibroCellURIScheme = 'libro-notebook-cell';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ApplicationContribution, inject, singleton } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { CloseAction, ErrorAction } from './common/api.js';
|
|
4
|
+
import { LSPEnv } from './common/vscodeAdaptor/lspEnv.js';
|
|
5
|
+
import { workspace } from './common/vscodeAdaptor/vscodeAdaptor.js';
|
|
6
|
+
import { LibroLanguageClientManager } from './libro-language-client-manager.js';
|
|
7
|
+
|
|
8
|
+
@singleton({ contrib: [ApplicationContribution] })
|
|
9
|
+
export class LibroLanguageClientContribution implements ApplicationContribution {
|
|
10
|
+
@inject(LibroLanguageClientManager)
|
|
11
|
+
protected readonly libroLanguageClientManager: LibroLanguageClientManager;
|
|
12
|
+
|
|
13
|
+
@inject(LSPEnv)
|
|
14
|
+
protected readonly lspEnv: LSPEnv;
|
|
15
|
+
|
|
16
|
+
async onViewStart() {
|
|
17
|
+
// not block
|
|
18
|
+
this.startLanguageClients();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async startLanguageClients() {
|
|
22
|
+
await this.lspEnv.ready;
|
|
23
|
+
const serverIds = await this.libroLanguageClientManager.getServers();
|
|
24
|
+
|
|
25
|
+
for (const serverId of serverIds) {
|
|
26
|
+
await this.libroLanguageClientManager.getOrCreateLanguageClient(serverId, {
|
|
27
|
+
name: `${serverId} Language Client`,
|
|
28
|
+
clientOptions: {
|
|
29
|
+
// use a language id as a document selector
|
|
30
|
+
documentSelector: [{ language: 'python' }],
|
|
31
|
+
// disable the default error handler
|
|
32
|
+
errorHandler: {
|
|
33
|
+
error: () => ({ action: ErrorAction.Continue }),
|
|
34
|
+
closed: () => ({ action: CloseAction.DoNotRestart }),
|
|
35
|
+
},
|
|
36
|
+
// pyright requires a workspace folder to be present, otherwise it will not work
|
|
37
|
+
// workspaceFolder: {
|
|
38
|
+
// index: 0,
|
|
39
|
+
// name: 'workspace',
|
|
40
|
+
// uri: URI.parse('/examples'), // abs path
|
|
41
|
+
// },
|
|
42
|
+
synchronize: {
|
|
43
|
+
fileEvents: [workspace.createFileSystemWatcher('**', false)],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { URL } from '@difizen/libro-common';
|
|
2
|
+
import { PageConfig } from '@difizen/libro-kernel';
|
|
3
|
+
import type { ILanguageServerManager, TSessionMap } from '@difizen/libro-lsp';
|
|
4
|
+
import { ILanguageServerManagerFactory } from '@difizen/libro-lsp';
|
|
5
|
+
import { singleton, inject, postConstruct, getOrigin } from '@difizen/mana-app';
|
|
6
|
+
|
|
7
|
+
import type { LibroLanguageClientOptions } from './libro-language-client.js';
|
|
8
|
+
import { LibroLanguageClient } from './libro-language-client.js';
|
|
9
|
+
|
|
10
|
+
interface IConnectionData {
|
|
11
|
+
connection: WebSocket;
|
|
12
|
+
languageClient: LibroLanguageClient;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// TODO: type is not complete
|
|
16
|
+
export type LSPFeatureType = 'textDocument/formatting';
|
|
17
|
+
|
|
18
|
+
@singleton()
|
|
19
|
+
export class LibroLanguageClientManager {
|
|
20
|
+
@inject(ILanguageServerManagerFactory)
|
|
21
|
+
protected readonly languageServerManagerFactory: ILanguageServerManagerFactory;
|
|
22
|
+
|
|
23
|
+
protected languageServerManager: ILanguageServerManager;
|
|
24
|
+
|
|
25
|
+
protected clientMap = new Map<string, IConnectionData>();
|
|
26
|
+
|
|
27
|
+
@postConstruct()
|
|
28
|
+
init() {
|
|
29
|
+
this.languageServerManager = this.languageServerManagerFactory({});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected serverUri(languageServerId: string) {
|
|
33
|
+
const wsBase = PageConfig.getBaseUrl().replace(/^http/, 'ws');
|
|
34
|
+
return URL.join(wsBase, 'lsp', 'ws', languageServerId);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getServers(language = 'python') {
|
|
38
|
+
await this.languageServerManager.ready;
|
|
39
|
+
const serverIds = this.languageServerManager.getMatchingServers({
|
|
40
|
+
language,
|
|
41
|
+
});
|
|
42
|
+
return serverIds;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async getServerSpecs(language = 'python') {
|
|
46
|
+
await this.languageServerManager.ready;
|
|
47
|
+
const specs = this.languageServerManager.getMatchingSpecs({
|
|
48
|
+
language,
|
|
49
|
+
});
|
|
50
|
+
return specs;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async refreshRunning() {
|
|
54
|
+
await this.languageServerManager.refreshRunning();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get sessionsChanged() {
|
|
58
|
+
return this.languageServerManager.sessionsChanged;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get sessions() {
|
|
62
|
+
const res: TSessionMap = new Map();
|
|
63
|
+
this.languageServerManager.sessions.forEach((item, key) => {
|
|
64
|
+
if (item.status === 'started') {
|
|
65
|
+
res.set(key, item);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return res;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async getOrCreateLanguageClient(
|
|
72
|
+
languageServerId: string,
|
|
73
|
+
options: LibroLanguageClientOptions,
|
|
74
|
+
) {
|
|
75
|
+
if (this.clientMap.has(languageServerId)) {
|
|
76
|
+
return this.clientMap.get(languageServerId);
|
|
77
|
+
}
|
|
78
|
+
const url = this.serverUri(languageServerId);
|
|
79
|
+
const client = await this.createLanguageClient(url, options);
|
|
80
|
+
this.clientMap.set(languageServerId, client);
|
|
81
|
+
this.refreshRunning();
|
|
82
|
+
return client;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected createLanguageClient = (
|
|
86
|
+
url: string,
|
|
87
|
+
options: LibroLanguageClientOptions,
|
|
88
|
+
) => {
|
|
89
|
+
return LibroLanguageClient.createWebSocketLanguageClient(url, options);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
async closeLanguageClient(languageServerId: string) {
|
|
93
|
+
await getOrigin(this.clientMap.get(languageServerId)?.languageClient)?.dispose();
|
|
94
|
+
getOrigin(this.clientMap.get(languageServerId)?.connection)?.close();
|
|
95
|
+
this.clientMap.delete(languageServerId);
|
|
96
|
+
this.refreshRunning();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async closeAllLanguageClient() {
|
|
100
|
+
const servers = await this.getServers();
|
|
101
|
+
await Promise.all(servers.map((server) => this.closeLanguageClient(server)));
|
|
102
|
+
this.refreshRunning();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async getFeatureStatus(
|
|
106
|
+
feature: LSPFeatureType,
|
|
107
|
+
language = 'python',
|
|
108
|
+
): Promise<boolean> {
|
|
109
|
+
let featureEnabled = false;
|
|
110
|
+
const serverids = await this.getServers(language);
|
|
111
|
+
serverids.forEach((id) => {
|
|
112
|
+
const featureState = this.clientMap
|
|
113
|
+
.get(id)
|
|
114
|
+
?.languageClient.getFeature(feature)
|
|
115
|
+
.getState();
|
|
116
|
+
if (featureState?.kind === 'document' && featureState.registrations === true) {
|
|
117
|
+
featureEnabled = true;
|
|
118
|
+
}
|
|
119
|
+
if (featureState?.kind === 'workspace' && featureState.registrations === true) {
|
|
120
|
+
featureEnabled = true;
|
|
121
|
+
}
|
|
122
|
+
if (featureState?.kind === 'window' && featureState.registrations === true) {
|
|
123
|
+
featureEnabled = true;
|
|
124
|
+
}
|
|
125
|
+
if (featureState?.kind === 'static') {
|
|
126
|
+
featureEnabled = true;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return featureEnabled;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Deferred } from '@difizen/mana-common';
|
|
2
|
+
import {
|
|
3
|
+
BrowserMessageReader,
|
|
4
|
+
BrowserMessageWriter,
|
|
5
|
+
} from '@difizen/vscode-languageserver-protocol/browser.js';
|
|
6
|
+
import {
|
|
7
|
+
WebSocketMessageReader,
|
|
8
|
+
WebSocketMessageWriter,
|
|
9
|
+
toSocket,
|
|
10
|
+
} from 'vscode-ws-jsonrpc';
|
|
11
|
+
|
|
12
|
+
import type { LanguageClientOptions, MessageTransports } from './common/client.js';
|
|
13
|
+
import { BaseLanguageClient } from './common/client.js';
|
|
14
|
+
|
|
15
|
+
export interface IConnectionProvider {
|
|
16
|
+
get(encoding: string): Promise<MessageTransports>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LibroLanguageClientOptions {
|
|
20
|
+
name: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
clientOptions: LanguageClientOptions;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface LibroLanguageClientFullOptions extends LibroLanguageClientOptions {
|
|
26
|
+
connectionProvider: IConnectionProvider;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class LibroLanguageClient extends BaseLanguageClient {
|
|
30
|
+
static createWebSocketLanguageClient = async (
|
|
31
|
+
url: string,
|
|
32
|
+
options: LibroLanguageClientOptions,
|
|
33
|
+
) => {
|
|
34
|
+
const deferred = new Deferred<{
|
|
35
|
+
connection: WebSocket;
|
|
36
|
+
languageClient: LibroLanguageClient;
|
|
37
|
+
}>();
|
|
38
|
+
const webSocket = new WebSocket(url);
|
|
39
|
+
webSocket.onopen = async () => {
|
|
40
|
+
const socket = toSocket(webSocket);
|
|
41
|
+
const reader = new WebSocketMessageReader(socket);
|
|
42
|
+
const writer = new WebSocketMessageWriter(socket);
|
|
43
|
+
const connectionProvider = {
|
|
44
|
+
get: () => {
|
|
45
|
+
return Promise.resolve({ reader, writer });
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const languageClient = new LibroLanguageClient({
|
|
49
|
+
...options,
|
|
50
|
+
connectionProvider,
|
|
51
|
+
});
|
|
52
|
+
await languageClient.start();
|
|
53
|
+
reader.onClose(() => languageClient.stop());
|
|
54
|
+
deferred.resolve({
|
|
55
|
+
connection: webSocket,
|
|
56
|
+
languageClient,
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return deferred.promise;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
static createWebWorkerLanguageClient = async (
|
|
63
|
+
url: string,
|
|
64
|
+
options: LibroLanguageClientOptions,
|
|
65
|
+
): Promise<{ connection: Worker; languageClient: LibroLanguageClient }> => {
|
|
66
|
+
const worker = new Worker(url);
|
|
67
|
+
const reader = new BrowserMessageReader(worker);
|
|
68
|
+
const writer = new BrowserMessageWriter(worker);
|
|
69
|
+
const connectionProvider = {
|
|
70
|
+
get: () => {
|
|
71
|
+
return Promise.resolve({ reader, writer });
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
const languageClient = new LibroLanguageClient({
|
|
75
|
+
...options,
|
|
76
|
+
connectionProvider,
|
|
77
|
+
});
|
|
78
|
+
await languageClient.start();
|
|
79
|
+
reader.onClose(() => languageClient.stop());
|
|
80
|
+
return { connection: worker, languageClient };
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
protected readonly connectionProvider: IConnectionProvider;
|
|
84
|
+
|
|
85
|
+
constructor({
|
|
86
|
+
id,
|
|
87
|
+
name,
|
|
88
|
+
clientOptions,
|
|
89
|
+
connectionProvider,
|
|
90
|
+
}: LibroLanguageClientFullOptions) {
|
|
91
|
+
super(id || name.toLowerCase(), name, clientOptions);
|
|
92
|
+
this.connectionProvider = connectionProvider;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
protected override createMessageTransports(
|
|
96
|
+
encoding: string,
|
|
97
|
+
): Promise<MessageTransports> {
|
|
98
|
+
return this.connectionProvider.get(encoding);
|
|
99
|
+
}
|
|
100
|
+
}
|
package/src/module.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LibroLSPModule } from '@difizen/libro-lsp';
|
|
2
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
3
|
+
|
|
4
|
+
import { LibroWindow } from './common/vscodeAdaptor/libroWindow.js';
|
|
5
|
+
import { LibroWorkspace } from './common/vscodeAdaptor/libroWorkspace.js';
|
|
6
|
+
import { LSPEnv } from './common/vscodeAdaptor/lspEnv.js';
|
|
7
|
+
import { MonacoLanguages } from './common/vscodeAdaptor/monacoLanguages.js';
|
|
8
|
+
import { setupLspEnv } from './common/vscodeAdaptor/vscodeAdaptor.js';
|
|
9
|
+
import { LibroLanguageClientContribution } from './libro-language-client-contribution.js';
|
|
10
|
+
import { LibroLanguageClientManager } from './libro-language-client-manager.js';
|
|
11
|
+
|
|
12
|
+
export const LibroLanguageClientModule = ManaModule.create()
|
|
13
|
+
.register(LibroLanguageClientManager, LibroLanguageClientContribution, LSPEnv)
|
|
14
|
+
.register(MonacoLanguages, LibroWindow, LibroWorkspace)
|
|
15
|
+
.dependOn(LibroLSPModule)
|
|
16
|
+
.preload((ctx) => {
|
|
17
|
+
setupLspEnv(ctx.container);
|
|
18
|
+
return Promise.resolve();
|
|
19
|
+
});
|