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

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 (54) hide show
  1. package/README.md +81 -81
  2. package/package.json +8 -8
  3. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  4. package/src/browser/abstract-resource-preference-provider.ts +232 -232
  5. package/src/browser/folder-preference-provider.ts +58 -58
  6. package/src/browser/folders-preferences-provider.ts +244 -244
  7. package/src/browser/index.ts +23 -23
  8. package/src/browser/monaco-jsonc-editor.ts +67 -67
  9. package/src/browser/package.spec.ts +28 -28
  10. package/src/browser/preference-bindings.ts +65 -65
  11. package/src/browser/preference-frontend-contribution.ts +38 -38
  12. package/src/browser/preference-frontend-module.ts +66 -66
  13. package/src/browser/preference-open-handler.ts +53 -53
  14. package/src/browser/preference-transaction-manager.ts +287 -287
  15. package/src/browser/preference-tree-model.ts +260 -260
  16. package/src/browser/preferences-contribution.ts +263 -263
  17. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  18. package/src/browser/preferences-monaco-contribution.ts +27 -27
  19. package/src/browser/section-preference-provider.ts +83 -83
  20. package/src/browser/style/index.css +506 -506
  21. package/src/browser/style/preference-array.css +94 -94
  22. package/src/browser/style/preference-context-menu.css +74 -74
  23. package/src/browser/style/preference-file.css +31 -31
  24. package/src/browser/style/preference-object.css +49 -49
  25. package/src/browser/style/search-input.css +66 -66
  26. package/src/browser/user-configs-preference-provider.ts +127 -127
  27. package/src/browser/user-preference-provider.ts +35 -35
  28. package/src/browser/util/preference-layout.ts +381 -381
  29. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  30. package/src/browser/util/preference-tree-generator.ts +260 -260
  31. package/src/browser/util/preference-tree-label-provider.spec.ts +110 -110
  32. package/src/browser/util/preference-tree-label-provider.ts +72 -72
  33. package/src/browser/util/preference-types.ts +177 -177
  34. package/src/browser/views/components/preference-array-input.ts +174 -174
  35. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  36. package/src/browser/views/components/preference-file-input.ts +104 -104
  37. package/src/browser/views/components/preference-json-input.ts +78 -78
  38. package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
  39. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  40. package/src/browser/views/components/preference-node-renderer.ts +477 -477
  41. package/src/browser/views/components/preference-number-input.ts +147 -147
  42. package/src/browser/views/components/preference-select-input.ts +131 -131
  43. package/src/browser/views/components/preference-string-input.ts +76 -76
  44. package/src/browser/views/preference-editor-widget.ts +349 -349
  45. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  46. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  47. package/src/browser/views/preference-tree-widget.tsx +102 -102
  48. package/src/browser/views/preference-widget-bindings.ts +102 -102
  49. package/src/browser/views/preference-widget.tsx +118 -118
  50. package/src/browser/workspace-file-preference-provider.ts +100 -100
  51. package/src/browser/workspace-preference-provider.ts +134 -134
  52. package/src/common/cli-preferences.ts +22 -22
  53. package/src/node/preference-backend-module.ts +33 -33
  54. package/src/node/preference-cli-contribution.ts +48 -48
@@ -1,86 +1,86 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 { inject, injectable } from '@theia/core/shared/inversify';
18
- import URI from '@theia/core/lib/common/uri';
19
- import { InMemoryResources } from '@theia/core';
20
- import { JsonSchemaRegisterContext, JsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
21
- import { PreferenceSchemaProvider } from '@theia/core/lib/browser/preferences/preference-contribution';
22
- import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
23
- import { PreferenceScope } from '@theia/core/lib/browser';
24
- import { WorkspaceService } from '@theia/workspace/lib/browser';
25
-
26
- const PREFERENCE_URI_PREFIX = 'vscode://schemas/settings/';
27
- const USER_STORAGE_PREFIX = 'user-storage:/';
28
-
29
- @injectable()
30
- export class PreferencesJsonSchemaContribution implements JsonSchemaContribution {
31
- private serializeSchema = (scope: PreferenceScope) => JSON.stringify(this.schemaProvider.getSchema(scope));
32
-
33
- @inject(PreferenceSchemaProvider)
34
- protected readonly schemaProvider: PreferenceSchemaProvider;
35
-
36
- @inject(InMemoryResources)
37
- protected readonly inmemoryResources: InMemoryResources;
38
-
39
- @inject(PreferenceConfigurations)
40
- protected readonly preferenceConfigurations: PreferenceConfigurations;
41
-
42
- @inject(WorkspaceService)
43
- protected readonly workspaceService: WorkspaceService;
44
-
45
- registerSchemas(context: JsonSchemaRegisterContext): void {
46
- this.registerSchema(PreferenceScope.Default, context);
47
- this.registerSchema(PreferenceScope.User, context);
48
- this.registerSchema(PreferenceScope.Workspace, context);
49
- this.registerSchema(PreferenceScope.Folder, context);
50
-
51
- this.workspaceService.updateSchema('settings', { $ref: this.getSchemaURIForScope(PreferenceScope.Workspace).toString() });
52
- this.schemaProvider.onDidPreferenceSchemaChanged(() => this.updateInMemoryResources());
53
- }
54
-
55
- private registerSchema(scope: PreferenceScope, context: JsonSchemaRegisterContext): void {
56
- const scopeStr = PreferenceScope[scope].toLowerCase();
57
- const uri = new URI(PREFERENCE_URI_PREFIX + scopeStr);
58
-
59
- this.inmemoryResources.add(uri, this.serializeSchema(scope));
60
-
61
- context.registerSchema({
62
- fileMatch: this.getFileMatch(scopeStr),
63
- url: uri.toString()
64
- });
65
- }
66
-
67
- private updateInMemoryResources(): void {
68
- this.inmemoryResources.update(this.getSchemaURIForScope(PreferenceScope.Default),
69
- this.serializeSchema(+PreferenceScope.Default));
70
- this.inmemoryResources.update(this.getSchemaURIForScope(PreferenceScope.User),
71
- this.serializeSchema(+PreferenceScope.User));
72
- this.inmemoryResources.update(this.getSchemaURIForScope(PreferenceScope.Workspace),
73
- this.serializeSchema(+PreferenceScope.Workspace));
74
- this.inmemoryResources.update(this.getSchemaURIForScope(PreferenceScope.Folder),
75
- this.serializeSchema(+PreferenceScope.Folder));
76
- }
77
-
78
- private getSchemaURIForScope(scope: PreferenceScope): URI {
79
- return new URI(PREFERENCE_URI_PREFIX + PreferenceScope[scope].toLowerCase());
80
- }
81
-
82
- private getFileMatch(scope: string): string[] {
83
- const baseName = this.preferenceConfigurations.getConfigName() + '.json';
84
- return [baseName, new URI(USER_STORAGE_PREFIX + scope).resolve(baseName).toString()];
85
- }
86
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 { inject, injectable } from '@theia/core/shared/inversify';
18
+ import URI from '@theia/core/lib/common/uri';
19
+ import { InMemoryResources } from '@theia/core';
20
+ import { JsonSchemaRegisterContext, JsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
21
+ import { PreferenceSchemaProvider } from '@theia/core/lib/browser/preferences/preference-contribution';
22
+ import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
23
+ import { PreferenceScope } from '@theia/core/lib/browser';
24
+ import { WorkspaceService } from '@theia/workspace/lib/browser';
25
+
26
+ const PREFERENCE_URI_PREFIX = 'vscode://schemas/settings/';
27
+ const USER_STORAGE_PREFIX = 'user-storage:/';
28
+
29
+ @injectable()
30
+ export class PreferencesJsonSchemaContribution implements JsonSchemaContribution {
31
+ private serializeSchema = (scope: PreferenceScope) => JSON.stringify(this.schemaProvider.getSchema(scope));
32
+
33
+ @inject(PreferenceSchemaProvider)
34
+ protected readonly schemaProvider: PreferenceSchemaProvider;
35
+
36
+ @inject(InMemoryResources)
37
+ protected readonly inmemoryResources: InMemoryResources;
38
+
39
+ @inject(PreferenceConfigurations)
40
+ protected readonly preferenceConfigurations: PreferenceConfigurations;
41
+
42
+ @inject(WorkspaceService)
43
+ protected readonly workspaceService: WorkspaceService;
44
+
45
+ registerSchemas(context: JsonSchemaRegisterContext): void {
46
+ this.registerSchema(PreferenceScope.Default, context);
47
+ this.registerSchema(PreferenceScope.User, context);
48
+ this.registerSchema(PreferenceScope.Workspace, context);
49
+ this.registerSchema(PreferenceScope.Folder, context);
50
+
51
+ this.workspaceService.updateSchema('settings', { $ref: this.getSchemaURIForScope(PreferenceScope.Workspace).toString() });
52
+ this.schemaProvider.onDidPreferenceSchemaChanged(() => this.updateInMemoryResources());
53
+ }
54
+
55
+ private registerSchema(scope: PreferenceScope, context: JsonSchemaRegisterContext): void {
56
+ const scopeStr = PreferenceScope[scope].toLowerCase();
57
+ const uri = new URI(PREFERENCE_URI_PREFIX + scopeStr);
58
+
59
+ this.inmemoryResources.add(uri, this.serializeSchema(scope));
60
+
61
+ context.registerSchema({
62
+ fileMatch: this.getFileMatch(scopeStr),
63
+ url: uri.toString()
64
+ });
65
+ }
66
+
67
+ private updateInMemoryResources(): void {
68
+ this.inmemoryResources.update(this.getSchemaURIForScope(PreferenceScope.Default),
69
+ this.serializeSchema(+PreferenceScope.Default));
70
+ this.inmemoryResources.update(this.getSchemaURIForScope(PreferenceScope.User),
71
+ this.serializeSchema(+PreferenceScope.User));
72
+ this.inmemoryResources.update(this.getSchemaURIForScope(PreferenceScope.Workspace),
73
+ this.serializeSchema(+PreferenceScope.Workspace));
74
+ this.inmemoryResources.update(this.getSchemaURIForScope(PreferenceScope.Folder),
75
+ this.serializeSchema(+PreferenceScope.Folder));
76
+ }
77
+
78
+ private getSchemaURIForScope(scope: PreferenceScope): URI {
79
+ return new URI(PREFERENCE_URI_PREFIX + PreferenceScope[scope].toLowerCase());
80
+ }
81
+
82
+ private getFileMatch(scope: string): string[] {
83
+ const baseName = this.preferenceConfigurations.getConfigName() + '.json';
84
+ return [baseName, new URI(USER_STORAGE_PREFIX + scope).resolve(baseName).toString()];
85
+ }
86
+ }
@@ -1,27 +1,27 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 * as monaco from '@theia/monaco-editor-core';
18
-
19
- monaco.languages.register({
20
- id: 'jsonc',
21
- 'aliases': [
22
- 'JSON with Comments'
23
- ],
24
- 'filenames': [
25
- 'settings.json'
26
- ]
27
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 * as monaco from '@theia/monaco-editor-core';
18
+
19
+ monaco.languages.register({
20
+ id: 'jsonc',
21
+ 'aliases': [
22
+ 'JSON with Comments'
23
+ ],
24
+ 'filenames': [
25
+ 'settings.json'
26
+ ]
27
+ });
@@ -1,83 +1,83 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 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
- import { inject, injectable } from '@theia/core/shared/inversify';
18
- import URI from '@theia/core/lib/common/uri';
19
- import { AbstractResourcePreferenceProvider } from './abstract-resource-preference-provider';
20
- import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
21
- import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
22
-
23
- export const SectionPreferenceProviderUri = Symbol('SectionPreferenceProviderUri');
24
- export const SectionPreferenceProviderSection = Symbol('SectionPreferenceProviderSection');
25
-
26
- /**
27
- * This class encapsulates the logic of using separate files for some workspace configuration like 'launch.json' or 'tasks.json'.
28
- * Anything that is not a contributed section will be in the main config file.
29
- */
30
- @injectable()
31
- export abstract class SectionPreferenceProvider extends AbstractResourcePreferenceProvider {
32
-
33
- @inject(WorkspaceService)
34
- protected readonly workspaceService: WorkspaceService;
35
- @inject(SectionPreferenceProviderUri)
36
- protected readonly uri: URI;
37
- @inject(SectionPreferenceProviderSection)
38
- protected readonly section: string;
39
- @inject(PreferenceConfigurations)
40
- protected readonly preferenceConfigurations: PreferenceConfigurations;
41
-
42
- private _isSection?: boolean;
43
-
44
- private get isSection(): boolean {
45
- if (typeof this._isSection === 'undefined') {
46
- this._isSection = this.preferenceConfigurations.isSectionName(this.section);
47
- }
48
- return this._isSection;
49
- }
50
-
51
- protected getUri(): URI {
52
- return this.uri;
53
- }
54
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- protected override parse(content: string): any {
56
- const prefs = super.parse(content);
57
- if (this.isSection) {
58
- if (prefs === undefined) {
59
- return undefined;
60
- }
61
- const result: { [k: string]: unknown } = {
62
-
63
- };
64
- result[this.section] = { ...prefs };
65
- return result;
66
- } else {
67
- return prefs;
68
- }
69
- }
70
-
71
- protected override getPath(preferenceName: string): string[] | undefined {
72
- if (!this.isSection) {
73
- return super.getPath(preferenceName);
74
- }
75
- if (preferenceName === this.section) {
76
- return [];
77
- }
78
- if (preferenceName.startsWith(`${this.section}.`)) {
79
- return [preferenceName.slice(this.section.length + 1)];
80
- }
81
- return undefined;
82
- }
83
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 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
+ import { inject, injectable } from '@theia/core/shared/inversify';
18
+ import URI from '@theia/core/lib/common/uri';
19
+ import { AbstractResourcePreferenceProvider } from './abstract-resource-preference-provider';
20
+ import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
21
+ import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
22
+
23
+ export const SectionPreferenceProviderUri = Symbol('SectionPreferenceProviderUri');
24
+ export const SectionPreferenceProviderSection = Symbol('SectionPreferenceProviderSection');
25
+
26
+ /**
27
+ * This class encapsulates the logic of using separate files for some workspace configuration like 'launch.json' or 'tasks.json'.
28
+ * Anything that is not a contributed section will be in the main config file.
29
+ */
30
+ @injectable()
31
+ export abstract class SectionPreferenceProvider extends AbstractResourcePreferenceProvider {
32
+
33
+ @inject(WorkspaceService)
34
+ protected readonly workspaceService: WorkspaceService;
35
+ @inject(SectionPreferenceProviderUri)
36
+ protected readonly uri: URI;
37
+ @inject(SectionPreferenceProviderSection)
38
+ protected readonly section: string;
39
+ @inject(PreferenceConfigurations)
40
+ protected readonly preferenceConfigurations: PreferenceConfigurations;
41
+
42
+ private _isSection?: boolean;
43
+
44
+ private get isSection(): boolean {
45
+ if (typeof this._isSection === 'undefined') {
46
+ this._isSection = this.preferenceConfigurations.isSectionName(this.section);
47
+ }
48
+ return this._isSection;
49
+ }
50
+
51
+ protected getUri(): URI {
52
+ return this.uri;
53
+ }
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ protected override parse(content: string): any {
56
+ const prefs = super.parse(content);
57
+ if (this.isSection) {
58
+ if (prefs === undefined) {
59
+ return undefined;
60
+ }
61
+ const result: { [k: string]: unknown } = {
62
+
63
+ };
64
+ result[this.section] = { ...prefs };
65
+ return result;
66
+ } else {
67
+ return prefs;
68
+ }
69
+ }
70
+
71
+ protected override getPath(preferenceName: string): string[] | undefined {
72
+ if (!this.isSection) {
73
+ return super.getPath(preferenceName);
74
+ }
75
+ if (preferenceName === this.section) {
76
+ return [];
77
+ }
78
+ if (preferenceName.startsWith(`${this.section}.`)) {
79
+ return [preferenceName.slice(this.section.length + 1)];
80
+ }
81
+ return undefined;
82
+ }
83
+ }