@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,36 @@
|
|
|
1
|
+
import { LibroService } from '@difizen/libro-core';
|
|
2
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
3
|
+
import type { Event, FileSystemWatcher, GlobPattern, Uri } from 'vscode';
|
|
4
|
+
|
|
5
|
+
import { EventEmitter } from './vscodeAdaptor.js';
|
|
6
|
+
|
|
7
|
+
@singleton()
|
|
8
|
+
export class LibroFileWatcher implements FileSystemWatcher {
|
|
9
|
+
@inject(LibroService) protected readonly libroService: LibroService;
|
|
10
|
+
|
|
11
|
+
create(
|
|
12
|
+
globPattern: GlobPattern,
|
|
13
|
+
ignoreCreateEvents?: boolean,
|
|
14
|
+
ignoreChangeEvents?: boolean,
|
|
15
|
+
ignoreDeleteEvents?: boolean,
|
|
16
|
+
) {
|
|
17
|
+
this.globPattern = globPattern;
|
|
18
|
+
this.ignoreCreateEvents = ignoreCreateEvents ?? true;
|
|
19
|
+
this.ignoreChangeEvents = ignoreChangeEvents ?? true;
|
|
20
|
+
this.ignoreDeleteEvents = ignoreDeleteEvents ?? true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
globPattern: GlobPattern;
|
|
24
|
+
ignoreCreateEvents: boolean;
|
|
25
|
+
ignoreChangeEvents: boolean;
|
|
26
|
+
ignoreDeleteEvents: boolean;
|
|
27
|
+
protected onDidCreateEmitter = new EventEmitter<Uri>();
|
|
28
|
+
onDidCreate: Event<Uri> = this.onDidCreateEmitter.event;
|
|
29
|
+
protected onDidChangeEmitter = new EventEmitter<Uri>();
|
|
30
|
+
onDidChange: Event<Uri> = this.onDidChangeEmitter.event;
|
|
31
|
+
protected onDidDeleteEmitter = new EventEmitter<Uri>();
|
|
32
|
+
onDidDelete: Event<Uri> = this.onDidDeleteEmitter.event;
|
|
33
|
+
dispose() {
|
|
34
|
+
// console.log('Method not implemented.');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
import type { UriComponents } from '@difizen/monaco-editor-core';
|
|
2
|
+
import type { Uri } from 'vscode';
|
|
3
|
+
|
|
4
|
+
export function asArray<T>(x: T | T[]): T[];
|
|
5
|
+
export function asArray<T>(x: T | readonly T[]): readonly T[];
|
|
6
|
+
export function asArray<T>(x: T | T[]): T[] {
|
|
7
|
+
return Array.isArray(x) ? x : [x];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Remove all falsy values from `array`. The original array IS modified.
|
|
12
|
+
*/
|
|
13
|
+
export function coalesceInPlace<T>(
|
|
14
|
+
array: Array<T | undefined | null>,
|
|
15
|
+
): asserts array is Array<T> {
|
|
16
|
+
let to = 0;
|
|
17
|
+
for (let i = 0; i < array.length; i++) {
|
|
18
|
+
if (array[i]) {
|
|
19
|
+
array[to] = array[i];
|
|
20
|
+
to += 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
array.length = to;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function equals<T>(
|
|
27
|
+
one: ReadonlyArray<T> | undefined,
|
|
28
|
+
other: ReadonlyArray<T> | undefined,
|
|
29
|
+
itemEquals: (a: T, b: T) => boolean = (a, b) => a === b,
|
|
30
|
+
): boolean {
|
|
31
|
+
if (one === other) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!one || !other) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (one.length !== other.length) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (let i = 0, len = one.length; i < len; i++) {
|
|
44
|
+
if (!itemEquals(one[i], other[i])) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function illegalArgument(name?: string): Error {
|
|
53
|
+
if (name) {
|
|
54
|
+
return new Error(`Illegal argument: ${name}`);
|
|
55
|
+
} else {
|
|
56
|
+
return new Error('Illegal argument');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface IRelativePattern {
|
|
61
|
+
/**
|
|
62
|
+
* A base file path to which this pattern will be matched against relatively.
|
|
63
|
+
*/
|
|
64
|
+
readonly base: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A file glob pattern like `*.{ts,js}` that will be matched on file paths
|
|
68
|
+
* relative to the base path.
|
|
69
|
+
*
|
|
70
|
+
* Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
|
|
71
|
+
* the file glob pattern will match on `index.js`.
|
|
72
|
+
*/
|
|
73
|
+
readonly pattern: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface MarkdownStringTrustedOptions {
|
|
77
|
+
readonly enabledCommands: readonly string[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface IMarkdownString {
|
|
81
|
+
readonly value: string;
|
|
82
|
+
readonly isTrusted?: boolean | MarkdownStringTrustedOptions;
|
|
83
|
+
readonly supportThemeIcons?: boolean;
|
|
84
|
+
readonly supportHtml?: boolean;
|
|
85
|
+
readonly baseUri?: UriComponents;
|
|
86
|
+
uris?: { [href: string]: UriComponents };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const enum MarkdownStringTextNewlineStyle {
|
|
90
|
+
Paragraph = 0,
|
|
91
|
+
Break = 1,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class MarkdownString implements IMarkdownString {
|
|
95
|
+
public value: string;
|
|
96
|
+
public isTrusted?: boolean | MarkdownStringTrustedOptions;
|
|
97
|
+
public supportThemeIcons?: boolean;
|
|
98
|
+
public supportHtml?: boolean;
|
|
99
|
+
public baseUri?: Uri;
|
|
100
|
+
|
|
101
|
+
constructor(
|
|
102
|
+
value = '',
|
|
103
|
+
isTrustedOrOptions:
|
|
104
|
+
| boolean
|
|
105
|
+
| {
|
|
106
|
+
isTrusted?: boolean | MarkdownStringTrustedOptions;
|
|
107
|
+
supportThemeIcons?: boolean;
|
|
108
|
+
supportHtml?: boolean;
|
|
109
|
+
} = false,
|
|
110
|
+
) {
|
|
111
|
+
this.value = value;
|
|
112
|
+
if (typeof this.value !== 'string') {
|
|
113
|
+
throw illegalArgument('value');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (typeof isTrustedOrOptions === 'boolean') {
|
|
117
|
+
this.isTrusted = isTrustedOrOptions;
|
|
118
|
+
this.supportThemeIcons = false;
|
|
119
|
+
this.supportHtml = false;
|
|
120
|
+
} else {
|
|
121
|
+
this.isTrusted = isTrustedOrOptions.isTrusted ?? undefined;
|
|
122
|
+
this.supportThemeIcons = isTrustedOrOptions.supportThemeIcons ?? false;
|
|
123
|
+
this.supportHtml = isTrustedOrOptions.supportHtml ?? false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
appendText(
|
|
128
|
+
value: string,
|
|
129
|
+
newlineStyle: MarkdownStringTextNewlineStyle = MarkdownStringTextNewlineStyle.Paragraph,
|
|
130
|
+
): MarkdownString {
|
|
131
|
+
this.value += escapeMarkdownSyntaxTokens(
|
|
132
|
+
this.supportThemeIcons ? escapeIcons(value) : value,
|
|
133
|
+
) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.
|
|
134
|
+
.replace(/([ \t]+)/g, (_match, g1) => ' '.repeat(g1.length)) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.
|
|
135
|
+
// eslint-disable-next-line no-useless-escape
|
|
136
|
+
.replace(/\>/gm, '\\>') // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.
|
|
137
|
+
.replace(
|
|
138
|
+
/\n/g,
|
|
139
|
+
newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\n' : '\n\n',
|
|
140
|
+
); // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.
|
|
141
|
+
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
appendMarkdown(value: string): MarkdownString {
|
|
146
|
+
this.value += value;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
appendCodeblock(langId: string, code: string): MarkdownString {
|
|
151
|
+
this.value += `\n${appendEscapedMarkdownCodeBlockFence(code, langId)}\n`;
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
appendLink(target: Uri | string, label: string, title?: string): MarkdownString {
|
|
156
|
+
this.value += '[';
|
|
157
|
+
this.value += this._escape(label, ']');
|
|
158
|
+
this.value += '](';
|
|
159
|
+
this.value += this._escape(String(target), ')');
|
|
160
|
+
if (title) {
|
|
161
|
+
this.value += ` "${this._escape(this._escape(title, '"'), ')')}"`;
|
|
162
|
+
}
|
|
163
|
+
this.value += ')';
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private _escape(value: string, ch: string): string {
|
|
168
|
+
const r = new RegExp(escapeRegExpCharacters(ch), 'g');
|
|
169
|
+
return value.replace(r, (match, offset) => {
|
|
170
|
+
if (value.charAt(offset - 1) !== '\\') {
|
|
171
|
+
return `\\${match}`;
|
|
172
|
+
} else {
|
|
173
|
+
return match;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function isEmptyMarkdownString(
|
|
180
|
+
oneOrMany: IMarkdownString | IMarkdownString[] | null | undefined,
|
|
181
|
+
): boolean {
|
|
182
|
+
if (isMarkdownString(oneOrMany)) {
|
|
183
|
+
return !oneOrMany.value;
|
|
184
|
+
} else if (Array.isArray(oneOrMany)) {
|
|
185
|
+
return oneOrMany.every(isEmptyMarkdownString);
|
|
186
|
+
} else {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function isMarkdownString(thing: any): thing is IMarkdownString {
|
|
192
|
+
if (thing instanceof MarkdownString) {
|
|
193
|
+
return true;
|
|
194
|
+
} else if (thing && typeof thing === 'object') {
|
|
195
|
+
return (
|
|
196
|
+
typeof (<IMarkdownString>thing).value === 'string' &&
|
|
197
|
+
(typeof (<IMarkdownString>thing).isTrusted === 'boolean' ||
|
|
198
|
+
typeof (<IMarkdownString>thing).isTrusted === 'object' ||
|
|
199
|
+
(<IMarkdownString>thing).isTrusted === undefined) &&
|
|
200
|
+
(typeof (<IMarkdownString>thing).supportThemeIcons === 'boolean' ||
|
|
201
|
+
(<IMarkdownString>thing).supportThemeIcons === undefined)
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function escapeMarkdownSyntaxTokens(text: string): string {
|
|
208
|
+
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
|
209
|
+
return text.replace(/[\\`*_{}[\]()#+\-!~]/g, '\\$&'); // CodeQL [SM02383] Backslash is escaped in the character class
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @see https://github.com/microsoft/vscode/issues/193746
|
|
214
|
+
*/
|
|
215
|
+
export function appendEscapedMarkdownCodeBlockFence(code: string, langId: string) {
|
|
216
|
+
const longestFenceLength =
|
|
217
|
+
code.match(/^`+/gm)?.reduce((a, b) => (a.length > b.length ? a : b)).length ?? 0;
|
|
218
|
+
const desiredFenceLength = longestFenceLength >= 3 ? longestFenceLength + 1 : 3;
|
|
219
|
+
|
|
220
|
+
// the markdown result
|
|
221
|
+
return [
|
|
222
|
+
`${'`'.repeat(desiredFenceLength)}${langId}`,
|
|
223
|
+
code,
|
|
224
|
+
`${'`'.repeat(desiredFenceLength)}`,
|
|
225
|
+
].join('\n');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function escapeDoubleQuotes(input: string) {
|
|
229
|
+
return input.replace(/"/g, '"');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function removeMarkdownEscapes(text: string): string {
|
|
233
|
+
if (!text) {
|
|
234
|
+
return text;
|
|
235
|
+
}
|
|
236
|
+
return text.replace(/\\([\\`*_{}[\]()#+\-.!~])/g, '$1');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export function parseHrefAndDimensions(href: string): {
|
|
240
|
+
href: string;
|
|
241
|
+
dimensions: string[];
|
|
242
|
+
} {
|
|
243
|
+
const dimensions: string[] = [];
|
|
244
|
+
const splitted = href.split('|').map((s) => s.trim());
|
|
245
|
+
href = splitted[0];
|
|
246
|
+
const parameters = splitted[1];
|
|
247
|
+
if (parameters) {
|
|
248
|
+
const heightFromParams = /height=(\d+)/.exec(parameters);
|
|
249
|
+
const widthFromParams = /width=(\d+)/.exec(parameters);
|
|
250
|
+
const height = heightFromParams ? heightFromParams[1] : '';
|
|
251
|
+
const width = widthFromParams ? widthFromParams[1] : '';
|
|
252
|
+
const widthIsFinite = isFinite(parseInt(width));
|
|
253
|
+
const heightIsFinite = isFinite(parseInt(height));
|
|
254
|
+
if (widthIsFinite) {
|
|
255
|
+
dimensions.push(`width="${width}"`);
|
|
256
|
+
}
|
|
257
|
+
if (heightIsFinite) {
|
|
258
|
+
dimensions.push(`height="${height}"`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return { href, dimensions };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export const iconNameExpression = '[A-Za-z0-9-]+';
|
|
265
|
+
export const iconModifierExpression = '~[A-Za-z]+';
|
|
266
|
+
const iconsRegex = new RegExp(
|
|
267
|
+
`\\$\\(${iconNameExpression}(?:${iconModifierExpression})?\\)`,
|
|
268
|
+
'g',
|
|
269
|
+
); // no capturing groups
|
|
270
|
+
|
|
271
|
+
const escapeIconsRegex = new RegExp(`(\\\\)?${iconsRegex.source}`, 'g');
|
|
272
|
+
export function escapeIcons(text: string): string {
|
|
273
|
+
return text.replace(escapeIconsRegex, (match, escaped) =>
|
|
274
|
+
escaped ? match : `\\${match}`,
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Escapes regular expression characters in a given string
|
|
280
|
+
*/
|
|
281
|
+
export function escapeRegExpCharacters(value: string): string {
|
|
282
|
+
// eslint-disable-next-line no-useless-escape
|
|
283
|
+
return value.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g, '\\$&');
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
interface ResourceMapKeyFn {
|
|
287
|
+
(resource: Uri): string;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
class ResourceMapEntry<T> {
|
|
291
|
+
constructor(
|
|
292
|
+
readonly uri: Uri,
|
|
293
|
+
readonly value: T,
|
|
294
|
+
) {}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function isEntries<T>(
|
|
298
|
+
arg: ResourceMap<T> | ResourceMapKeyFn | readonly (readonly [Uri, T])[] | undefined,
|
|
299
|
+
): arg is readonly (readonly [Uri, T])[] {
|
|
300
|
+
return Array.isArray(arg);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export class ResourceMap<T> implements Map<Uri, T> {
|
|
304
|
+
private static readonly defaultToKey = (resource: Uri) => resource.toString();
|
|
305
|
+
|
|
306
|
+
readonly [Symbol.toStringTag] = 'ResourceMap';
|
|
307
|
+
|
|
308
|
+
private readonly map: Map<string, ResourceMapEntry<T>>;
|
|
309
|
+
private readonly toKey: ResourceMapKeyFn;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
*
|
|
313
|
+
* @param toKey Custom uri identity function, e.g use an existing `IExtUri#getComparison`-util
|
|
314
|
+
*/
|
|
315
|
+
constructor(toKey?: ResourceMapKeyFn);
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
*
|
|
319
|
+
* @param other Another resource which this maps is created from
|
|
320
|
+
* @param toKey Custom uri identity function, e.g use an existing `IExtUri#getComparison`-util
|
|
321
|
+
*/
|
|
322
|
+
constructor(other?: ResourceMap<T>, toKey?: ResourceMapKeyFn);
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
*
|
|
326
|
+
* @param other Another resource which this maps is created from
|
|
327
|
+
* @param toKey Custom uri identity function, e.g use an existing `IExtUri#getComparison`-util
|
|
328
|
+
*/
|
|
329
|
+
constructor(entries?: readonly (readonly [Uri, T])[], toKey?: ResourceMapKeyFn);
|
|
330
|
+
|
|
331
|
+
constructor(
|
|
332
|
+
arg?: ResourceMap<T> | ResourceMapKeyFn | readonly (readonly [Uri, T])[],
|
|
333
|
+
toKey?: ResourceMapKeyFn,
|
|
334
|
+
) {
|
|
335
|
+
if (arg instanceof ResourceMap) {
|
|
336
|
+
this.map = new Map(arg.map);
|
|
337
|
+
this.toKey = toKey ?? ResourceMap.defaultToKey;
|
|
338
|
+
} else if (isEntries(arg)) {
|
|
339
|
+
this.map = new Map();
|
|
340
|
+
this.toKey = toKey ?? ResourceMap.defaultToKey;
|
|
341
|
+
|
|
342
|
+
for (const [resource, value] of arg) {
|
|
343
|
+
this.set(resource, value);
|
|
344
|
+
}
|
|
345
|
+
} else {
|
|
346
|
+
this.map = new Map();
|
|
347
|
+
this.toKey = arg ?? ResourceMap.defaultToKey;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
set(resource: Uri, value: T): this {
|
|
352
|
+
this.map.set(this.toKey(resource), new ResourceMapEntry(resource, value));
|
|
353
|
+
return this;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
get(resource: Uri): T | undefined {
|
|
357
|
+
return this.map.get(this.toKey(resource))?.value;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
has(resource: Uri): boolean {
|
|
361
|
+
return this.map.has(this.toKey(resource));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
get size(): number {
|
|
365
|
+
return this.map.size;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
clear(): void {
|
|
369
|
+
this.map.clear();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
delete(resource: Uri): boolean {
|
|
373
|
+
return this.map.delete(this.toKey(resource));
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
forEach(clb: (value: T, key: Uri, map: Map<Uri, T>) => void, thisArg?: any): void {
|
|
377
|
+
if (typeof thisArg !== 'undefined') {
|
|
378
|
+
clb = clb.bind(thisArg);
|
|
379
|
+
}
|
|
380
|
+
for (const [_, entry] of this.map) {
|
|
381
|
+
clb(entry.value, entry.uri, <any>this);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
*values(): IterableIterator<T> {
|
|
386
|
+
for (const entry of this.map.values()) {
|
|
387
|
+
yield entry.value;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
*keys(): IterableIterator<Uri> {
|
|
392
|
+
for (const entry of this.map.values()) {
|
|
393
|
+
yield entry.uri;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
*entries(): IterableIterator<[Uri, T]> {
|
|
398
|
+
for (const entry of this.map.values()) {
|
|
399
|
+
yield [entry.uri, entry.value];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
*[Symbol.iterator](): IterableIterator<[Uri, T]> {
|
|
404
|
+
for (const [, entry] of this.map) {
|
|
405
|
+
yield [entry.uri, entry.value];
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export const Mimes = Object.freeze({
|
|
411
|
+
text: 'text/plain',
|
|
412
|
+
binary: 'application/octet-stream',
|
|
413
|
+
unknown: 'application/unknown',
|
|
414
|
+
markdown: 'text/markdown',
|
|
415
|
+
latex: 'text/latex',
|
|
416
|
+
uriList: 'text/uri-list',
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
const _simplePattern = /^(.+)\/(.+?)(;.+)?$/;
|
|
420
|
+
|
|
421
|
+
export function normalizeMimeType(mimeType: string): string;
|
|
422
|
+
export function normalizeMimeType(mimeType: string, strict: true): string | undefined;
|
|
423
|
+
export function normalizeMimeType(mimeType: string, strict?: true): string | undefined {
|
|
424
|
+
const match = _simplePattern.exec(mimeType);
|
|
425
|
+
if (!match) {
|
|
426
|
+
return strict ? undefined : mimeType;
|
|
427
|
+
}
|
|
428
|
+
// https://datatracker.ietf.org/doc/html/rfc2045#section-5.1
|
|
429
|
+
// media and subtype must ALWAYS be lowercase, parameter not
|
|
430
|
+
return `${match[1].toLowerCase()}/${match[2].toLowerCase()}${match[3] ?? ''}`;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* @returns whether the provided parameter is a JavaScript String or not.
|
|
435
|
+
*/
|
|
436
|
+
export function isString(str: unknown): str is string {
|
|
437
|
+
return typeof str === 'string';
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* @returns whether the provided parameter is a JavaScript Array and each element in the array is a string.
|
|
442
|
+
*/
|
|
443
|
+
export function isStringArray(value: unknown): value is string[] {
|
|
444
|
+
return Array.isArray(value) && (<unknown[]>value).every((elem) => isString(elem));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* @returns whether the provided parameter is of type `object` but **not**
|
|
449
|
+
* `null`, an `array`, a `regexp`, nor a `date`.
|
|
450
|
+
*/
|
|
451
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
452
|
+
export function isObject(obj: unknown): obj is Object {
|
|
453
|
+
// The method can't do a type cast since there are type (like strings) which
|
|
454
|
+
// are subclasses of any put not positvely matched by the function. Hence type
|
|
455
|
+
// narrowing results in wrong results.
|
|
456
|
+
return (
|
|
457
|
+
typeof obj === 'object' &&
|
|
458
|
+
obj !== null &&
|
|
459
|
+
!Array.isArray(obj) &&
|
|
460
|
+
!(obj instanceof RegExp) &&
|
|
461
|
+
!(obj instanceof Date)
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* In **contrast** to just checking `typeof` this will return `false` for `NaN`.
|
|
467
|
+
* @returns whether the provided parameter is a JavaScript Number or not.
|
|
468
|
+
*/
|
|
469
|
+
export function isNumber(obj: unknown): obj is number {
|
|
470
|
+
return typeof obj === 'number' && !isNaN(obj);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export const enum CellEditType {
|
|
474
|
+
Replace = 1,
|
|
475
|
+
Output = 2,
|
|
476
|
+
Metadata = 3,
|
|
477
|
+
CellLanguage = 4,
|
|
478
|
+
DocumentMetadata = 5,
|
|
479
|
+
Move = 6,
|
|
480
|
+
OutputItems = 7,
|
|
481
|
+
PartialMetadata = 8,
|
|
482
|
+
PartialInternalMetadata = 9,
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface NotebookCellMetadata {
|
|
486
|
+
/**
|
|
487
|
+
* custom metadata
|
|
488
|
+
*/
|
|
489
|
+
[key: string]: unknown;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export interface ICellMetadataEdit {
|
|
493
|
+
editType: CellEditType.Metadata;
|
|
494
|
+
index: number;
|
|
495
|
+
metadata: NotebookCellMetadata;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export interface IDocumentMetadataEdit {
|
|
499
|
+
editType: CellEditType.DocumentMetadata;
|
|
500
|
+
metadata: NotebookDocumentMetadata;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export type NotebookDocumentMetadata = Record<string, unknown>;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Whether the provided mime type is a text stream like `stdout`, `stderr`.
|
|
507
|
+
*/
|
|
508
|
+
export function isTextStreamMime(mimeType: string) {
|
|
509
|
+
return [
|
|
510
|
+
'application/vnd.code.notebook.stdout',
|
|
511
|
+
'application/vnd.code.notebook.stderr',
|
|
512
|
+
].includes(mimeType);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export interface IRelativePatternDto extends IRelativePattern {
|
|
516
|
+
baseUri: UriComponents;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export enum FileSystemProviderErrorCode {
|
|
520
|
+
FileExists = 'EntryExists',
|
|
521
|
+
FileNotFound = 'EntryNotFound',
|
|
522
|
+
FileNotADirectory = 'EntryNotADirectory',
|
|
523
|
+
FileIsADirectory = 'EntryIsADirectory',
|
|
524
|
+
FileExceedsStorageQuota = 'EntryExceedsStorageQuota',
|
|
525
|
+
FileTooLarge = 'EntryTooLarge',
|
|
526
|
+
FileWriteLocked = 'EntryWriteLocked',
|
|
527
|
+
NoPermissions = 'NoPermissions',
|
|
528
|
+
Unavailable = 'Unavailable',
|
|
529
|
+
Unknown = 'Unknown',
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export function markAsFileSystemProviderError(
|
|
533
|
+
error: Error,
|
|
534
|
+
code: FileSystemProviderErrorCode,
|
|
535
|
+
): Error {
|
|
536
|
+
error.name = code ? `${code} (FileSystemError)` : `FileSystemError`;
|
|
537
|
+
|
|
538
|
+
return error;
|
|
539
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { FileStat, FileSystem, Uri } from 'vscode';
|
|
2
|
+
|
|
3
|
+
import { FileType } from './vscodeAdaptor.js';
|
|
4
|
+
|
|
5
|
+
export class LibroFS implements FileSystem {
|
|
6
|
+
stat(uri: Uri): Thenable<FileStat> {
|
|
7
|
+
return Promise.resolve<FileStat>({
|
|
8
|
+
type: FileType.File,
|
|
9
|
+
ctime: 0,
|
|
10
|
+
mtime: 0,
|
|
11
|
+
size: 0,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
readDirectory(uri: Uri): Thenable<[string, FileType][]> {
|
|
15
|
+
throw new Error('Method not implemented.');
|
|
16
|
+
}
|
|
17
|
+
createDirectory(uri: Uri): Thenable<void> {
|
|
18
|
+
throw new Error('Method not implemented.');
|
|
19
|
+
}
|
|
20
|
+
readFile(uri: Uri): Thenable<Uint8Array> {
|
|
21
|
+
throw new Error('Method not implemented.');
|
|
22
|
+
}
|
|
23
|
+
writeFile(uri: Uri, content: Uint8Array): Thenable<void> {
|
|
24
|
+
throw new Error('Method not implemented.');
|
|
25
|
+
}
|
|
26
|
+
delete(
|
|
27
|
+
uri: Uri,
|
|
28
|
+
options?:
|
|
29
|
+
| { recursive?: boolean | undefined; useTrash?: boolean | undefined }
|
|
30
|
+
| undefined,
|
|
31
|
+
): Thenable<void> {
|
|
32
|
+
throw new Error('Method not implemented.');
|
|
33
|
+
}
|
|
34
|
+
rename(
|
|
35
|
+
source: Uri,
|
|
36
|
+
target: Uri,
|
|
37
|
+
options?: { overwrite?: boolean | undefined } | undefined,
|
|
38
|
+
): Thenable<void> {
|
|
39
|
+
throw new Error('Method not implemented.');
|
|
40
|
+
}
|
|
41
|
+
copy(
|
|
42
|
+
source: Uri,
|
|
43
|
+
target: Uri,
|
|
44
|
+
options?: { overwrite?: boolean | undefined } | undefined,
|
|
45
|
+
): Thenable<void> {
|
|
46
|
+
throw new Error('Method not implemented.');
|
|
47
|
+
}
|
|
48
|
+
isWritableFileSystem(scheme: string): boolean | undefined {
|
|
49
|
+
throw new Error('Method not implemented.');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { noop, singleton } from '@difizen/mana-app';
|
|
3
|
+
import type {
|
|
4
|
+
TabGroups,
|
|
5
|
+
TextEditor,
|
|
6
|
+
Event,
|
|
7
|
+
OutputChannel,
|
|
8
|
+
TextDocument,
|
|
9
|
+
Uri,
|
|
10
|
+
ProgressOptions,
|
|
11
|
+
Progress,
|
|
12
|
+
ViewColumn,
|
|
13
|
+
TextDocumentShowOptions,
|
|
14
|
+
CancellationToken,
|
|
15
|
+
} from 'vscode';
|
|
16
|
+
|
|
17
|
+
import type { MsgFunc } from './services.js';
|
|
18
|
+
import { ILibroWindow } from './services.js';
|
|
19
|
+
import { unsupported } from './util.js';
|
|
20
|
+
|
|
21
|
+
@singleton({ token: ILibroWindow })
|
|
22
|
+
export class LibroWindow implements ILibroWindow {
|
|
23
|
+
protected readonly channels = new Map<string, OutputChannel>();
|
|
24
|
+
|
|
25
|
+
tabGroups: TabGroups;
|
|
26
|
+
activeTextEditor: TextEditor | undefined;
|
|
27
|
+
onDidChangeActiveTextEditor: Event<TextEditor | undefined> = () => {
|
|
28
|
+
return {
|
|
29
|
+
dispose: () => {
|
|
30
|
+
return;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
createOutputChannel(name: string, options?: string | { log: true }): OutputChannel {
|
|
35
|
+
const existing = this.channels.get(name);
|
|
36
|
+
if (existing) {
|
|
37
|
+
return existing;
|
|
38
|
+
}
|
|
39
|
+
const channel: OutputChannel = {
|
|
40
|
+
name,
|
|
41
|
+
clear: unsupported,
|
|
42
|
+
replace: unsupported,
|
|
43
|
+
hide: unsupported,
|
|
44
|
+
append(value: string): void {
|
|
45
|
+
console.log(name + ': ' + value);
|
|
46
|
+
},
|
|
47
|
+
appendLine(line: string): void {
|
|
48
|
+
console.log(name + ': ' + line);
|
|
49
|
+
},
|
|
50
|
+
show: noop,
|
|
51
|
+
dispose: noop,
|
|
52
|
+
};
|
|
53
|
+
this.channels.set(name, channel);
|
|
54
|
+
return channel;
|
|
55
|
+
}
|
|
56
|
+
showErrorMessage: MsgFunc = (message: string, ...items) => {
|
|
57
|
+
console.error(message);
|
|
58
|
+
return Promise.resolve(items[0]);
|
|
59
|
+
};
|
|
60
|
+
showWarningMessage: MsgFunc = (message: string, ...items) => {
|
|
61
|
+
console.warn(message);
|
|
62
|
+
return Promise.resolve(items[0]);
|
|
63
|
+
};
|
|
64
|
+
showInformationMessage: MsgFunc = (message: string, ...items) => {
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
console.log(message);
|
|
67
|
+
return Promise.resolve(items[0]);
|
|
68
|
+
};
|
|
69
|
+
showTextDocument(
|
|
70
|
+
documentOrUri: TextDocument | Uri,
|
|
71
|
+
columnOrOptions?: ViewColumn | TextDocumentShowOptions,
|
|
72
|
+
preserveFocus?: boolean,
|
|
73
|
+
): Promise<TextEditor> {
|
|
74
|
+
return Promise.resolve({} as TextEditor);
|
|
75
|
+
}
|
|
76
|
+
withProgress<R>(
|
|
77
|
+
options: ProgressOptions,
|
|
78
|
+
task: (
|
|
79
|
+
progress: Progress<{ message?: string; worked?: number }>,
|
|
80
|
+
token: CancellationToken,
|
|
81
|
+
) => Thenable<R>,
|
|
82
|
+
) {
|
|
83
|
+
return Promise.resolve({} as R);
|
|
84
|
+
}
|
|
85
|
+
}
|