@theia/preferences 1.34.1 → 1.34.3

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 (128) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +81 -81
  3. package/lib/browser/abstract-resource-preference-provider.d.ts +46 -46
  4. package/lib/browser/abstract-resource-preference-provider.js +237 -237
  5. package/lib/browser/abstract-resource-preference-provider.spec.d.ts +1 -1
  6. package/lib/browser/abstract-resource-preference-provider.spec.js +83 -83
  7. package/lib/browser/folder-preference-provider.d.ts +20 -20
  8. package/lib/browser/folder-preference-provider.js +59 -59
  9. package/lib/browser/folders-preferences-provider.d.ts +25 -25
  10. package/lib/browser/folders-preferences-provider.js +239 -239
  11. package/lib/browser/index.d.ts +7 -7
  12. package/lib/browser/index.js +34 -34
  13. package/lib/browser/monaco-jsonc-editor.d.ts +9 -9
  14. package/lib/browser/monaco-jsonc-editor.js +80 -80
  15. package/lib/browser/package.spec.js +25 -25
  16. package/lib/browser/preference-bindings.d.ts +4 -4
  17. package/lib/browser/preference-bindings.js +63 -63
  18. package/lib/browser/preference-frontend-module.d.ts +6 -6
  19. package/lib/browser/preference-frontend-module.js +52 -52
  20. package/lib/browser/preference-open-handler.d.ts +9 -9
  21. package/lib/browser/preference-open-handler.js +64 -64
  22. package/lib/browser/preference-transaction-manager.d.ts +98 -98
  23. package/lib/browser/preference-transaction-manager.js +295 -295
  24. package/lib/browser/preference-tree-model.d.ts +59 -59
  25. package/lib/browser/preference-tree-model.js +240 -240
  26. package/lib/browser/preferences-contribution.d.ts +37 -37
  27. package/lib/browser/preferences-contribution.js +279 -279
  28. package/lib/browser/preferences-json-schema-contribution.d.ts +17 -17
  29. package/lib/browser/preferences-json-schema-contribution.js +91 -91
  30. package/lib/browser/preferences-monaco-contribution.d.ts +1 -1
  31. package/lib/browser/preferences-monaco-contribution.js +30 -30
  32. package/lib/browser/section-preference-provider.d.ts +21 -21
  33. package/lib/browser/section-preference-provider.js +96 -96
  34. package/lib/browser/user-configs-preference-provider.d.ts +21 -21
  35. package/lib/browser/user-configs-preference-provider.js +134 -134
  36. package/lib/browser/user-preference-provider.d.ts +13 -13
  37. package/lib/browser/user-preference-provider.js +41 -41
  38. package/lib/browser/util/preference-scope-command-manager.d.ts +17 -17
  39. package/lib/browser/util/preference-scope-command-manager.js +87 -87
  40. package/lib/browser/util/preference-tree-generator.d.ts +30 -30
  41. package/lib/browser/util/preference-tree-generator.js +234 -234
  42. package/lib/browser/util/preference-tree-label-provider.d.ts +11 -11
  43. package/lib/browser/util/preference-tree-label-provider.js +77 -77
  44. package/lib/browser/util/preference-tree-label-provider.spec.d.ts +1 -1
  45. package/lib/browser/util/preference-tree-label-provider.spec.js +87 -87
  46. package/lib/browser/util/preference-types.d.ts +62 -62
  47. package/lib/browser/util/preference-types.js +128 -128
  48. package/lib/browser/views/components/preference-array-input.d.ts +28 -28
  49. package/lib/browser/views/components/preference-array-input.js +180 -180
  50. package/lib/browser/views/components/preference-boolean-input.d.ts +17 -17
  51. package/lib/browser/views/components/preference-boolean-input.js +79 -79
  52. package/lib/browser/views/components/preference-file-input.d.ts +29 -29
  53. package/lib/browser/views/components/preference-file-input.js +110 -110
  54. package/lib/browser/views/components/preference-json-input.d.ts +19 -19
  55. package/lib/browser/views/components/preference-json-input.js +93 -93
  56. package/lib/browser/views/components/preference-node-renderer-creator.d.ts +48 -48
  57. package/lib/browser/views/components/preference-node-renderer-creator.js +132 -132
  58. package/lib/browser/views/components/preference-node-renderer.d.ts +111 -111
  59. package/lib/browser/views/components/preference-node-renderer.js +460 -460
  60. package/lib/browser/views/components/preference-number-input.d.ts +34 -34
  61. package/lib/browser/views/components/preference-number-input.js +142 -142
  62. package/lib/browser/views/components/preference-select-input.d.ts +27 -27
  63. package/lib/browser/views/components/preference-select-input.js +135 -135
  64. package/lib/browser/views/components/preference-string-input.d.ts +17 -17
  65. package/lib/browser/views/components/preference-string-input.js +89 -89
  66. package/lib/browser/views/preference-editor-widget.d.ts +67 -67
  67. package/lib/browser/views/preference-editor-widget.js +376 -376
  68. package/lib/browser/views/preference-scope-tabbar-widget.d.ts +54 -54
  69. package/lib/browser/views/preference-scope-tabbar-widget.js +343 -343
  70. package/lib/browser/views/preference-searchbar-widget.d.ts +53 -53
  71. package/lib/browser/views/preference-searchbar-widget.js +173 -173
  72. package/lib/browser/views/preference-tree-widget.d.ts +17 -17
  73. package/lib/browser/views/preference-tree-widget.js +104 -104
  74. package/lib/browser/views/preference-widget-bindings.d.ts +3 -3
  75. package/lib/browser/views/preference-widget-bindings.js +85 -85
  76. package/lib/browser/views/preference-widget.d.ts +35 -35
  77. package/lib/browser/views/preference-widget.js +123 -123
  78. package/lib/browser/workspace-file-preference-provider.d.ts +23 -23
  79. package/lib/browser/workspace-file-preference-provider.js +110 -110
  80. package/lib/browser/workspace-preference-provider.d.ts +28 -28
  81. package/lib/browser/workspace-preference-provider.js +142 -142
  82. package/package.json +9 -9
  83. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  84. package/src/browser/abstract-resource-preference-provider.ts +228 -228
  85. package/src/browser/folder-preference-provider.ts +58 -58
  86. package/src/browser/folders-preferences-provider.ts +236 -236
  87. package/src/browser/index.ts +23 -23
  88. package/src/browser/monaco-jsonc-editor.ts +67 -67
  89. package/src/browser/package.spec.ts +28 -28
  90. package/src/browser/preference-bindings.ts +65 -65
  91. package/src/browser/preference-frontend-module.ts +57 -57
  92. package/src/browser/preference-open-handler.ts +53 -53
  93. package/src/browser/preference-transaction-manager.ts +283 -283
  94. package/src/browser/preference-tree-model.ts +246 -246
  95. package/src/browser/preferences-contribution.ts +263 -263
  96. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  97. package/src/browser/preferences-monaco-contribution.ts +30 -30
  98. package/src/browser/section-preference-provider.ts +83 -83
  99. package/src/browser/style/index.css +456 -456
  100. package/src/browser/style/preference-array.css +90 -90
  101. package/src/browser/style/preference-context-menu.css +74 -74
  102. package/src/browser/style/preference-file.css +32 -32
  103. package/src/browser/style/preference-object.css +49 -49
  104. package/src/browser/style/search-input.css +66 -66
  105. package/src/browser/user-configs-preference-provider.ts +123 -123
  106. package/src/browser/user-preference-provider.ts +35 -35
  107. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  108. package/src/browser/util/preference-tree-generator.ts +222 -222
  109. package/src/browser/util/preference-tree-label-provider.spec.ts +108 -108
  110. package/src/browser/util/preference-tree-label-provider.ts +64 -64
  111. package/src/browser/util/preference-types.ts +169 -169
  112. package/src/browser/views/components/preference-array-input.ts +174 -174
  113. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  114. package/src/browser/views/components/preference-file-input.ts +104 -104
  115. package/src/browser/views/components/preference-json-input.ts +78 -78
  116. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  117. package/src/browser/views/components/preference-node-renderer.ts +499 -499
  118. package/src/browser/views/components/preference-number-input.ts +147 -147
  119. package/src/browser/views/components/preference-select-input.ts +127 -127
  120. package/src/browser/views/components/preference-string-input.ts +76 -76
  121. package/src/browser/views/preference-editor-widget.ts +361 -361
  122. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  123. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  124. package/src/browser/views/preference-tree-widget.tsx +93 -93
  125. package/src/browser/views/preference-widget-bindings.ts +99 -99
  126. package/src/browser/views/preference-widget.tsx +113 -113
  127. package/src/browser/workspace-file-preference-provider.ts +100 -100
  128. package/src/browser/workspace-preference-provider.ts +134 -134
@@ -1,67 +1,67 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 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 * as jsoncparser from 'jsonc-parser';
18
- import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model';
19
- import { MonacoWorkspace } from '@theia/monaco/lib/browser/monaco-workspace';
20
- import { inject, injectable } from '@theia/core/shared/inversify';
21
- import * as monaco from '@theia/monaco-editor-core';
22
-
23
- @injectable()
24
- export class MonacoJSONCEditor {
25
- @inject(MonacoWorkspace) protected readonly workspace: MonacoWorkspace;
26
-
27
- async setValue(model: MonacoEditorModel, path: jsoncparser.JSONPath, value: unknown, shouldSave = true): Promise<void> {
28
- const edits = this.getEditOperations(model, path, value);
29
- if (edits.length > 0) {
30
- await this.workspace.applyBackgroundEdit(model, edits, shouldSave);
31
- }
32
- }
33
-
34
- getEditOperations(model: MonacoEditorModel, path: jsoncparser.JSONPath, value: unknown): monaco.editor.IIdentifiedSingleEditOperation[] {
35
- const textModel = model.textEditorModel;
36
- const content = model.getText().trim();
37
- // Everything is already undefined - no need for changes.
38
- if (!content && value === undefined) {
39
- return [];
40
- }
41
- // Delete the entire document.
42
- if (!path.length && value === undefined) {
43
- return [{
44
- range: textModel.getFullModelRange(),
45
- text: null, // eslint-disable-line no-null/no-null
46
- forceMoveMarkers: false
47
- }];
48
- }
49
- const { insertSpaces, tabSize, defaultEOL } = textModel.getOptions();
50
- const jsonCOptions = {
51
- formattingOptions: {
52
- insertSpaces,
53
- tabSize,
54
- eol: defaultEOL === monaco.editor.DefaultEndOfLine.LF ? '\n' : '\r\n'
55
- }
56
- };
57
- return jsoncparser.modify(content, path, value, jsonCOptions).map(edit => {
58
- const start = textModel.getPositionAt(edit.offset);
59
- const end = textModel.getPositionAt(edit.offset + edit.length);
60
- return {
61
- range: monaco.Range.fromPositions(start, end),
62
- text: edit.content || null, // eslint-disable-line no-null/no-null
63
- forceMoveMarkers: false
64
- };
65
- });
66
- }
67
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 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 * as jsoncparser from 'jsonc-parser';
18
+ import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model';
19
+ import { MonacoWorkspace } from '@theia/monaco/lib/browser/monaco-workspace';
20
+ import { inject, injectable } from '@theia/core/shared/inversify';
21
+ import * as monaco from '@theia/monaco-editor-core';
22
+
23
+ @injectable()
24
+ export class MonacoJSONCEditor {
25
+ @inject(MonacoWorkspace) protected readonly workspace: MonacoWorkspace;
26
+
27
+ async setValue(model: MonacoEditorModel, path: jsoncparser.JSONPath, value: unknown, shouldSave = true): Promise<void> {
28
+ const edits = this.getEditOperations(model, path, value);
29
+ if (edits.length > 0) {
30
+ await this.workspace.applyBackgroundEdit(model, edits, shouldSave);
31
+ }
32
+ }
33
+
34
+ getEditOperations(model: MonacoEditorModel, path: jsoncparser.JSONPath, value: unknown): monaco.editor.IIdentifiedSingleEditOperation[] {
35
+ const textModel = model.textEditorModel;
36
+ const content = model.getText().trim();
37
+ // Everything is already undefined - no need for changes.
38
+ if (!content && value === undefined) {
39
+ return [];
40
+ }
41
+ // Delete the entire document.
42
+ if (!path.length && value === undefined) {
43
+ return [{
44
+ range: textModel.getFullModelRange(),
45
+ text: null, // eslint-disable-line no-null/no-null
46
+ forceMoveMarkers: false
47
+ }];
48
+ }
49
+ const { insertSpaces, tabSize, defaultEOL } = textModel.getOptions();
50
+ const jsonCOptions = {
51
+ formattingOptions: {
52
+ insertSpaces,
53
+ tabSize,
54
+ eol: defaultEOL === monaco.editor.DefaultEndOfLine.LF ? '\n' : '\r\n'
55
+ }
56
+ };
57
+ return jsoncparser.modify(content, path, value, jsonCOptions).map(edit => {
58
+ const start = textModel.getPositionAt(edit.offset);
59
+ const end = textModel.getPositionAt(edit.offset + edit.length);
60
+ return {
61
+ range: monaco.Range.fromPositions(start, end),
62
+ text: edit.content || null, // eslint-disable-line no-null/no-null
63
+ forceMoveMarkers: false
64
+ };
65
+ });
66
+ }
67
+ }
@@ -1,28 +1,28 @@
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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- /* note: this bogus test file is required so that
18
- we are able to run mocha unit tests on this
19
- package, without having any actual unit tests in it.
20
- This way a coverage report will be generated,
21
- showing 0% coverage, instead of no report.
22
- This file can be removed once we have real unit
23
- tests in place. */
24
-
25
- describe('preferences package', () => {
26
-
27
- it('should support code coverage statistics', () => true);
28
- });
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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /* note: this bogus test file is required so that
18
+ we are able to run mocha unit tests on this
19
+ package, without having any actual unit tests in it.
20
+ This way a coverage report will be generated,
21
+ showing 0% coverage, instead of no report.
22
+ This file can be removed once we have real unit
23
+ tests in place. */
24
+
25
+ describe('preferences package', () => {
26
+
27
+ it('should support code coverage statistics', () => true);
28
+ });
@@ -1,65 +1,65 @@
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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { Container, interfaces } from '@theia/core/shared/inversify';
18
- import { PreferenceProvider, PreferenceScope } from '@theia/core/lib/browser/preferences';
19
- import { UserPreferenceProvider, UserPreferenceProviderFactory } from './user-preference-provider';
20
- import { WorkspacePreferenceProvider } from './workspace-preference-provider';
21
- import { WorkspaceFilePreferenceProvider, WorkspaceFilePreferenceProviderFactory, WorkspaceFilePreferenceProviderOptions } from './workspace-file-preference-provider';
22
- import { FoldersPreferencesProvider } from './folders-preferences-provider';
23
- import { FolderPreferenceProvider, FolderPreferenceProviderFactory, FolderPreferenceProviderFolder } from './folder-preference-provider';
24
- import { UserConfigsPreferenceProvider } from './user-configs-preference-provider';
25
- import { SectionPreferenceProviderUri, SectionPreferenceProviderSection } from './section-preference-provider';
26
-
27
- export function bindWorkspaceFilePreferenceProvider(bind: interfaces.Bind): void {
28
- bind(WorkspaceFilePreferenceProviderFactory).toFactory(ctx => (options: WorkspaceFilePreferenceProviderOptions) => {
29
- const child = new Container({ defaultScope: 'Singleton' });
30
- child.parent = ctx.container;
31
- child.bind(WorkspaceFilePreferenceProvider).toSelf();
32
- child.bind(WorkspaceFilePreferenceProviderOptions).toConstantValue(options);
33
- return child.get(WorkspaceFilePreferenceProvider);
34
- });
35
- }
36
-
37
- export function bindFactory<F, C>(bind: interfaces.Bind,
38
- factoryId: interfaces.ServiceIdentifier<F>,
39
- constructor: interfaces.Newable<C>,
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- ...parameterBindings: interfaces.ServiceIdentifier<any>[]): void {
42
- bind(factoryId).toFactory(ctx =>
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- (...args: any[]) => {
45
- const child = new Container({ defaultScope: 'Singleton' });
46
- child.parent = ctx.container;
47
- for (let i = 0; i < parameterBindings.length; i++) {
48
- child.bind(parameterBindings[i]).toConstantValue(args[i]);
49
- }
50
- child.bind(constructor).to(constructor);
51
- return child.get(constructor);
52
- }
53
- );
54
- }
55
-
56
- export function bindPreferenceProviders(bind: interfaces.Bind, unbind: interfaces.Unbind): void {
57
- unbind(PreferenceProvider);
58
-
59
- bind(PreferenceProvider).to(UserConfigsPreferenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.User);
60
- bind(PreferenceProvider).to(WorkspacePreferenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Workspace);
61
- bind(PreferenceProvider).to(FoldersPreferencesProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Folder);
62
- bindWorkspaceFilePreferenceProvider(bind);
63
- bindFactory(bind, UserPreferenceProviderFactory, UserPreferenceProvider, SectionPreferenceProviderUri, SectionPreferenceProviderSection);
64
- bindFactory(bind, FolderPreferenceProviderFactory, FolderPreferenceProvider, SectionPreferenceProviderUri, SectionPreferenceProviderSection, FolderPreferenceProviderFolder);
65
- }
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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { Container, interfaces } from '@theia/core/shared/inversify';
18
+ import { PreferenceProvider, PreferenceScope } from '@theia/core/lib/browser/preferences';
19
+ import { UserPreferenceProvider, UserPreferenceProviderFactory } from './user-preference-provider';
20
+ import { WorkspacePreferenceProvider } from './workspace-preference-provider';
21
+ import { WorkspaceFilePreferenceProvider, WorkspaceFilePreferenceProviderFactory, WorkspaceFilePreferenceProviderOptions } from './workspace-file-preference-provider';
22
+ import { FoldersPreferencesProvider } from './folders-preferences-provider';
23
+ import { FolderPreferenceProvider, FolderPreferenceProviderFactory, FolderPreferenceProviderFolder } from './folder-preference-provider';
24
+ import { UserConfigsPreferenceProvider } from './user-configs-preference-provider';
25
+ import { SectionPreferenceProviderUri, SectionPreferenceProviderSection } from './section-preference-provider';
26
+
27
+ export function bindWorkspaceFilePreferenceProvider(bind: interfaces.Bind): void {
28
+ bind(WorkspaceFilePreferenceProviderFactory).toFactory(ctx => (options: WorkspaceFilePreferenceProviderOptions) => {
29
+ const child = new Container({ defaultScope: 'Singleton' });
30
+ child.parent = ctx.container;
31
+ child.bind(WorkspaceFilePreferenceProvider).toSelf();
32
+ child.bind(WorkspaceFilePreferenceProviderOptions).toConstantValue(options);
33
+ return child.get(WorkspaceFilePreferenceProvider);
34
+ });
35
+ }
36
+
37
+ export function bindFactory<F, C>(bind: interfaces.Bind,
38
+ factoryId: interfaces.ServiceIdentifier<F>,
39
+ constructor: interfaces.Newable<C>,
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ ...parameterBindings: interfaces.ServiceIdentifier<any>[]): void {
42
+ bind(factoryId).toFactory(ctx =>
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ (...args: any[]) => {
45
+ const child = new Container({ defaultScope: 'Singleton' });
46
+ child.parent = ctx.container;
47
+ for (let i = 0; i < parameterBindings.length; i++) {
48
+ child.bind(parameterBindings[i]).toConstantValue(args[i]);
49
+ }
50
+ child.bind(constructor).to(constructor);
51
+ return child.get(constructor);
52
+ }
53
+ );
54
+ }
55
+
56
+ export function bindPreferenceProviders(bind: interfaces.Bind, unbind: interfaces.Unbind): void {
57
+ unbind(PreferenceProvider);
58
+
59
+ bind(PreferenceProvider).to(UserConfigsPreferenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.User);
60
+ bind(PreferenceProvider).to(WorkspacePreferenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Workspace);
61
+ bind(PreferenceProvider).to(FoldersPreferencesProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Folder);
62
+ bindWorkspaceFilePreferenceProvider(bind);
63
+ bindFactory(bind, UserPreferenceProviderFactory, UserPreferenceProvider, SectionPreferenceProviderUri, SectionPreferenceProviderSection);
64
+ bindFactory(bind, FolderPreferenceProviderFactory, FolderPreferenceProvider, SectionPreferenceProviderUri, SectionPreferenceProviderSection, FolderPreferenceProviderFolder);
65
+ }
@@ -1,57 +1,57 @@
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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import '../../src/browser/style/index.css';
18
- import './preferences-monaco-contribution';
19
- import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
20
- import { bindViewContribution, OpenHandler } from '@theia/core/lib/browser';
21
- import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
22
- import { PreferenceTreeGenerator } from './util/preference-tree-generator';
23
- import { bindPreferenceProviders } from './preference-bindings';
24
- import { bindPreferencesWidgets } from './views/preference-widget-bindings';
25
- import { PreferencesContribution } from './preferences-contribution';
26
- import { PreferenceScopeCommandManager } from './util/preference-scope-command-manager';
27
- import { JsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
28
- import { PreferencesJsonSchemaContribution } from './preferences-json-schema-contribution';
29
- import { MonacoJSONCEditor } from './monaco-jsonc-editor';
30
- import { PreferenceTransaction, PreferenceTransactionFactory, preferenceTransactionFactoryCreator } from './preference-transaction-manager';
31
- import { PreferenceOpenHandler } from './preference-open-handler';
32
-
33
- export function bindPreferences(bind: interfaces.Bind, unbind: interfaces.Unbind): void {
34
- bindPreferenceProviders(bind, unbind);
35
- bindPreferencesWidgets(bind);
36
-
37
- bind(PreferenceTreeGenerator).toSelf().inSingletonScope();
38
-
39
- bindViewContribution(bind, PreferencesContribution);
40
-
41
- bind(PreferenceOpenHandler).toSelf().inSingletonScope();
42
- bind(OpenHandler).toService(PreferenceOpenHandler);
43
-
44
- bind(PreferenceScopeCommandManager).toSelf().inSingletonScope();
45
- bind(TabBarToolbarContribution).toService(PreferencesContribution);
46
-
47
- bind(PreferencesJsonSchemaContribution).toSelf().inSingletonScope();
48
- bind(JsonSchemaContribution).toService(PreferencesJsonSchemaContribution);
49
-
50
- bind(MonacoJSONCEditor).toSelf().inSingletonScope();
51
- bind(PreferenceTransaction).toSelf();
52
- bind(PreferenceTransactionFactory).toFactory(preferenceTransactionFactoryCreator);
53
- }
54
-
55
- export default new ContainerModule((bind, unbind, isBound, rebind) => {
56
- bindPreferences(bind, unbind);
57
- });
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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import '../../src/browser/style/index.css';
18
+ import './preferences-monaco-contribution';
19
+ import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
20
+ import { bindViewContribution, OpenHandler } from '@theia/core/lib/browser';
21
+ import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
22
+ import { PreferenceTreeGenerator } from './util/preference-tree-generator';
23
+ import { bindPreferenceProviders } from './preference-bindings';
24
+ import { bindPreferencesWidgets } from './views/preference-widget-bindings';
25
+ import { PreferencesContribution } from './preferences-contribution';
26
+ import { PreferenceScopeCommandManager } from './util/preference-scope-command-manager';
27
+ import { JsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
28
+ import { PreferencesJsonSchemaContribution } from './preferences-json-schema-contribution';
29
+ import { MonacoJSONCEditor } from './monaco-jsonc-editor';
30
+ import { PreferenceTransaction, PreferenceTransactionFactory, preferenceTransactionFactoryCreator } from './preference-transaction-manager';
31
+ import { PreferenceOpenHandler } from './preference-open-handler';
32
+
33
+ export function bindPreferences(bind: interfaces.Bind, unbind: interfaces.Unbind): void {
34
+ bindPreferenceProviders(bind, unbind);
35
+ bindPreferencesWidgets(bind);
36
+
37
+ bind(PreferenceTreeGenerator).toSelf().inSingletonScope();
38
+
39
+ bindViewContribution(bind, PreferencesContribution);
40
+
41
+ bind(PreferenceOpenHandler).toSelf().inSingletonScope();
42
+ bind(OpenHandler).toService(PreferenceOpenHandler);
43
+
44
+ bind(PreferenceScopeCommandManager).toSelf().inSingletonScope();
45
+ bind(TabBarToolbarContribution).toService(PreferencesContribution);
46
+
47
+ bind(PreferencesJsonSchemaContribution).toSelf().inSingletonScope();
48
+ bind(JsonSchemaContribution).toService(PreferencesJsonSchemaContribution);
49
+
50
+ bind(MonacoJSONCEditor).toSelf().inSingletonScope();
51
+ bind(PreferenceTransaction).toSelf();
52
+ bind(PreferenceTransactionFactory).toFactory(preferenceTransactionFactoryCreator);
53
+ }
54
+
55
+ export default new ContainerModule((bind, unbind, isBound, rebind) => {
56
+ bindPreferences(bind, unbind);
57
+ });
@@ -1,53 +1,53 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2022 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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { animationFrame, OpenHandler } from '@theia/core/lib/browser';
18
- import URI from '@theia/core/lib/common/uri';
19
- import { injectable, inject } from '@theia/core/shared/inversify';
20
- import { PreferencesContribution } from './preferences-contribution';
21
-
22
- @injectable()
23
- export class PreferenceOpenHandler implements OpenHandler {
24
-
25
- readonly id = 'preference';
26
-
27
- @inject(PreferencesContribution)
28
- protected readonly preferencesContribution: PreferencesContribution;
29
-
30
- canHandle(uri: URI): number {
31
- return uri.scheme === this.id ? 500 : -1;
32
- }
33
-
34
- async open(uri: URI): Promise<boolean> {
35
- const preferencesWidget = await this.preferencesContribution.openView();
36
- const selector = `li[data-pref-id="${uri.path.toString()}"]:not([data-node-id^="commonly-used@"])`;
37
- const element = document.querySelector(selector);
38
- if (element instanceof HTMLElement) {
39
- if (element.classList.contains('hidden')) {
40
- // We clear the search term as we have clicked on a hidden preference
41
- await preferencesWidget.setSearchTerm('');
42
- await animationFrame();
43
- }
44
- element.scrollIntoView({
45
- block: 'center'
46
- });
47
- element.focus();
48
- return true;
49
- }
50
- return false;
51
- }
52
-
53
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { animationFrame, OpenHandler } from '@theia/core/lib/browser';
18
+ import URI from '@theia/core/lib/common/uri';
19
+ import { injectable, inject } from '@theia/core/shared/inversify';
20
+ import { PreferencesContribution } from './preferences-contribution';
21
+
22
+ @injectable()
23
+ export class PreferenceOpenHandler implements OpenHandler {
24
+
25
+ readonly id = 'preference';
26
+
27
+ @inject(PreferencesContribution)
28
+ protected readonly preferencesContribution: PreferencesContribution;
29
+
30
+ canHandle(uri: URI): number {
31
+ return uri.scheme === this.id ? 500 : -1;
32
+ }
33
+
34
+ async open(uri: URI): Promise<boolean> {
35
+ const preferencesWidget = await this.preferencesContribution.openView();
36
+ const selector = `li[data-pref-id="${uri.path.toString()}"]:not([data-node-id^="commonly-used@"])`;
37
+ const element = document.querySelector(selector);
38
+ if (element instanceof HTMLElement) {
39
+ if (element.classList.contains('hidden')) {
40
+ // We clear the search term as we have clicked on a hidden preference
41
+ await preferencesWidget.setSearchTerm('');
42
+ await animationFrame();
43
+ }
44
+ element.scrollIntoView({
45
+ block: 'center'
46
+ });
47
+ element.focus();
48
+ return true;
49
+ }
50
+ return false;
51
+ }
52
+
53
+ }