@theia/preferences 1.53.0-next.4 → 1.53.0-next.55

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.
Files changed (74) hide show
  1. package/README.md +81 -81
  2. package/lib/browser/preference-tree-model.d.ts.map +1 -1
  3. package/lib/browser/preference-tree-model.js +5 -2
  4. package/lib/browser/preference-tree-model.js.map +1 -1
  5. package/lib/browser/util/preference-layout.d.ts.map +1 -1
  6. package/lib/browser/util/preference-layout.js +4 -0
  7. package/lib/browser/util/preference-layout.js.map +1 -1
  8. package/lib/browser/util/preference-tree-generator.d.ts +14 -2
  9. package/lib/browser/util/preference-tree-generator.d.ts.map +1 -1
  10. package/lib/browser/util/preference-tree-generator.js +89 -26
  11. package/lib/browser/util/preference-tree-generator.js.map +1 -1
  12. package/lib/browser/util/preference-tree-label-provider.d.ts.map +1 -1
  13. package/lib/browser/util/preference-tree-label-provider.js +4 -11
  14. package/lib/browser/util/preference-tree-label-provider.js.map +1 -1
  15. package/lib/browser/util/preference-types.d.ts +4 -2
  16. package/lib/browser/util/preference-types.d.ts.map +1 -1
  17. package/lib/browser/util/preference-types.js.map +1 -1
  18. package/lib/browser/views/preference-tree-widget.d.ts +2 -0
  19. package/lib/browser/views/preference-tree-widget.d.ts.map +1 -1
  20. package/lib/browser/views/preference-tree-widget.js +10 -1
  21. package/lib/browser/views/preference-tree-widget.js.map +1 -1
  22. package/package.json +9 -9
  23. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  24. package/src/browser/abstract-resource-preference-provider.ts +232 -232
  25. package/src/browser/folder-preference-provider.ts +58 -58
  26. package/src/browser/folders-preferences-provider.ts +244 -244
  27. package/src/browser/index.ts +23 -23
  28. package/src/browser/monaco-jsonc-editor.ts +67 -67
  29. package/src/browser/package.spec.ts +28 -28
  30. package/src/browser/preference-bindings.ts +65 -65
  31. package/src/browser/preference-frontend-contribution.ts +38 -38
  32. package/src/browser/preference-frontend-module.ts +66 -66
  33. package/src/browser/preference-open-handler.ts +53 -53
  34. package/src/browser/preference-transaction-manager.ts +287 -287
  35. package/src/browser/preference-tree-model.ts +260 -257
  36. package/src/browser/preferences-contribution.ts +263 -263
  37. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  38. package/src/browser/preferences-monaco-contribution.ts +27 -27
  39. package/src/browser/section-preference-provider.ts +83 -83
  40. package/src/browser/style/index.css +506 -506
  41. package/src/browser/style/preference-array.css +94 -94
  42. package/src/browser/style/preference-context-menu.css +74 -74
  43. package/src/browser/style/preference-file.css +31 -31
  44. package/src/browser/style/preference-object.css +49 -49
  45. package/src/browser/style/search-input.css +66 -66
  46. package/src/browser/user-configs-preference-provider.ts +127 -127
  47. package/src/browser/user-preference-provider.ts +35 -35
  48. package/src/browser/util/preference-layout.ts +381 -377
  49. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  50. package/src/browser/util/preference-tree-generator.ts +260 -190
  51. package/src/browser/util/preference-tree-label-provider.spec.ts +110 -110
  52. package/src/browser/util/preference-tree-label-provider.ts +72 -78
  53. package/src/browser/util/preference-types.ts +177 -175
  54. package/src/browser/views/components/preference-array-input.ts +174 -174
  55. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  56. package/src/browser/views/components/preference-file-input.ts +104 -104
  57. package/src/browser/views/components/preference-json-input.ts +78 -78
  58. package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
  59. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  60. package/src/browser/views/components/preference-node-renderer.ts +477 -477
  61. package/src/browser/views/components/preference-number-input.ts +147 -147
  62. package/src/browser/views/components/preference-select-input.ts +131 -131
  63. package/src/browser/views/components/preference-string-input.ts +76 -76
  64. package/src/browser/views/preference-editor-widget.ts +349 -349
  65. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  66. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  67. package/src/browser/views/preference-tree-widget.tsx +102 -93
  68. package/src/browser/views/preference-widget-bindings.ts +102 -102
  69. package/src/browser/views/preference-widget.tsx +118 -118
  70. package/src/browser/workspace-file-preference-provider.ts +100 -100
  71. package/src/browser/workspace-preference-provider.ts +134 -134
  72. package/src/common/cli-preferences.ts +22 -22
  73. package/src/node/preference-backend-module.ts +33 -33
  74. package/src/node/preference-cli-contribution.ts +48 -48
@@ -1,134 +1,134 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- /* eslint-disable @typescript-eslint/no-explicit-any */
18
-
19
- import { inject, injectable, postConstruct, named } from '@theia/core/shared/inversify';
20
- import URI from '@theia/core/lib/common/uri';
21
- import { DisposableCollection } from '@theia/core/lib/common/disposable';
22
- import { PreferenceScope, PreferenceProvider } from '@theia/core/lib/browser/preferences';
23
- import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
24
- import { WorkspaceFilePreferenceProviderFactory, WorkspaceFilePreferenceProvider } from './workspace-file-preference-provider';
25
-
26
- @injectable()
27
- export class WorkspacePreferenceProvider extends PreferenceProvider {
28
-
29
- @inject(WorkspaceService)
30
- protected readonly workspaceService: WorkspaceService;
31
-
32
- @inject(WorkspaceFilePreferenceProviderFactory)
33
- protected readonly workspaceFileProviderFactory: WorkspaceFilePreferenceProviderFactory;
34
-
35
- @inject(PreferenceProvider) @named(PreferenceScope.Folder)
36
- protected readonly folderPreferenceProvider: PreferenceProvider;
37
-
38
- protected readonly toDisposeOnEnsureDelegateUpToDate = new DisposableCollection();
39
-
40
- @postConstruct()
41
- protected init(): void {
42
- this.workspaceService.ready.then(() => {
43
- // If there is no workspace after the workspace service is initialized, then no more work is needed for this provider to be ready.
44
- // If there is a workspace, then we wait for the new delegate to be ready before declaring this provider ready.
45
- if (!this.workspaceService.workspace) {
46
- this._ready.resolve();
47
- }
48
- });
49
- this.workspaceService.onWorkspaceLocationChanged(() => this.ensureDelegateUpToDate());
50
- this.workspaceService.onWorkspaceChanged(() => this.ensureDelegateUpToDate());
51
- }
52
-
53
- override getConfigUri(resourceUri: string | undefined = this.ensureResourceUri(), sectionName?: string): URI | undefined {
54
- return this.delegate?.getConfigUri(resourceUri, sectionName);
55
- }
56
-
57
- override getContainingConfigUri(resourceUri: string | undefined = this.ensureResourceUri(), sectionName?: string): URI | undefined {
58
- return this.delegate?.getContainingConfigUri?.(resourceUri, sectionName);
59
- }
60
-
61
- protected _delegate: PreferenceProvider | undefined;
62
- protected get delegate(): PreferenceProvider | undefined {
63
- return this._delegate;
64
- }
65
-
66
- protected ensureDelegateUpToDate(): void {
67
- const delegate = this.createDelegate();
68
- if (this._delegate !== delegate) {
69
- this.toDisposeOnEnsureDelegateUpToDate.dispose();
70
- this.toDispose.push(this.toDisposeOnEnsureDelegateUpToDate);
71
-
72
- this._delegate = delegate;
73
-
74
- if (delegate) {
75
- // If this provider has not yet declared itself ready, it should do so when the new delegate is ready.
76
- delegate.ready.then(() => this._ready.resolve(), () => { });
77
- }
78
-
79
- if (delegate instanceof WorkspaceFilePreferenceProvider) {
80
- this.toDisposeOnEnsureDelegateUpToDate.pushAll([
81
- delegate,
82
- delegate.onDidPreferencesChanged(changes => this.onDidPreferencesChangedEmitter.fire(changes))
83
- ]);
84
- }
85
- }
86
- }
87
-
88
- protected createDelegate(): PreferenceProvider | undefined {
89
- const workspace = this.workspaceService.workspace;
90
- if (!workspace) {
91
- return undefined;
92
- }
93
- if (!this.workspaceService.isMultiRootWorkspaceOpened) {
94
- return this.folderPreferenceProvider;
95
- }
96
- if (this._delegate instanceof WorkspaceFilePreferenceProvider && this._delegate.getConfigUri().isEqual(workspace.resource)) {
97
- return this._delegate;
98
- }
99
- return this.workspaceFileProviderFactory({
100
- workspaceUri: workspace.resource
101
- });
102
- }
103
-
104
- override get<T>(preferenceName: string, resourceUri: string | undefined = this.ensureResourceUri()): T | undefined {
105
- const delegate = this.delegate;
106
- return delegate ? delegate.get<T>(preferenceName, resourceUri) : undefined;
107
- }
108
-
109
- override resolve<T>(preferenceName: string, resourceUri: string | undefined = this.ensureResourceUri()): { value?: T, configUri?: URI } {
110
- const delegate = this.delegate;
111
- return delegate ? delegate.resolve<T>(preferenceName, resourceUri) : {};
112
- }
113
-
114
- getPreferences(resourceUri: string | undefined = this.ensureResourceUri()): { [p: string]: any } {
115
- const delegate = this.delegate;
116
- return delegate ? delegate.getPreferences(resourceUri) : {};
117
- }
118
-
119
- async setPreference(preferenceName: string, value: any, resourceUri: string | undefined = this.ensureResourceUri()): Promise<boolean> {
120
- const delegate = this.delegate;
121
- if (delegate) {
122
- return delegate.setPreference(preferenceName, value, resourceUri);
123
- }
124
- return false;
125
- }
126
-
127
- protected ensureResourceUri(): string | undefined {
128
- if (this.workspaceService.workspace && !this.workspaceService.isMultiRootWorkspaceOpened) {
129
- return this.workspaceService.workspace.resource.toString();
130
- }
131
- return undefined;
132
- }
133
-
134
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /* eslint-disable @typescript-eslint/no-explicit-any */
18
+
19
+ import { inject, injectable, postConstruct, named } from '@theia/core/shared/inversify';
20
+ import URI from '@theia/core/lib/common/uri';
21
+ import { DisposableCollection } from '@theia/core/lib/common/disposable';
22
+ import { PreferenceScope, PreferenceProvider } from '@theia/core/lib/browser/preferences';
23
+ import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
24
+ import { WorkspaceFilePreferenceProviderFactory, WorkspaceFilePreferenceProvider } from './workspace-file-preference-provider';
25
+
26
+ @injectable()
27
+ export class WorkspacePreferenceProvider extends PreferenceProvider {
28
+
29
+ @inject(WorkspaceService)
30
+ protected readonly workspaceService: WorkspaceService;
31
+
32
+ @inject(WorkspaceFilePreferenceProviderFactory)
33
+ protected readonly workspaceFileProviderFactory: WorkspaceFilePreferenceProviderFactory;
34
+
35
+ @inject(PreferenceProvider) @named(PreferenceScope.Folder)
36
+ protected readonly folderPreferenceProvider: PreferenceProvider;
37
+
38
+ protected readonly toDisposeOnEnsureDelegateUpToDate = new DisposableCollection();
39
+
40
+ @postConstruct()
41
+ protected init(): void {
42
+ this.workspaceService.ready.then(() => {
43
+ // If there is no workspace after the workspace service is initialized, then no more work is needed for this provider to be ready.
44
+ // If there is a workspace, then we wait for the new delegate to be ready before declaring this provider ready.
45
+ if (!this.workspaceService.workspace) {
46
+ this._ready.resolve();
47
+ }
48
+ });
49
+ this.workspaceService.onWorkspaceLocationChanged(() => this.ensureDelegateUpToDate());
50
+ this.workspaceService.onWorkspaceChanged(() => this.ensureDelegateUpToDate());
51
+ }
52
+
53
+ override getConfigUri(resourceUri: string | undefined = this.ensureResourceUri(), sectionName?: string): URI | undefined {
54
+ return this.delegate?.getConfigUri(resourceUri, sectionName);
55
+ }
56
+
57
+ override getContainingConfigUri(resourceUri: string | undefined = this.ensureResourceUri(), sectionName?: string): URI | undefined {
58
+ return this.delegate?.getContainingConfigUri?.(resourceUri, sectionName);
59
+ }
60
+
61
+ protected _delegate: PreferenceProvider | undefined;
62
+ protected get delegate(): PreferenceProvider | undefined {
63
+ return this._delegate;
64
+ }
65
+
66
+ protected ensureDelegateUpToDate(): void {
67
+ const delegate = this.createDelegate();
68
+ if (this._delegate !== delegate) {
69
+ this.toDisposeOnEnsureDelegateUpToDate.dispose();
70
+ this.toDispose.push(this.toDisposeOnEnsureDelegateUpToDate);
71
+
72
+ this._delegate = delegate;
73
+
74
+ if (delegate) {
75
+ // If this provider has not yet declared itself ready, it should do so when the new delegate is ready.
76
+ delegate.ready.then(() => this._ready.resolve(), () => { });
77
+ }
78
+
79
+ if (delegate instanceof WorkspaceFilePreferenceProvider) {
80
+ this.toDisposeOnEnsureDelegateUpToDate.pushAll([
81
+ delegate,
82
+ delegate.onDidPreferencesChanged(changes => this.onDidPreferencesChangedEmitter.fire(changes))
83
+ ]);
84
+ }
85
+ }
86
+ }
87
+
88
+ protected createDelegate(): PreferenceProvider | undefined {
89
+ const workspace = this.workspaceService.workspace;
90
+ if (!workspace) {
91
+ return undefined;
92
+ }
93
+ if (!this.workspaceService.isMultiRootWorkspaceOpened) {
94
+ return this.folderPreferenceProvider;
95
+ }
96
+ if (this._delegate instanceof WorkspaceFilePreferenceProvider && this._delegate.getConfigUri().isEqual(workspace.resource)) {
97
+ return this._delegate;
98
+ }
99
+ return this.workspaceFileProviderFactory({
100
+ workspaceUri: workspace.resource
101
+ });
102
+ }
103
+
104
+ override get<T>(preferenceName: string, resourceUri: string | undefined = this.ensureResourceUri()): T | undefined {
105
+ const delegate = this.delegate;
106
+ return delegate ? delegate.get<T>(preferenceName, resourceUri) : undefined;
107
+ }
108
+
109
+ override resolve<T>(preferenceName: string, resourceUri: string | undefined = this.ensureResourceUri()): { value?: T, configUri?: URI } {
110
+ const delegate = this.delegate;
111
+ return delegate ? delegate.resolve<T>(preferenceName, resourceUri) : {};
112
+ }
113
+
114
+ getPreferences(resourceUri: string | undefined = this.ensureResourceUri()): { [p: string]: any } {
115
+ const delegate = this.delegate;
116
+ return delegate ? delegate.getPreferences(resourceUri) : {};
117
+ }
118
+
119
+ async setPreference(preferenceName: string, value: any, resourceUri: string | undefined = this.ensureResourceUri()): Promise<boolean> {
120
+ const delegate = this.delegate;
121
+ if (delegate) {
122
+ return delegate.setPreference(preferenceName, value, resourceUri);
123
+ }
124
+ return false;
125
+ }
126
+
127
+ protected ensureResourceUri(): string | undefined {
128
+ if (this.workspaceService.workspace && !this.workspaceService.isMultiRootWorkspaceOpened) {
129
+ return this.workspaceService.workspace.resource.toString();
130
+ }
131
+ return undefined;
132
+ }
133
+
134
+ }
@@ -1,22 +1,22 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 Typefox 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- export const CliPreferences = Symbol('CliPreferences');
18
- export const CliPreferencesPath = '/services/cli-preferences';
19
-
20
- export interface CliPreferences {
21
- getPreferences(): Promise<[string, unknown][]>;
22
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 Typefox 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ export const CliPreferences = Symbol('CliPreferences');
18
+ export const CliPreferencesPath = '/services/cli-preferences';
19
+
20
+ export interface CliPreferences {
21
+ getPreferences(): Promise<[string, unknown][]>;
22
+ }
@@ -1,33 +1,33 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 Typefox 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { ContainerModule } from '@theia/core/shared/inversify';
18
- import { CliContribution } from '@theia/core/lib/node/cli';
19
- import { PreferenceCliContribution } from './preference-cli-contribution';
20
- import { ConnectionContainerModule } from '@theia/core/lib/node/messaging/connection-container-module';
21
- import { CliPreferences, CliPreferencesPath } from '../common/cli-preferences';
22
-
23
- const preferencesConnectionModule = ConnectionContainerModule.create(({ bind, bindBackendService }) => {
24
- bindBackendService(CliPreferencesPath, CliPreferences);
25
- });
26
-
27
- export default new ContainerModule(bind => {
28
- bind(PreferenceCliContribution).toSelf().inSingletonScope();
29
- bind(CliPreferences).toService(PreferenceCliContribution);
30
- bind(CliContribution).toService(PreferenceCliContribution);
31
-
32
- bind(ConnectionContainerModule).toConstantValue(preferencesConnectionModule);
33
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 Typefox 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule } from '@theia/core/shared/inversify';
18
+ import { CliContribution } from '@theia/core/lib/node/cli';
19
+ import { PreferenceCliContribution } from './preference-cli-contribution';
20
+ import { ConnectionContainerModule } from '@theia/core/lib/node/messaging/connection-container-module';
21
+ import { CliPreferences, CliPreferencesPath } from '../common/cli-preferences';
22
+
23
+ const preferencesConnectionModule = ConnectionContainerModule.create(({ bind, bindBackendService }) => {
24
+ bindBackendService(CliPreferencesPath, CliPreferences);
25
+ });
26
+
27
+ export default new ContainerModule(bind => {
28
+ bind(PreferenceCliContribution).toSelf().inSingletonScope();
29
+ bind(CliPreferences).toService(PreferenceCliContribution);
30
+ bind(CliContribution).toService(PreferenceCliContribution);
31
+
32
+ bind(ConnectionContainerModule).toConstantValue(preferencesConnectionModule);
33
+ });
@@ -1,48 +1,48 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 Typefox 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable } from '@theia/core/shared/inversify';
18
- import { Argv } from '@theia/core/shared/yargs';
19
- import { CliContribution } from '@theia/core/lib/node/cli';
20
- import { CliPreferences } from '../common/cli-preferences';
21
-
22
- @injectable()
23
- export class PreferenceCliContribution implements CliContribution, CliPreferences {
24
-
25
- protected preferences: [string, unknown][] = [];
26
-
27
- configure(conf: Argv<{}>): void {
28
- conf.option('set-preference', {
29
- nargs: 1,
30
- desc: 'sets the specified preference'
31
- });
32
- }
33
-
34
- setArguments(args: Record<string, unknown>): void {
35
- if (args.setPreference) {
36
- const preferences: string[] = args.setPreference instanceof Array ? args.setPreference : [args.setPreference];
37
- for (const preference of preferences) {
38
- const firstEqualIndex = preference.indexOf('=');
39
- this.preferences.push([preference.substring(0, firstEqualIndex), JSON.parse(preference.substring(firstEqualIndex + 1))]);
40
- }
41
- }
42
- }
43
-
44
- async getPreferences(): Promise<[string, unknown][]> {
45
- return this.preferences;
46
- }
47
-
48
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 Typefox 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+ import { Argv } from '@theia/core/shared/yargs';
19
+ import { CliContribution } from '@theia/core/lib/node/cli';
20
+ import { CliPreferences } from '../common/cli-preferences';
21
+
22
+ @injectable()
23
+ export class PreferenceCliContribution implements CliContribution, CliPreferences {
24
+
25
+ protected preferences: [string, unknown][] = [];
26
+
27
+ configure(conf: Argv<{}>): void {
28
+ conf.option('set-preference', {
29
+ nargs: 1,
30
+ desc: 'sets the specified preference'
31
+ });
32
+ }
33
+
34
+ setArguments(args: Record<string, unknown>): void {
35
+ if (args.setPreference) {
36
+ const preferences: string[] = args.setPreference instanceof Array ? args.setPreference : [args.setPreference];
37
+ for (const preference of preferences) {
38
+ const firstEqualIndex = preference.indexOf('=');
39
+ this.preferences.push([preference.substring(0, firstEqualIndex), JSON.parse(preference.substring(firstEqualIndex + 1))]);
40
+ }
41
+ }
42
+ }
43
+
44
+ async getPreferences(): Promise<[string, unknown][]> {
45
+ return this.preferences;
46
+ }
47
+
48
+ }