@theia/core 1.34.0-next.7 → 1.34.1
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/README.md +6 -6
- package/i18n/nls.cs.json +26 -100
- package/i18n/nls.de.json +26 -100
- package/i18n/nls.es.json +26 -100
- package/i18n/nls.fr.json +26 -100
- package/i18n/nls.hu.json +26 -100
- package/i18n/nls.it.json +26 -100
- package/i18n/nls.ja.json +26 -100
- package/i18n/nls.json +26 -100
- package/i18n/nls.pl.json +26 -100
- package/i18n/nls.pt-br.json +26 -100
- package/i18n/nls.pt-pt.json +26 -100
- package/i18n/nls.ru.json +26 -100
- package/i18n/nls.zh-cn.json +26 -100
- package/lib/browser/about-dialog.js +1 -1
- package/lib/browser/about-dialog.js.map +1 -1
- package/lib/browser/common-frontend-contribution.js +1 -1
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/core-preferences.d.ts.map +1 -1
- package/lib/browser/core-preferences.js +5 -6
- package/lib/browser/core-preferences.js.map +1 -1
- package/lib/browser/dialogs.js +1 -1
- package/lib/browser/dialogs.js.map +1 -1
- package/lib/browser/frontend-application.d.ts.map +1 -1
- package/lib/browser/frontend-application.js +12 -3
- package/lib/browser/frontend-application.js.map +1 -1
- package/lib/browser/i18n/language-quick-pick-service.js +2 -2
- package/lib/browser/i18n/language-quick-pick-service.js.map +1 -1
- package/lib/browser/label-parser.d.ts +1 -1
- package/lib/browser/label-parser.d.ts.map +1 -1
- package/lib/browser/label-parser.js +2 -1
- package/lib/browser/label-parser.js.map +1 -1
- package/lib/browser/label-provider.d.ts.map +1 -1
- package/lib/browser/label-provider.js +2 -3
- package/lib/browser/label-provider.js.map +1 -1
- package/lib/browser/navigatable-types.d.ts +1 -2
- package/lib/browser/navigatable-types.d.ts.map +1 -1
- package/lib/browser/navigatable-types.js +3 -2
- package/lib/browser/navigatable-types.js.map +1 -1
- package/lib/browser/preferences/injectable-preference-proxy.d.ts.map +1 -1
- package/lib/browser/preferences/injectable-preference-proxy.js +1 -1
- package/lib/browser/preferences/injectable-preference-proxy.js.map +1 -1
- package/lib/browser/preferences/preference-contribution.js +2 -1
- package/lib/browser/preferences/preference-contribution.js.map +1 -1
- package/lib/browser/preferences/preference-language-override-service.js +1 -1
- package/lib/browser/preferences/preference-language-override-service.js.map +1 -1
- package/lib/browser/preferences/preference-provider.d.ts.map +1 -1
- package/lib/browser/preferences/preference-provider.js +3 -7
- package/lib/browser/preferences/preference-provider.js.map +1 -1
- package/lib/browser/preferences/preference-proxy.d.ts.map +1 -1
- package/lib/browser/preferences/preference-proxy.js +3 -1
- package/lib/browser/preferences/preference-proxy.js.map +1 -1
- package/lib/browser/saveable.d.ts.map +1 -1
- package/lib/browser/saveable.js +3 -2
- package/lib/browser/saveable.js.map +1 -1
- package/lib/browser/shell/application-shell.d.ts +12 -0
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +74 -4
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/shell-layout-restorer.d.ts +1 -1
- package/lib/browser/shell/shell-layout-restorer.d.ts.map +1 -1
- package/lib/browser/shell/shell-layout-restorer.js +5 -10
- package/lib/browser/shell/shell-layout-restorer.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js +6 -10
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js.map +1 -1
- package/lib/browser/source-tree/tree-source.d.ts +1 -3
- package/lib/browser/source-tree/tree-source.d.ts.map +1 -1
- package/lib/browser/source-tree/tree-source.js +4 -5
- package/lib/browser/source-tree/tree-source.js.map +1 -1
- package/lib/browser/status-bar/status-bar.js +1 -1
- package/lib/browser/status-bar/status-bar.js.map +1 -1
- package/lib/browser/tree/tree-selection.d.ts.map +1 -1
- package/lib/browser/tree/tree-selection.js +2 -1
- package/lib/browser/tree/tree-selection.js.map +1 -1
- package/lib/browser/tree/tree-widget.d.ts +1 -0
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +5 -2
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/tree/tree.d.ts +1 -1
- package/lib/browser/tree/tree.d.ts.map +1 -1
- package/lib/browser/tree/tree.js +3 -2
- package/lib/browser/tree/tree.js.map +1 -1
- package/lib/browser/view-container.js +2 -2
- package/lib/browser/view-container.js.map +1 -1
- package/lib/browser/widgets/select-component.d.ts +1 -0
- package/lib/browser/widgets/select-component.d.ts.map +1 -1
- package/lib/browser/widgets/select-component.js +8 -3
- package/lib/browser/widgets/select-component.js.map +1 -1
- package/lib/browser/widgets/widget.d.ts.map +1 -1
- package/lib/browser/widgets/widget.js +1 -1
- package/lib/browser/widgets/widget.js.map +1 -1
- package/lib/common/array-utils.d.ts +49 -0
- package/lib/common/array-utils.d.ts.map +1 -0
- package/lib/common/array-utils.js +98 -0
- package/lib/common/array-utils.js.map +1 -0
- package/lib/common/cancellation.d.ts.map +1 -1
- package/lib/common/cancellation.js +4 -4
- package/lib/common/cancellation.js.map +1 -1
- package/lib/common/command.d.ts.map +1 -1
- package/lib/common/command.js +2 -1
- package/lib/common/command.js.map +1 -1
- package/lib/common/disposable.d.ts.map +1 -1
- package/lib/common/disposable.js +4 -3
- package/lib/common/disposable.js.map +1 -1
- package/lib/common/index.d.ts +20 -19
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +23 -20
- package/lib/common/index.js.map +1 -1
- package/lib/common/keybinding.d.ts.map +1 -1
- package/lib/common/keybinding.js +18 -2
- package/lib/common/keybinding.js.map +1 -1
- package/lib/common/keys.d.ts.map +1 -1
- package/lib/common/keys.js +2 -1
- package/lib/common/keys.js.map +1 -1
- package/lib/common/lsp-types.d.ts.map +1 -1
- package/lib/common/lsp-types.js +5 -6
- package/lib/common/lsp-types.js.map +1 -1
- package/lib/common/markdown-rendering/markdown-string.d.ts.map +1 -1
- package/lib/common/markdown-rendering/markdown-string.js +2 -2
- package/lib/common/markdown-rendering/markdown-string.js.map +1 -1
- package/lib/common/menu/menu-types.d.ts.map +1 -1
- package/lib/common/menu/menu-types.js +2 -1
- package/lib/common/menu/menu-types.js.map +1 -1
- package/lib/common/message-service-protocol.d.ts +1 -1
- package/lib/common/message-service-protocol.d.ts.map +1 -1
- package/lib/common/message-service-protocol.js +2 -1
- package/lib/common/message-service-protocol.js.map +1 -1
- package/lib/common/objects.d.ts.map +1 -1
- package/lib/common/objects.js +5 -5
- package/lib/common/objects.js.map +1 -1
- package/lib/common/preferences/preference-schema.d.ts.map +1 -1
- package/lib/common/preferences/preference-schema.js +4 -3
- package/lib/common/preferences/preference-schema.js.map +1 -1
- package/lib/common/prioritizeable.d.ts +17 -0
- package/lib/common/prioritizeable.d.ts.map +1 -0
- package/lib/common/prioritizeable.js +56 -0
- package/lib/common/prioritizeable.js.map +1 -0
- package/lib/common/promise-util.d.ts.map +1 -1
- package/lib/common/promise-util.js +2 -1
- package/lib/common/promise-util.js.map +1 -1
- package/lib/common/selection.d.ts.map +1 -1
- package/lib/common/selection.js +2 -1
- package/lib/common/selection.js.map +1 -1
- package/lib/common/types.d.ts +29 -73
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js +53 -110
- package/lib/common/types.js.map +1 -1
- package/lib/common/uri-command-handler.d.ts.map +1 -1
- package/lib/common/uri-command-handler.js +2 -1
- package/lib/common/uri-command-handler.js.map +1 -1
- package/lib/common/uri.d.ts +1 -0
- package/lib/common/uri.d.ts.map +1 -1
- package/lib/common/uri.js +3 -0
- package/lib/common/uri.js.map +1 -1
- package/lib/common/view-column.d.ts +18 -0
- package/lib/common/view-column.d.ts.map +1 -0
- package/lib/common/view-column.js +37 -0
- package/lib/common/view-column.js.map +1 -0
- package/lib/electron-node/token/electron-token-validator.d.ts +1 -1
- package/lib/electron-node/token/electron-token-validator.d.ts.map +1 -1
- package/lib/electron-node/token/electron-token-validator.js +4 -5
- package/lib/electron-node/token/electron-token-validator.js.map +1 -1
- package/lib/node/backend-application.d.ts +1 -0
- package/lib/node/backend-application.d.ts.map +1 -1
- package/lib/node/backend-application.js +9 -6
- package/lib/node/backend-application.js.map +1 -1
- package/lib/node/i18n/localization-contribution.d.ts.map +1 -1
- package/lib/node/i18n/localization-contribution.js +2 -2
- package/lib/node/i18n/localization-contribution.js.map +1 -1
- package/package.json +6 -6
- package/shared/reflect-metadata/index.d.ts +1 -0
- package/shared/reflect-metadata/index.js +1 -0
- package/src/browser/about-dialog.tsx +1 -1
- package/src/browser/common-frontend-contribution.ts +1 -1
- package/src/browser/core-preferences.ts +5 -6
- package/src/browser/dialogs.ts +1 -1
- package/src/browser/frontend-application.ts +12 -4
- package/src/browser/i18n/language-quick-pick-service.ts +2 -2
- package/src/browser/label-parser.ts +3 -2
- package/src/browser/label-provider.ts +2 -3
- package/src/browser/navigatable-types.ts +6 -7
- package/src/browser/preferences/injectable-preference-proxy.ts +5 -3
- package/src/browser/preferences/preference-contribution.ts +2 -2
- package/src/browser/preferences/preference-language-override-service.ts +2 -2
- package/src/browser/preferences/preference-provider.ts +4 -8
- package/src/browser/preferences/preference-proxy.ts +2 -2
- package/src/browser/saveable.ts +3 -2
- package/src/browser/shell/application-shell.ts +83 -5
- package/src/browser/shell/shell-layout-restorer.ts +6 -11
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.ts +6 -11
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.tsx +1 -1
- package/src/browser/source-tree/tree-source.ts +2 -4
- package/src/browser/status-bar/status-bar.tsx +1 -1
- package/src/browser/style/dialog.css +3 -2
- package/src/browser/style/index.css +0 -1
- package/src/browser/style/select-component.css +1 -0
- package/src/browser/tree/tree-selection.ts +2 -2
- package/src/browser/tree/tree-widget.tsx +5 -3
- package/src/browser/tree/tree.ts +3 -3
- package/src/browser/view-container.ts +3 -3
- package/src/browser/widgets/select-component.tsx +7 -3
- package/src/browser/widgets/widget.ts +2 -2
- package/src/common/array-utils.ts +109 -0
- package/src/common/cancellation.ts +4 -4
- package/src/common/command.ts +2 -1
- package/src/common/disposable.ts +3 -1
- package/src/common/i18n/nls.metadata.json +18565 -14326
- package/src/common/index.ts +20 -19
- package/src/common/keybinding.ts +5 -2
- package/src/common/keys.ts +2 -1
- package/src/common/lsp-types.ts +5 -6
- package/src/common/markdown-rendering/markdown-string.ts +2 -2
- package/src/common/menu/menu-types.ts +2 -1
- package/src/common/message-service-protocol.ts +2 -1
- package/src/common/objects.ts +7 -6
- package/src/common/preferences/preference-schema.ts +4 -3
- package/src/common/prioritizeable.ts +58 -0
- package/src/common/promise-util.ts +2 -1
- package/src/common/selection.ts +2 -1
- package/src/common/types.ts +57 -137
- package/src/common/uri-command-handler.ts +2 -2
- package/src/common/uri.ts +4 -0
- package/src/common/view-column.ts +33 -0
- package/src/electron-node/token/electron-token-validator.ts +5 -7
- package/src/node/backend-application.ts +10 -6
- package/src/node/i18n/localization-contribution.ts +3 -3
package/src/common/index.ts
CHANGED
|
@@ -14,35 +14,36 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
export
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './reference';
|
|
20
|
-
export * from './event';
|
|
17
|
+
export { environment } from '@theia/application-package/lib/environment';
|
|
18
|
+
export * from './application-error';
|
|
21
19
|
export * from './cancellation';
|
|
22
20
|
export * from './command';
|
|
23
|
-
export * from './
|
|
24
|
-
export * from './selection-service';
|
|
25
|
-
export * from './objects';
|
|
26
|
-
export * from './os';
|
|
27
|
-
export * from './resource';
|
|
21
|
+
export * from './contribution-filter';
|
|
28
22
|
export * from './contribution-provider';
|
|
29
|
-
export * from './
|
|
23
|
+
export * from './disposable';
|
|
24
|
+
export * from './event';
|
|
30
25
|
export * from './logger';
|
|
31
|
-
export * from './
|
|
26
|
+
export * from './lsp-types';
|
|
27
|
+
export * from './menu';
|
|
32
28
|
export * from './message-rpc';
|
|
33
29
|
export * from './message-service';
|
|
34
30
|
export * from './message-service-protocol';
|
|
31
|
+
export * from './messaging';
|
|
32
|
+
export * from './nls';
|
|
33
|
+
export * from './numbers';
|
|
34
|
+
export * from './objects';
|
|
35
|
+
export * from './os';
|
|
36
|
+
export * from './path';
|
|
37
|
+
export * from './performance';
|
|
35
38
|
export * from './progress-service';
|
|
36
39
|
export * from './progress-service-protocol';
|
|
37
40
|
export * from './quick-pick-service';
|
|
41
|
+
export * from './reference';
|
|
42
|
+
export * from './resource';
|
|
38
43
|
export * from './selection';
|
|
44
|
+
export * from './selection-service';
|
|
39
45
|
export * from './strings';
|
|
40
|
-
export * from './
|
|
41
|
-
export
|
|
42
|
-
export * from './
|
|
43
|
-
export * from './nls';
|
|
44
|
-
export * from './numbers';
|
|
45
|
-
export * from './performance';
|
|
46
|
+
export * from './types';
|
|
47
|
+
export { default as URI } from './uri';
|
|
48
|
+
export * from './view-column';
|
|
46
49
|
|
|
47
|
-
import { environment } from '@theia/application-package/lib/environment';
|
|
48
|
-
export { environment };
|
package/src/common/keybinding.ts
CHANGED
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
//
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { isObject } from './types';
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* A Keybinding binds a specific key sequence ({@link Keybinding#keybinding}) to trigger a command ({@link Keybinding#command}). A Keybinding optionally may
|
|
18
21
|
* define a "when clause" ({@link Keybinding#when}) to specify in which context it becomes active.
|
|
@@ -102,7 +105,7 @@ export namespace Keybinding {
|
|
|
102
105
|
|
|
103
106
|
/* Determine whether object is a KeyBinding */
|
|
104
107
|
export function is(arg: unknown): arg is Keybinding {
|
|
105
|
-
return
|
|
108
|
+
return isObject(arg) && 'command' in arg && 'keybinding' in arg;
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -118,6 +121,6 @@ export interface RawKeybinding extends Omit<Keybinding, 'keybinding'> {
|
|
|
118
121
|
|
|
119
122
|
export namespace RawKeybinding {
|
|
120
123
|
export function is(candidate: unknown): candidate is RawKeybinding {
|
|
121
|
-
return
|
|
124
|
+
return isObject(candidate) && 'command' in candidate && 'key' in candidate;
|
|
122
125
|
}
|
|
123
126
|
}
|
package/src/common/keys.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { isOSX } from './os';
|
|
18
|
+
import { isObject } from './types';
|
|
18
19
|
|
|
19
20
|
export type KeySequence = KeyCode[];
|
|
20
21
|
export namespace KeySequence {
|
|
@@ -489,7 +490,7 @@ export namespace SpecialCases {
|
|
|
489
490
|
export namespace Key {
|
|
490
491
|
|
|
491
492
|
export function isKey(arg: unknown): arg is Key {
|
|
492
|
-
return
|
|
493
|
+
return isObject(arg) && 'code' in arg && 'keyCode' in arg;
|
|
493
494
|
}
|
|
494
495
|
|
|
495
496
|
export function getKey(arg: string | number): Key | undefined {
|
package/src/common/lsp-types.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { Range } from 'vscode-languageserver-protocol';
|
|
18
|
+
import { isNumber, isObject, isString, isUndefined } from './types';
|
|
18
19
|
|
|
19
20
|
export interface TextDocumentContentChangeDelta {
|
|
20
21
|
readonly range: Range;
|
|
@@ -24,12 +25,10 @@ export interface TextDocumentContentChangeDelta {
|
|
|
24
25
|
export namespace TextDocumentContentChangeDelta {
|
|
25
26
|
|
|
26
27
|
export function is(arg: unknown): arg is TextDocumentContentChangeDelta {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
&&
|
|
30
|
-
&&
|
|
31
|
-
&& (typeof changeDelta.rangeLength === 'number' || typeof changeDelta.rangeLength === 'undefined')
|
|
32
|
-
&& Range.is(changeDelta.range);
|
|
28
|
+
return isObject<TextDocumentContentChangeDelta>(arg)
|
|
29
|
+
&& isString(arg.text)
|
|
30
|
+
&& (isNumber(arg.rangeLength) || isUndefined(arg.rangeLength))
|
|
31
|
+
&& Range.is(arg.range);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { escapeRegExpCharacters } from '../strings';
|
|
18
18
|
import { UriComponents } from '../uri';
|
|
19
19
|
import { escapeIcons } from './icon-utilities';
|
|
20
|
+
import { isObject, isString } from '../types';
|
|
20
21
|
|
|
21
22
|
export interface MarkdownString {
|
|
22
23
|
readonly value: string;
|
|
@@ -37,8 +38,7 @@ export namespace MarkdownString {
|
|
|
37
38
|
* @returns whether the candidate satisfies the interface of a markdown string
|
|
38
39
|
*/
|
|
39
40
|
export function is(candidate: unknown): candidate is MarkdownString {
|
|
40
|
-
|
|
41
|
-
return typeof maybeMarkdownString === 'object' && !!maybeMarkdownString && typeof maybeMarkdownString.value === 'string';
|
|
41
|
+
return isObject<MarkdownString>(candidate) && isString(candidate.value);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { Disposable } from '../disposable';
|
|
18
|
+
import { isObject } from '../types';
|
|
18
19
|
|
|
19
20
|
export type MenuPath = string[];
|
|
20
21
|
export const MAIN_MENU_BAR: MenuPath = ['menubar'];
|
|
@@ -86,7 +87,7 @@ export interface MenuAction extends MenuNodeRenderingData, Pick<MenuNodeMetadata
|
|
|
86
87
|
export namespace MenuAction {
|
|
87
88
|
/* Determine whether object is a MenuAction */
|
|
88
89
|
export function is(arg: unknown): arg is MenuAction {
|
|
89
|
-
return
|
|
90
|
+
return isObject(arg) && 'commandId' in arg;
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { injectable } from 'inversify';
|
|
18
18
|
import { CancellationToken } from './cancellation';
|
|
19
|
+
import { nls } from './nls';
|
|
19
20
|
|
|
20
21
|
export const messageServicePath = '/services/messageService';
|
|
21
22
|
|
|
@@ -52,7 +53,7 @@ export interface ProgressMessage extends Message {
|
|
|
52
53
|
readonly options?: ProgressMessageOptions;
|
|
53
54
|
}
|
|
54
55
|
export namespace ProgressMessage {
|
|
55
|
-
export const Cancel = 'Cancel';
|
|
56
|
+
export const Cancel = nls.localizeByDefault('Cancel');
|
|
56
57
|
export function isCancelable(message: ProgressMessage): boolean {
|
|
57
58
|
return !!message.options?.cancelable;
|
|
58
59
|
}
|
package/src/common/objects.ts
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
+
import { isObject } from './types';
|
|
18
|
+
|
|
17
19
|
export function deepClone<T>(obj: T): T {
|
|
18
|
-
if (!obj
|
|
20
|
+
if (!isObject(obj)) {
|
|
19
21
|
return obj;
|
|
20
22
|
}
|
|
21
23
|
if (obj instanceof RegExp) {
|
|
@@ -24,9 +26,8 @@ export function deepClone<T>(obj: T): T {
|
|
|
24
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
27
|
const result: any = Array.isArray(obj) ? [] : {};
|
|
26
28
|
Object.keys(obj).forEach((key: string) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (prop && typeof prop === 'object') {
|
|
29
|
+
const prop = obj[key];
|
|
30
|
+
if (isObject(prop)) {
|
|
30
31
|
result[key] = deepClone(prop);
|
|
31
32
|
} else {
|
|
32
33
|
result[key] = prop;
|
|
@@ -36,7 +37,7 @@ export function deepClone<T>(obj: T): T {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export function deepFreeze<T>(obj: T): T {
|
|
39
|
-
if (!obj
|
|
40
|
+
if (!isObject(obj)) {
|
|
40
41
|
return obj;
|
|
41
42
|
}
|
|
42
43
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -47,7 +48,7 @@ export function deepFreeze<T>(obj: T): T {
|
|
|
47
48
|
for (const key in objectToFreeze) {
|
|
48
49
|
if (_hasOwnProperty.call(objectToFreeze, key)) {
|
|
49
50
|
const prop = objectToFreeze[key];
|
|
50
|
-
if (
|
|
51
|
+
if (isObject(prop) && !Object.isFrozen(prop)) {
|
|
51
52
|
stack.push(prop);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { JSONValue } from '@phosphor/coreutils';
|
|
20
20
|
import { IJSONSchema } from '../json-schema';
|
|
21
21
|
import { PreferenceScope } from './preference-scope';
|
|
22
|
+
import { isObject, isString } from '../types';
|
|
22
23
|
|
|
23
24
|
export interface PreferenceSchema {
|
|
24
25
|
[name: string]: any,
|
|
@@ -28,7 +29,7 @@ export interface PreferenceSchema {
|
|
|
28
29
|
}
|
|
29
30
|
export namespace PreferenceSchema {
|
|
30
31
|
export function is(obj: unknown): obj is PreferenceSchema {
|
|
31
|
-
return
|
|
32
|
+
return isObject<PreferenceSchema>(obj) && PreferenceSchemaProperties.is(obj.properties);
|
|
32
33
|
}
|
|
33
34
|
export function getDefaultScope(schema: PreferenceSchema): PreferenceScope {
|
|
34
35
|
let defaultScope: PreferenceScope = PreferenceScope.Workspace;
|
|
@@ -46,7 +47,7 @@ export interface PreferenceSchemaProperties {
|
|
|
46
47
|
}
|
|
47
48
|
export namespace PreferenceSchemaProperties {
|
|
48
49
|
export function is(obj: unknown): obj is PreferenceSchemaProperties {
|
|
49
|
-
return
|
|
50
|
+
return isObject(obj);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -86,7 +87,7 @@ export namespace PreferenceDataProperty {
|
|
|
86
87
|
export function fromPreferenceSchemaProperty(schemaProps: PreferenceSchemaProperty, defaultScope: PreferenceScope = PreferenceScope.Workspace): PreferenceDataProperty {
|
|
87
88
|
if (!schemaProps.scope) {
|
|
88
89
|
schemaProps.scope = defaultScope;
|
|
89
|
-
} else if (
|
|
90
|
+
} else if (isString(schemaProps.scope)) {
|
|
90
91
|
return Object.assign(schemaProps, { scope: PreferenceScope.fromString(schemaProps.scope) || defaultScope });
|
|
91
92
|
}
|
|
92
93
|
return <PreferenceDataProperty>schemaProps;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import type { MaybeArray, MaybePromise } from './types';
|
|
18
|
+
|
|
19
|
+
export interface Prioritizeable<T> {
|
|
20
|
+
readonly priority: number;
|
|
21
|
+
readonly value: T;
|
|
22
|
+
}
|
|
23
|
+
export namespace Prioritizeable {
|
|
24
|
+
export type GetPriority<T> = (value: T) => MaybePromise<number>;
|
|
25
|
+
export type GetPrioritySync<T> = (value: T) => number;
|
|
26
|
+
export async function toPrioritizeable<T>(rawValue: MaybePromise<T>, getPriority: GetPriority<T>): Promise<Prioritizeable<T>>;
|
|
27
|
+
export async function toPrioritizeable<T>(rawValue: MaybePromise<T>[], getPriority: GetPriority<T>): Promise<Prioritizeable<T>[]>;
|
|
28
|
+
export async function toPrioritizeable<T>(rawValue: MaybeArray<MaybePromise<T>>, getPriority: GetPriority<T>): Promise<MaybeArray<Prioritizeable<T>>> {
|
|
29
|
+
if (rawValue instanceof Array) {
|
|
30
|
+
return Promise.all(
|
|
31
|
+
rawValue.map(v => toPrioritizeable(v, getPriority))
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const value = await rawValue;
|
|
35
|
+
const priority = await getPriority(value);
|
|
36
|
+
return { priority, value };
|
|
37
|
+
}
|
|
38
|
+
export function toPrioritizeableSync<T>(rawValue: T[], getPriority: GetPrioritySync<T>): Prioritizeable<T>[] {
|
|
39
|
+
return rawValue.map(v => ({
|
|
40
|
+
value: v,
|
|
41
|
+
priority: getPriority(v)
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
export function prioritizeAllSync<T>(values: T[], getPriority: GetPrioritySync<T>): Prioritizeable<T>[] {
|
|
45
|
+
const prioritizeable = toPrioritizeableSync(values, getPriority);
|
|
46
|
+
return prioritizeable.filter(isValid).sort(compare);
|
|
47
|
+
}
|
|
48
|
+
export async function prioritizeAll<T>(values: MaybePromise<T>[], getPriority: GetPriority<T>): Promise<Prioritizeable<T>[]> {
|
|
49
|
+
const prioritizeable = await toPrioritizeable(values, getPriority);
|
|
50
|
+
return prioritizeable.filter(isValid).sort(compare);
|
|
51
|
+
}
|
|
52
|
+
export function isValid<T>(p: Prioritizeable<T>): boolean {
|
|
53
|
+
return p.priority > 0;
|
|
54
|
+
}
|
|
55
|
+
export function compare<T>(p: Prioritizeable<T>, p2: Prioritizeable<T>): number {
|
|
56
|
+
return p2.priority - p.priority;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { Disposable } from './disposable';
|
|
18
18
|
import { Event } from './event';
|
|
19
19
|
import { CancellationToken, CancellationError, cancelled } from './cancellation';
|
|
20
|
+
import { isFunction, isObject } from './types';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Simple implementation of the deferred pattern.
|
|
@@ -126,5 +127,5 @@ export function waitForEvent<T>(event: Event<T>, ms: number, thisArg?: any, disp
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
export function isThenable<T>(obj: unknown): obj is Promise<T> {
|
|
129
|
-
return
|
|
130
|
+
return isObject<Promise<unknown>>(obj) && isFunction(obj.then);
|
|
130
131
|
}
|
package/src/common/selection.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
+
import { isObject } from './types';
|
|
17
18
|
import URI from './uri';
|
|
18
19
|
|
|
19
20
|
export interface UriSelection {
|
|
@@ -23,7 +24,7 @@ export interface UriSelection {
|
|
|
23
24
|
export namespace UriSelection {
|
|
24
25
|
|
|
25
26
|
export function is(arg: unknown): arg is UriSelection {
|
|
26
|
-
return
|
|
27
|
+
return isObject<UriSelection>(arg) && arg.uri instanceof URI;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export function getUri(selection: unknown): URI | undefined {
|
package/src/common/types.ts
CHANGED
|
@@ -14,161 +14,81 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export type MaybeUndefined<T> = { [P in keyof T]: T[P] | undefined };
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Creates a shallow copy with all ownkeys of the original object that are `null` made `undefined`
|
|
23
|
-
*/
|
|
24
|
-
export function nullToUndefined<T>(nullable: MaybeNull<T>): MaybeUndefined<T> {
|
|
25
|
-
const undefinable = { ...nullable } as MaybeUndefined<T>;
|
|
26
|
-
for (const key in nullable) {
|
|
27
|
-
// eslint-disable-next-line no-null/no-null
|
|
28
|
-
if (nullable[key] === null && Object.prototype.hasOwnProperty.call(nullable, key)) {
|
|
29
|
-
undefinable[key] = undefined;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return undefinable;
|
|
33
|
-
}
|
|
17
|
+
export { ArrayUtils } from './array-utils';
|
|
18
|
+
export { Prioritizeable } from './prioritizeable';
|
|
34
19
|
|
|
35
|
-
export type Deferred<T> = {
|
|
36
|
-
|
|
37
|
-
};
|
|
20
|
+
export type Deferred<T> = { [P in keyof T]: Promise<T[P]> };
|
|
21
|
+
export type MaybeArray<T> = T | T[];
|
|
22
|
+
export type MaybeNull<T> = { [P in keyof T]: T[P] | null };
|
|
23
|
+
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
24
|
+
export type MaybeUndefined<T> = { [P in keyof T]?: T[P] | undefined };
|
|
25
|
+
export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
|
|
38
26
|
export type RecursivePartial<T> = {
|
|
39
|
-
[P in keyof T]?: T[P] extends
|
|
40
|
-
?
|
|
27
|
+
[P in keyof T]?: T[P] extends (infer I)[]
|
|
28
|
+
? RecursivePartial<I>[]
|
|
41
29
|
: RecursivePartial<T[P]>;
|
|
42
30
|
};
|
|
43
|
-
export type MaybeArray<T> = T | T[];
|
|
44
|
-
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
45
31
|
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
readonly value: T;
|
|
49
|
-
}
|
|
50
|
-
export namespace Prioritizeable {
|
|
51
|
-
export type GetPriority<T> = (value: T) => MaybePromise<number>;
|
|
52
|
-
export type GetPrioritySync<T> = (value: T) => number;
|
|
53
|
-
export async function toPrioritizeable<T>(rawValue: MaybePromise<T>, getPriority: GetPriority<T>): Promise<Prioritizeable<T>>;
|
|
54
|
-
export async function toPrioritizeable<T>(rawValue: MaybePromise<T>[], getPriority: GetPriority<T>): Promise<Prioritizeable<T>[]>;
|
|
55
|
-
export async function toPrioritizeable<T>(rawValue: MaybeArray<MaybePromise<T>>, getPriority: GetPriority<T>): Promise<MaybeArray<Prioritizeable<T>>> {
|
|
56
|
-
if (rawValue instanceof Array) {
|
|
57
|
-
return Promise.all(
|
|
58
|
-
rawValue.map(v => toPrioritizeable(v, getPriority))
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
const value = await rawValue;
|
|
62
|
-
const priority = await getPriority(value);
|
|
63
|
-
return { priority, value };
|
|
64
|
-
}
|
|
65
|
-
export function toPrioritizeableSync<T>(rawValue: T[], getPriority: GetPrioritySync<T>): Prioritizeable<T>[] {
|
|
66
|
-
return rawValue.map(v => ({
|
|
67
|
-
value: v,
|
|
68
|
-
priority: getPriority(v)
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
export function prioritizeAllSync<T>(values: T[], getPriority: GetPrioritySync<T>): Prioritizeable<T>[] {
|
|
72
|
-
const prioritizeable = toPrioritizeableSync(values, getPriority);
|
|
73
|
-
return prioritizeable.filter(isValid).sort(compare);
|
|
74
|
-
}
|
|
75
|
-
export async function prioritizeAll<T>(values: MaybePromise<T>[], getPriority: GetPriority<T>): Promise<Prioritizeable<T>[]> {
|
|
76
|
-
const prioritizeable = await toPrioritizeable(values, getPriority);
|
|
77
|
-
return prioritizeable.filter(isValid).sort(compare);
|
|
78
|
-
}
|
|
79
|
-
export function isValid<T>(p: Prioritizeable<T>): boolean {
|
|
80
|
-
return p.priority > 0;
|
|
81
|
-
}
|
|
82
|
-
export function compare<T>(p: Prioritizeable<T>, p2: Prioritizeable<T>): number {
|
|
83
|
-
return p2.priority - p.priority;
|
|
84
|
-
}
|
|
32
|
+
export function isBoolean(value: unknown): value is boolean {
|
|
33
|
+
return value === true || value === false;
|
|
85
34
|
}
|
|
86
35
|
|
|
87
|
-
export
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface Tail<T> extends Array<T> {
|
|
93
|
-
tail(): T;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface Children<T> extends Array<T> {
|
|
97
|
-
children(): Tail<T>
|
|
98
|
-
}
|
|
36
|
+
export function isString(value: unknown): value is string {
|
|
37
|
+
return typeof value === 'string' || value instanceof String;
|
|
38
|
+
}
|
|
99
39
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
};
|
|
40
|
+
export function isNumber(value: unknown): value is number {
|
|
41
|
+
return typeof value === 'number' || value instanceof Number;
|
|
42
|
+
}
|
|
105
43
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
44
|
+
export function isError(value: unknown): value is Error {
|
|
45
|
+
return value instanceof Error;
|
|
46
|
+
}
|
|
110
47
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
48
|
+
export function isErrorLike(value: unknown): value is Error {
|
|
49
|
+
return isObject(value) && isString(value.name) && isString(value.message) && (isUndefined(value.stack) || isString(value.stack));
|
|
50
|
+
}
|
|
115
51
|
|
|
116
|
-
|
|
52
|
+
// eslint-disable-next-line space-before-function-paren
|
|
53
|
+
export function isFunction<T extends (...args: unknown[]) => unknown>(value: unknown): value is T {
|
|
54
|
+
return typeof value === 'function';
|
|
55
|
+
}
|
|
117
56
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
57
|
+
export function isObject<T = Record<string | number | symbol, unknown>>(value: unknown): value is T {
|
|
58
|
+
// eslint-disable-next-line no-null/no-null
|
|
59
|
+
return typeof value === 'object' && value !== null;
|
|
60
|
+
}
|
|
121
61
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
62
|
+
export function isUndefined(value: unknown): value is undefined {
|
|
63
|
+
return typeof value === 'undefined';
|
|
64
|
+
}
|
|
125
65
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @param value value to check.
|
|
68
|
+
* @param every optional predicate ran on every element of the array.
|
|
69
|
+
* @param thisArg value to substitute `this` with when invoking in the predicate.
|
|
70
|
+
* @returns whether or not `value` is an array.
|
|
71
|
+
*/
|
|
72
|
+
export function isArray<T>(value: unknown, every?: (value: unknown) => unknown, thisArg?: unknown): value is T[] {
|
|
73
|
+
return Array.isArray(value) && (!isFunction(every) || value.every(every, thisArg));
|
|
74
|
+
}
|
|
131
75
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
* when we need to perform a binary search over something that isn't actually an
|
|
136
|
-
* array, and converting data to an array would defeat the use of binary search
|
|
137
|
-
* in the first place.
|
|
138
|
-
*
|
|
139
|
-
* @param length The collection length.
|
|
140
|
-
* @param compareToKey A function that takes an index of an element in the
|
|
141
|
-
* collection and returns zero if the value at this index is equal to the
|
|
142
|
-
* search key, a negative number if the value precedes the search key in the
|
|
143
|
-
* sorting order, or a positive number if the search key precedes the value.
|
|
144
|
-
* @return A non-negative index of an element, if found. If not found, the
|
|
145
|
-
* result is -(n+1) (or ~n, using bitwise notation), where n is the index
|
|
146
|
-
* where the key should be inserted to maintain the sorting order.
|
|
147
|
-
*/
|
|
148
|
-
export function binarySearch2(length: number, compareToKey: (index: number) => number): number {
|
|
149
|
-
let low = 0;
|
|
150
|
-
let high = length - 1;
|
|
76
|
+
export function isStringArray(value: unknown): value is string[] {
|
|
77
|
+
return isArray(value, isString);
|
|
78
|
+
}
|
|
151
79
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a shallow copy with all ownkeys of the original object that are `null` made `undefined`
|
|
82
|
+
*/
|
|
83
|
+
export function nullToUndefined<T>(nullable: MaybeNull<T>): MaybeUndefined<T> {
|
|
84
|
+
const undefinable = { ...nullable } as MaybeUndefined<T>;
|
|
85
|
+
for (const key in nullable) {
|
|
86
|
+
// eslint-disable-next-line no-null/no-null
|
|
87
|
+
if (nullable[key] === null && Object.prototype.hasOwnProperty.call(nullable, key)) {
|
|
88
|
+
undefinable[key] = undefined;
|
|
162
89
|
}
|
|
163
|
-
return -(low + 1);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* @returns New array with all falsy values removed. The original array IS NOT modified.
|
|
168
|
-
*/
|
|
169
|
-
export function coalesce<T>(array: ReadonlyArray<T | undefined | null>): T[] {
|
|
170
|
-
return <T[]>array.filter(e => !!e);
|
|
171
90
|
}
|
|
91
|
+
return undefinable;
|
|
172
92
|
}
|
|
173
93
|
|
|
174
94
|
/**
|
|
@@ -20,7 +20,7 @@ import { SelectionService } from '../common/selection-service';
|
|
|
20
20
|
import { UriSelection } from '../common/selection';
|
|
21
21
|
import { CommandHandler } from './command';
|
|
22
22
|
import URI from './uri';
|
|
23
|
-
import { MaybeArray } from './types';
|
|
23
|
+
import { isArray, MaybeArray } from './types';
|
|
24
24
|
|
|
25
25
|
export interface UriCommandHandler<T extends MaybeArray<URI>> extends CommandHandler {
|
|
26
26
|
|
|
@@ -59,7 +59,7 @@ export class UriAwareCommandHandler<T extends MaybeArray<URI>> implements UriCom
|
|
|
59
59
|
protected getUri(...args: any[]): T | undefined {
|
|
60
60
|
const [maybeUriArray] = args;
|
|
61
61
|
const firstArgIsOK = this.isMulti()
|
|
62
|
-
?
|
|
62
|
+
? isArray(maybeUriArray, uri => uri instanceof URI)
|
|
63
63
|
: maybeUriArray instanceof URI;
|
|
64
64
|
|
|
65
65
|
if (firstArgIsOK) {
|
package/src/common/uri.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 STMicroelectronics.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Denotes a column in the editor window.
|
|
19
|
+
* Columns are used to show editors side by side.
|
|
20
|
+
*/
|
|
21
|
+
export enum ViewColumn {
|
|
22
|
+
Active = -1,
|
|
23
|
+
Beside = -2,
|
|
24
|
+
One = 1,
|
|
25
|
+
Two = 2,
|
|
26
|
+
Three = 3,
|
|
27
|
+
Four = 4,
|
|
28
|
+
Five = 5,
|
|
29
|
+
Six = 6,
|
|
30
|
+
Seven = 7,
|
|
31
|
+
Eight = 8,
|
|
32
|
+
Nine = 9
|
|
33
|
+
}
|