@theia/preferences 1.65.0-next.6 → 1.65.0
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/lib/browser/folder-preference-provider.d.ts +4 -2
- package/lib/browser/folder-preference-provider.d.ts.map +1 -1
- package/lib/browser/folder-preference-provider.js +9 -4
- package/lib/browser/folder-preference-provider.js.map +1 -1
- package/lib/browser/folders-preferences-provider.d.ts +2 -3
- package/lib/browser/folders-preferences-provider.d.ts.map +1 -1
- package/lib/browser/folders-preferences-provider.js +7 -8
- package/lib/browser/folders-preferences-provider.js.map +1 -1
- package/lib/browser/frontend-preference-storage.d.ts +20 -0
- package/lib/browser/frontend-preference-storage.d.ts.map +1 -0
- package/lib/browser/frontend-preference-storage.js +63 -0
- package/lib/browser/frontend-preference-storage.js.map +1 -0
- package/lib/browser/index.d.ts +0 -3
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -3
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/monaco-jsonc-editor.js +2 -2
- package/lib/browser/monaco-jsonc-editor.js.map +1 -1
- package/lib/browser/preference-bindings.d.ts +0 -1
- package/lib/browser/preference-bindings.d.ts.map +1 -1
- package/lib/browser/preference-bindings.js +13 -28
- package/lib/browser/preference-bindings.js.map +1 -1
- package/lib/browser/preference-frontend-contribution.d.ts +1 -1
- package/lib/browser/preference-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/preference-frontend-contribution.js +3 -3
- package/lib/browser/preference-frontend-contribution.js.map +1 -1
- package/lib/browser/preference-frontend-module.d.ts.map +1 -1
- package/lib/browser/preference-frontend-module.js +4 -0
- package/lib/browser/preference-frontend-module.js.map +1 -1
- package/lib/browser/preference-transaction-manager.d.ts +4 -7
- package/lib/browser/preference-transaction-manager.d.ts.map +1 -1
- package/lib/browser/preference-transaction-manager.js +8 -11
- package/lib/browser/preference-transaction-manager.js.map +1 -1
- package/lib/browser/preference-tree-model.d.ts +4 -6
- package/lib/browser/preference-tree-model.d.ts.map +1 -1
- package/lib/browser/preference-tree-model.js +4 -4
- package/lib/browser/preference-tree-model.js.map +1 -1
- package/lib/browser/preferences-contribution.d.ts +2 -5
- package/lib/browser/preferences-contribution.d.ts.map +1 -1
- package/lib/browser/preferences-contribution.js +7 -17
- package/lib/browser/preferences-contribution.js.map +1 -1
- package/lib/browser/preferences-json-schema-contribution.d.ts +2 -6
- package/lib/browser/preferences-json-schema-contribution.d.ts.map +1 -1
- package/lib/browser/preferences-json-schema-contribution.js +30 -35
- package/lib/browser/preferences-json-schema-contribution.js.map +1 -1
- package/lib/browser/util/preference-scope-command-manager.d.ts.map +1 -1
- package/lib/browser/util/preference-scope-command-manager.js +1 -1
- package/lib/browser/util/preference-scope-command-manager.js.map +1 -1
- package/lib/browser/util/preference-tree-generator.d.ts +3 -4
- package/lib/browser/util/preference-tree-generator.d.ts.map +1 -1
- package/lib/browser/util/preference-tree-generator.js +10 -14
- package/lib/browser/util/preference-tree-generator.js.map +1 -1
- package/lib/browser/util/preference-types.d.ts +2 -2
- package/lib/browser/util/preference-types.d.ts.map +1 -1
- package/lib/browser/util/preference-types.js +4 -4
- package/lib/browser/util/preference-types.js.map +1 -1
- package/lib/browser/views/components/preference-node-renderer.d.ts +2 -2
- package/lib/browser/views/components/preference-node-renderer.d.ts.map +1 -1
- package/lib/browser/views/components/preference-node-renderer.js +7 -7
- package/lib/browser/views/components/preference-node-renderer.js.map +1 -1
- package/lib/browser/views/components/preference-select-input.d.ts.map +1 -1
- package/lib/browser/views/components/preference-select-input.js +6 -9
- package/lib/browser/views/components/preference-select-input.js.map +1 -1
- package/lib/browser/views/preference-editor-widget.d.ts +3 -2
- package/lib/browser/views/preference-editor-widget.d.ts.map +1 -1
- package/lib/browser/views/preference-editor-widget.js +3 -3
- package/lib/browser/views/preference-editor-widget.js.map +1 -1
- package/lib/browser/views/preference-scope-tabbar-widget.d.ts +2 -2
- package/lib/browser/views/preference-scope-tabbar-widget.d.ts.map +1 -1
- package/lib/browser/views/preference-scope-tabbar-widget.js +7 -7
- package/lib/browser/views/preference-scope-tabbar-widget.js.map +1 -1
- package/lib/browser/views/preference-widget.d.ts +2 -1
- package/lib/browser/views/preference-widget.d.ts.map +1 -1
- package/lib/browser/views/preference-widget.js.map +1 -1
- package/lib/browser/workspace-file-preference-provider.d.ts +2 -2
- package/lib/browser/workspace-file-preference-provider.d.ts.map +1 -1
- package/lib/browser/workspace-file-preference-provider.js +2 -2
- package/lib/browser/workspace-file-preference-provider.js.map +1 -1
- package/lib/browser/workspace-preference-provider.d.ts +13 -6
- package/lib/browser/workspace-preference-provider.d.ts.map +1 -1
- package/lib/browser/workspace-preference-provider.js +27 -17
- package/lib/browser/workspace-preference-provider.js.map +1 -1
- package/lib/common/abstract-resource-preference-provider.d.ts +69 -0
- package/lib/common/abstract-resource-preference-provider.d.ts.map +1 -0
- package/lib/{browser → common}/abstract-resource-preference-provider.js +36 -62
- package/lib/common/abstract-resource-preference-provider.js.map +1 -0
- package/lib/common/abstract-resource-preference-provider.spec.d.ts.map +1 -0
- package/lib/{browser → common}/abstract-resource-preference-provider.spec.js +17 -17
- package/lib/common/abstract-resource-preference-provider.spec.js.map +1 -0
- package/lib/common/jsonc-editor.d.ts +10 -0
- package/lib/common/jsonc-editor.d.ts.map +1 -0
- package/lib/common/jsonc-editor.js +68 -0
- package/lib/common/jsonc-editor.js.map +1 -0
- package/lib/{browser → common}/section-preference-provider.d.ts +1 -3
- package/lib/common/section-preference-provider.d.ts.map +1 -0
- package/lib/{browser → common}/section-preference-provider.js +3 -8
- package/lib/common/section-preference-provider.js.map +1 -0
- package/lib/{browser → common}/user-configs-preference-provider.d.ts +6 -5
- package/lib/common/user-configs-preference-provider.d.ts.map +1 -0
- package/lib/{browser → common}/user-configs-preference-provider.js +17 -13
- package/lib/common/user-configs-preference-provider.js.map +1 -0
- package/lib/{browser → common}/user-preference-provider.d.ts +1 -1
- package/lib/common/user-preference-provider.d.ts.map +1 -0
- package/lib/{browser → common}/user-preference-provider.js +2 -2
- package/lib/common/user-preference-provider.js.map +1 -0
- package/lib/node/backend-preference-storage.d.ts +34 -0
- package/lib/node/backend-preference-storage.d.ts.map +1 -0
- package/lib/node/backend-preference-storage.js +100 -0
- package/lib/node/backend-preference-storage.js.map +1 -0
- package/lib/node/preference-backend-module.d.ts.map +1 -1
- package/lib/node/preference-backend-module.js +9 -0
- package/lib/node/preference-backend-module.js.map +1 -1
- package/lib/node/preference-bindings.d.ts +3 -0
- package/lib/node/preference-bindings.d.ts.map +1 -0
- package/lib/node/preference-bindings.js +33 -0
- package/lib/node/preference-bindings.js.map +1 -0
- package/package.json +9 -9
- package/src/browser/folder-preference-provider.ts +5 -2
- package/src/browser/folders-preferences-provider.ts +4 -5
- package/src/browser/frontend-preference-storage.ts +72 -0
- package/src/browser/index.ts +0 -3
- package/src/browser/monaco-jsonc-editor.ts +2 -2
- package/src/browser/preference-bindings.ts +7 -26
- package/src/browser/preference-frontend-contribution.ts +1 -1
- package/src/browser/preference-frontend-module.ts +10 -0
- package/src/browser/preference-transaction-manager.ts +8 -13
- package/src/browser/preference-tree-model.ts +4 -7
- package/src/browser/preferences-contribution.ts +2 -9
- package/src/browser/preferences-json-schema-contribution.ts +20 -23
- package/src/browser/util/preference-scope-command-manager.ts +2 -2
- package/src/browser/util/preference-tree-generator.ts +8 -12
- package/src/browser/util/preference-types.ts +2 -5
- package/src/browser/views/components/preference-node-renderer.ts +4 -5
- package/src/browser/views/components/preference-select-input.ts +6 -9
- package/src/browser/views/preference-editor-widget.ts +2 -5
- package/src/browser/views/preference-scope-tabbar-widget.tsx +2 -2
- package/src/browser/views/preference-widget.tsx +2 -1
- package/src/browser/workspace-file-preference-provider.ts +2 -2
- package/src/browser/workspace-preference-provider.ts +37 -19
- package/src/{browser → common}/abstract-resource-preference-provider.spec.ts +19 -20
- package/src/{browser → common}/abstract-resource-preference-provider.ts +69 -57
- package/src/common/jsonc-editor.ts +65 -0
- package/src/{browser → common}/section-preference-provider.ts +1 -5
- package/src/{browser → common}/user-configs-preference-provider.ts +14 -10
- package/src/{browser → common}/user-preference-provider.ts +1 -1
- package/src/node/backend-preference-storage.ts +117 -0
- package/src/node/preference-backend-module.ts +16 -0
- package/src/node/preference-bindings.ts +31 -0
- package/lib/browser/abstract-resource-preference-provider.d.ts +0 -48
- package/lib/browser/abstract-resource-preference-provider.d.ts.map +0 -1
- package/lib/browser/abstract-resource-preference-provider.js.map +0 -1
- package/lib/browser/abstract-resource-preference-provider.spec.d.ts.map +0 -1
- package/lib/browser/abstract-resource-preference-provider.spec.js.map +0 -1
- package/lib/browser/section-preference-provider.d.ts.map +0 -1
- package/lib/browser/section-preference-provider.js.map +0 -1
- package/lib/browser/user-configs-preference-provider.d.ts.map +0 -1
- package/lib/browser/user-configs-preference-provider.js.map +0 -1
- package/lib/browser/user-preference-provider.d.ts.map +0 -1
- package/lib/browser/user-preference-provider.js.map +0 -1
- /package/lib/{browser → common}/abstract-resource-preference-provider.spec.d.ts +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 STMicroelectronics and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.bindPreferenceProviders = void 0;
|
|
19
|
+
const user_preference_provider_1 = require("../common/user-preference-provider");
|
|
20
|
+
const section_preference_provider_1 = require("../common/section-preference-provider");
|
|
21
|
+
const core_1 = require("@theia/core");
|
|
22
|
+
const user_configs_preference_provider_1 = require("../common/user-configs-preference-provider");
|
|
23
|
+
const env_variables_1 = require("@theia/core/lib/common/env-variables");
|
|
24
|
+
function bindPreferenceProviders(bind) {
|
|
25
|
+
bind(user_configs_preference_provider_1.UserStorageLocationProvider).toDynamicValue(context => async () => {
|
|
26
|
+
const env = context.container.get(env_variables_1.EnvVariablesServer);
|
|
27
|
+
return new core_1.URI(await env.getConfigDirUri());
|
|
28
|
+
});
|
|
29
|
+
bind(core_1.PreferenceProvider).to(user_configs_preference_provider_1.UserConfigsPreferenceProvider).inSingletonScope().whenTargetNamed(core_1.PreferenceScope.User);
|
|
30
|
+
(0, core_1.bindFactory)(bind, user_preference_provider_1.UserPreferenceProviderFactory, user_preference_provider_1.UserPreferenceProvider, section_preference_provider_1.SectionPreferenceProviderUri, section_preference_provider_1.SectionPreferenceProviderSection);
|
|
31
|
+
}
|
|
32
|
+
exports.bindPreferenceProviders = bindPreferenceProviders;
|
|
33
|
+
//# sourceMappingURL=preference-bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preference-bindings.js","sourceRoot":"","sources":["../../src/node/preference-bindings.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAGhF,iFAA2G;AAC3G,uFAAuH;AACvH,sCAAoF;AACpF,iGAAwH;AACxH,wEAA0E;AAE1E,SAAgB,uBAAuB,CAAC,IAAqB;IACzD,IAAI,CAAC,8DAA2B,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE;QACnE,MAAM,GAAG,GAAuB,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,kCAAkB,CAAC,CAAC;QAC1E,OAAO,IAAI,UAAG,CAAC,MAAM,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,yBAAkB,CAAC,CAAC,EAAE,CAAC,gEAA6B,CAAC,CAAC,gBAAgB,EAAE,CAAC,eAAe,CAAC,sBAAe,CAAC,IAAI,CAAC,CAAC;IACpH,IAAA,kBAAW,EAAC,IAAI,EAAE,wDAA6B,EAAE,iDAAsB,EAAE,0DAA4B,EAAE,8DAAgC,CAAC,CAAC;AAC7I,CAAC;AAPD,0DAOC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/preferences",
|
|
3
|
-
"version": "1.65.0
|
|
3
|
+
"version": "1.65.0",
|
|
4
4
|
"description": "Theia - Preferences Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.65.0
|
|
7
|
-
"@theia/editor": "1.65.0
|
|
8
|
-
"@theia/filesystem": "1.65.0
|
|
9
|
-
"@theia/monaco": "1.65.0
|
|
6
|
+
"@theia/core": "1.65.0",
|
|
7
|
+
"@theia/editor": "1.65.0",
|
|
8
|
+
"@theia/filesystem": "1.65.0",
|
|
9
|
+
"@theia/monaco": "1.65.0",
|
|
10
10
|
"@theia/monaco-editor-core": "1.96.302",
|
|
11
|
-
"@theia/userstorage": "1.65.0
|
|
12
|
-
"@theia/workspace": "1.65.0
|
|
11
|
+
"@theia/userstorage": "1.65.0",
|
|
12
|
+
"@theia/workspace": "1.65.0",
|
|
13
13
|
"async-mutex": "^0.3.1",
|
|
14
14
|
"fast-deep-equal": "^3.1.3",
|
|
15
15
|
"jsonc-parser": "^2.2.0",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"watch": "theiaext watch"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@theia/ext-scripts": "1.
|
|
53
|
+
"@theia/ext-scripts": "1.65.0"
|
|
54
54
|
},
|
|
55
55
|
"nyc": {
|
|
56
56
|
"extends": "../../configs/nyc.json"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "500dfc80cee94fd2a623b5fb59b22d5a575247c2"
|
|
59
59
|
}
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
|
|
17
17
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
18
|
import URI from '@theia/core/lib/common/uri';
|
|
19
|
-
import { PreferenceScope } from '@theia/core/lib/browser';
|
|
20
19
|
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
21
|
-
import { SectionPreferenceProvider } from '
|
|
20
|
+
import { SectionPreferenceProvider } from '../common/section-preference-provider';
|
|
21
|
+
import { PreferenceScope } from '@theia/core';
|
|
22
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
22
23
|
|
|
23
24
|
export const FolderPreferenceProviderFactory = Symbol('FolderPreferenceProviderFactory');
|
|
24
25
|
export interface FolderPreferenceProviderFactory {
|
|
@@ -33,6 +34,8 @@ export interface FolderPreferenceProviderOptions {
|
|
|
33
34
|
|
|
34
35
|
@injectable()
|
|
35
36
|
export class FolderPreferenceProvider extends SectionPreferenceProvider {
|
|
37
|
+
@inject(WorkspaceService)
|
|
38
|
+
protected readonly workspaceService: WorkspaceService;
|
|
36
39
|
|
|
37
40
|
@inject(FolderPreferenceProviderFolder) protected readonly folder: FileStat;
|
|
38
41
|
|
|
@@ -18,14 +18,13 @@
|
|
|
18
18
|
|
|
19
19
|
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
20
20
|
import URI from '@theia/core/lib/common/uri';
|
|
21
|
-
import { PreferenceProvider, PreferenceResolveResult, PreferenceScope } from '@theia/core/lib/browser/preferences';
|
|
22
21
|
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
|
23
|
-
import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
|
|
24
22
|
import { FolderPreferenceProvider, FolderPreferenceProviderFactory } from './folder-preference-provider';
|
|
25
23
|
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
24
|
+
import { PreferenceProviderImpl, PreferenceConfigurations, PreferenceResolveResult, PreferenceScope, PreferenceUtils } from '@theia/core';
|
|
26
25
|
|
|
27
26
|
@injectable()
|
|
28
|
-
export class FoldersPreferencesProvider extends
|
|
27
|
+
export class FoldersPreferencesProvider extends PreferenceProviderImpl {
|
|
29
28
|
|
|
30
29
|
@inject(WorkspaceService)
|
|
31
30
|
protected readonly workspaceService: WorkspaceService;
|
|
@@ -113,7 +112,7 @@ export class FoldersPreferencesProvider extends PreferenceProvider {
|
|
|
113
112
|
const { value, configUri } = provider.resolve<T>(preferenceName, resourceUri);
|
|
114
113
|
if (configUri && value !== undefined) {
|
|
115
114
|
result.configUri = configUri;
|
|
116
|
-
result.value =
|
|
115
|
+
result.value = PreferenceUtils.merge(result.value as any, value as any) as any;
|
|
117
116
|
break;
|
|
118
117
|
}
|
|
119
118
|
}
|
|
@@ -128,7 +127,7 @@ export class FoldersPreferencesProvider extends PreferenceProvider {
|
|
|
128
127
|
for (const provider of group) {
|
|
129
128
|
if (provider.getConfigUri(resourceUri)) {
|
|
130
129
|
const preferences = provider.getPreferences();
|
|
131
|
-
result =
|
|
130
|
+
result = PreferenceUtils.merge(result, preferences) as any;
|
|
132
131
|
break;
|
|
133
132
|
}
|
|
134
133
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 STMicroelectronics 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 { ListenerList, DisposableCollection, URI, PreferenceScope, Listener } from '@theia/core';
|
|
18
|
+
import { JSONValue } from '@theia/core/shared/@lumino/coreutils';
|
|
19
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
20
|
+
import { FileContentStatus, PreferenceStorage } from '../common/abstract-resource-preference-provider';
|
|
21
|
+
import { PreferenceTransaction, PreferenceTransactionFactory } from './preference-transaction-manager';
|
|
22
|
+
|
|
23
|
+
export class FrontendPreferenceStorage implements PreferenceStorage {
|
|
24
|
+
|
|
25
|
+
protected readonly onDidChangeFileContentListeners = new ListenerList<FileContentStatus, Promise<boolean>>();
|
|
26
|
+
protected transaction: PreferenceTransaction | undefined;
|
|
27
|
+
|
|
28
|
+
protected readonly toDispose = new DisposableCollection();
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
protected readonly transactionFactory: PreferenceTransactionFactory,
|
|
32
|
+
protected readonly fileService: FileService,
|
|
33
|
+
protected readonly uri: URI,
|
|
34
|
+
protected readonly scope: PreferenceScope
|
|
35
|
+
) {
|
|
36
|
+
|
|
37
|
+
this.fileService.watch(uri);
|
|
38
|
+
this.fileService.onDidFilesChange(e => {
|
|
39
|
+
if (e.contains(uri)) {
|
|
40
|
+
this.read().then(content => this.onDidChangeFileContentListeners.invoke({ content, fileOK: true }, () => { }))
|
|
41
|
+
.catch(() => this.onDidChangeFileContentListeners.invoke({ content: '', fileOK: false }, () => { }));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
dispose(): void {
|
|
47
|
+
this.toDispose.dispose();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
writeValue(key: string, path: string[], value: JSONValue): Promise<boolean> {
|
|
51
|
+
if (!this.transaction?.open) {
|
|
52
|
+
const current = this.transaction;
|
|
53
|
+
this.transaction = this.transactionFactory({
|
|
54
|
+
getScope: () => this.scope,
|
|
55
|
+
getConfigUri: () => this.uri
|
|
56
|
+
}, current?.result);
|
|
57
|
+
this.transaction.onWillConclude(async status => {
|
|
58
|
+
if (status) {
|
|
59
|
+
const content = await this.read();
|
|
60
|
+
await Listener.await({ content, fileOK: true }, this.onDidChangeFileContentListeners);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
this.toDispose.push(this.transaction);
|
|
64
|
+
}
|
|
65
|
+
return this.transaction.enqueueAction(key, path, value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onDidChangeFileContent: Listener.Registration<FileContentStatus, Promise<boolean>> = this.onDidChangeFileContentListeners.registration;
|
|
69
|
+
async read(): Promise<string> {
|
|
70
|
+
return (await this.fileService.read(this.uri)).value;
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/browser/index.ts
CHANGED
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
export * from '@theia/core/lib/browser/preferences';
|
|
18
|
-
export * from './abstract-resource-preference-provider';
|
|
19
|
-
export * from './user-preference-provider';
|
|
20
18
|
export * from './workspace-preference-provider';
|
|
21
19
|
export * from './folders-preferences-provider';
|
|
22
20
|
export * from './folder-preference-provider';
|
|
23
|
-
export * from './user-configs-preference-provider';
|
|
@@ -33,9 +33,9 @@ export class MonacoJSONCEditor {
|
|
|
33
33
|
|
|
34
34
|
getEditOperations(model: MonacoEditorModel, path: jsoncparser.JSONPath, value: unknown): monaco.editor.IIdentifiedSingleEditOperation[] {
|
|
35
35
|
const textModel = model.textEditorModel;
|
|
36
|
-
const content = model.getText()
|
|
36
|
+
const content = model.getText();
|
|
37
37
|
// Everything is already undefined - no need for changes.
|
|
38
|
-
if (!content && value === undefined) {
|
|
38
|
+
if (!content.trim() && value === undefined) {
|
|
39
39
|
return [];
|
|
40
40
|
}
|
|
41
41
|
// Delete the entire document.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// *****************************************************************************
|
|
2
|
-
// Copyright (C)
|
|
2
|
+
// Copyright (C) 2025 STMicroelectronics and others.
|
|
3
3
|
//
|
|
4
4
|
// This program and the accompanying materials are made available under the
|
|
5
5
|
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { Container, interfaces } from '@theia/core/shared/inversify';
|
|
18
|
-
import {
|
|
19
|
-
import { UserPreferenceProvider, UserPreferenceProviderFactory } from './user-preference-provider';
|
|
18
|
+
import { UserPreferenceProvider, UserPreferenceProviderFactory } from '../common/user-preference-provider';
|
|
20
19
|
import { WorkspacePreferenceProvider } from './workspace-preference-provider';
|
|
21
20
|
import { WorkspaceFilePreferenceProvider, WorkspaceFilePreferenceProviderFactory, WorkspaceFilePreferenceProviderOptions } from './workspace-file-preference-provider';
|
|
22
21
|
import { FoldersPreferencesProvider } from './folders-preferences-provider';
|
|
23
22
|
import { FolderPreferenceProvider, FolderPreferenceProviderFactory, FolderPreferenceProviderFolder } from './folder-preference-provider';
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
23
|
+
import { SectionPreferenceProviderUri, SectionPreferenceProviderSection } from '../common/section-preference-provider';
|
|
24
|
+
import { bindFactory, PreferenceProvider, PreferenceScope } from '@theia/core';
|
|
25
|
+
import { UserStorageUri } from '@theia/userstorage/lib/browser';
|
|
26
|
+
import { UserConfigsPreferenceProvider, UserStorageLocationProvider } from '../common/user-configs-preference-provider';
|
|
26
27
|
|
|
27
28
|
export function bindWorkspaceFilePreferenceProvider(bind: interfaces.Bind): void {
|
|
28
29
|
bind(WorkspaceFilePreferenceProviderFactory).toFactory(ctx => (options: WorkspaceFilePreferenceProviderOptions) => {
|
|
@@ -34,32 +35,12 @@ export function bindWorkspaceFilePreferenceProvider(bind: interfaces.Bind): void
|
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
|
|
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
38
|
export function bindPreferenceProviders(bind: interfaces.Bind, unbind: interfaces.Unbind): void {
|
|
57
|
-
unbind(PreferenceProvider);
|
|
58
|
-
|
|
59
39
|
bind(PreferenceProvider).to(UserConfigsPreferenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.User);
|
|
60
40
|
bind(PreferenceProvider).to(WorkspacePreferenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Workspace);
|
|
61
41
|
bind(PreferenceProvider).to(FoldersPreferencesProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Folder);
|
|
62
42
|
bindWorkspaceFilePreferenceProvider(bind);
|
|
43
|
+
bind(UserStorageLocationProvider).toConstantValue(() => UserStorageUri);
|
|
63
44
|
bindFactory(bind, UserPreferenceProviderFactory, UserPreferenceProvider, SectionPreferenceProviderUri, SectionPreferenceProviderSection);
|
|
64
45
|
bindFactory(bind, FolderPreferenceProviderFactory, FolderPreferenceProvider, SectionPreferenceProviderUri, SectionPreferenceProviderSection, FolderPreferenceProviderFolder);
|
|
65
46
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
18
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
19
|
import { CliPreferences } from '../common/cli-preferences';
|
|
20
|
-
import { PreferenceService, PreferenceScope } from '@theia/core/lib/
|
|
20
|
+
import { PreferenceService, PreferenceScope } from '@theia/core/lib/common/preferences';
|
|
21
21
|
|
|
22
22
|
@injectable()
|
|
23
23
|
export class PreferenceFrontendContribution implements FrontendApplicationContribution {
|
|
@@ -34,6 +34,10 @@ import { ServiceConnectionProvider } from '@theia/core/lib/browser/messaging/ser
|
|
|
34
34
|
import { PreferenceFrontendContribution } from './preference-frontend-contribution';
|
|
35
35
|
import { PreferenceLayoutProvider } from './util/preference-layout';
|
|
36
36
|
import { PreferencesWidget } from './views/preference-widget';
|
|
37
|
+
import { PreferenceStorageFactory } from '../common/abstract-resource-preference-provider';
|
|
38
|
+
import { FrontendPreferenceStorage } from './frontend-preference-storage';
|
|
39
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
40
|
+
import { PreferenceScope, URI } from '@theia/core';
|
|
37
41
|
|
|
38
42
|
export function bindPreferences(bind: interfaces.Bind, unbind: interfaces.Unbind): void {
|
|
39
43
|
bindPreferenceProviders(bind, unbind);
|
|
@@ -56,6 +60,12 @@ export function bindPreferences(bind: interfaces.Bind, unbind: interfaces.Unbind
|
|
|
56
60
|
bind(MonacoJSONCEditor).toSelf().inSingletonScope();
|
|
57
61
|
bind(PreferenceTransaction).toSelf();
|
|
58
62
|
bind(PreferenceTransactionFactory).toFactory(preferenceTransactionFactoryCreator);
|
|
63
|
+
bind(PreferenceStorageFactory).toFactory(({ container }) => (uri: URI, scope: PreferenceScope) => new FrontendPreferenceStorage(
|
|
64
|
+
container.get(PreferenceTransactionFactory),
|
|
65
|
+
container.get(FileService),
|
|
66
|
+
uri,
|
|
67
|
+
scope
|
|
68
|
+
));
|
|
59
69
|
|
|
60
70
|
bind(CliPreferences).toDynamicValue(ctx => ServiceConnectionProvider.createProxy<CliPreferences>(ctx.container, CliPreferencesPath)).inSingletonScope();
|
|
61
71
|
bind(PreferenceFrontendContribution).toSelf().inSingletonScope();
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { CancellationError,
|
|
17
|
+
import { CancellationError, Listener, ListenerList, MaybePromise, MessageService, nls } from '@theia/core';
|
|
18
18
|
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
19
19
|
import { inject, injectable, interfaces, postConstruct } from '@theia/core/shared/inversify';
|
|
20
20
|
import { PreferenceScope } from '@theia/core/lib/common/preferences/preference-scope';
|
|
@@ -26,10 +26,6 @@ import { MonacoJSONCEditor } from './monaco-jsonc-editor';
|
|
|
26
26
|
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
27
27
|
import { IReference } from '@theia/monaco-editor-core/esm/vs/base/common/lifecycle';
|
|
28
28
|
|
|
29
|
-
export interface OnWillConcludeEvent<T> extends WaitUntilEvent {
|
|
30
|
-
status: T | false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
29
|
@injectable()
|
|
34
30
|
/**
|
|
35
31
|
* Represents a batch of interactions with an underlying resource.
|
|
@@ -54,14 +50,12 @@ export abstract class Transaction<Arguments extends unknown[], Result = unknown,
|
|
|
54
50
|
* The transaction will self-dispose when the queue is empty, once at least one action has been processed.
|
|
55
51
|
*/
|
|
56
52
|
protected readonly queue = new Mutex(new CancellationError());
|
|
57
|
-
protected readonly
|
|
53
|
+
protected readonly onWillConcludeListeners = new ListenerList<(Status | false), Promise<void>>();
|
|
58
54
|
/**
|
|
59
55
|
* An event fired when the transaction is wrapping up.
|
|
60
56
|
* Consumers can call `waitUntil` on the event to delay the resolution of the `result` Promise.
|
|
61
57
|
*/
|
|
62
|
-
|
|
63
|
-
return this.onWillConcludeEmitter.event;
|
|
64
|
-
}
|
|
58
|
+
onWillConclude = this.onWillConcludeListeners.registration;
|
|
65
59
|
|
|
66
60
|
protected status = new Deferred<Status>();
|
|
67
61
|
/**
|
|
@@ -141,9 +135,8 @@ export abstract class Transaction<Arguments extends unknown[], Result = unknown,
|
|
|
141
135
|
this._open = false;
|
|
142
136
|
this.queue.cancel();
|
|
143
137
|
const result = await this.tearDown();
|
|
144
|
-
const status = this.status.state === 'unresolved' || this.status.state === 'rejected' ? false : await this.status.promise;
|
|
145
|
-
await
|
|
146
|
-
this.onWillConcludeEmitter.dispose();
|
|
138
|
+
const status: Status | boolean = (this.status.state === 'unresolved' || this.status.state === 'rejected') ? false : await this.status.promise;
|
|
139
|
+
await Listener.await(status, this.onWillConcludeListeners);
|
|
147
140
|
this._result.resolve(result);
|
|
148
141
|
} catch {
|
|
149
142
|
this._result.resolve(false);
|
|
@@ -179,12 +172,13 @@ export interface PreferenceContext {
|
|
|
179
172
|
getConfigUri(): URI;
|
|
180
173
|
getScope(): PreferenceScope;
|
|
181
174
|
}
|
|
175
|
+
|
|
182
176
|
export const PreferenceContext = Symbol('PreferenceContext');
|
|
183
177
|
export const PreferenceTransactionPreludeProvider = Symbol('PreferenceTransactionPreludeProvider');
|
|
184
178
|
export type PreferenceTransactionPreludeProvider = () => Promise<unknown>;
|
|
185
179
|
|
|
186
180
|
@injectable()
|
|
187
|
-
export class PreferenceTransaction extends Transaction<[string, string[], unknown], boolean> {
|
|
181
|
+
export class PreferenceTransaction extends Transaction<[string, string[], unknown], boolean, boolean> {
|
|
188
182
|
reference: IReference<MonacoEditorModel> | undefined;
|
|
189
183
|
@inject(PreferenceContext) protected readonly context: PreferenceContext;
|
|
190
184
|
@inject(PreferenceTransactionPreludeProvider) protected readonly prelude?: PreferenceTransactionPreludeProvider;
|
|
@@ -285,3 +279,4 @@ export const preferenceTransactionFactoryCreator: interfaces.FactoryCreator<Pref
|
|
|
285
279
|
child.bind(PreferenceTransactionPreludeProvider).toConstantValue(() => waitFor);
|
|
286
280
|
return child.get(PreferenceTransaction);
|
|
287
281
|
};
|
|
282
|
+
|
|
@@ -21,14 +21,11 @@ import {
|
|
|
21
21
|
CompositeTreeNode,
|
|
22
22
|
TopDownTreeIterator,
|
|
23
23
|
TreeNode,
|
|
24
|
-
PreferenceSchemaProvider,
|
|
25
|
-
PreferenceDataProperty,
|
|
26
24
|
NodeProps,
|
|
27
25
|
ExpandableTreeNode,
|
|
28
26
|
SelectableTreeNode,
|
|
29
|
-
PreferenceService,
|
|
30
27
|
} from '@theia/core/lib/browser';
|
|
31
|
-
import { Emitter } from '@theia/core';
|
|
28
|
+
import { Emitter, PreferenceDataProperty, PreferenceSchemaService, PreferenceService } from '@theia/core';
|
|
32
29
|
import { PreferencesSearchbarWidget } from './views/preference-searchbar-widget';
|
|
33
30
|
import { PreferenceTreeGenerator } from './util/preference-tree-generator';
|
|
34
31
|
import * as fuzzy from '@theia/core/shared/fuzzy';
|
|
@@ -57,7 +54,7 @@ export interface PreferenceFilterChangeEvent {
|
|
|
57
54
|
@injectable()
|
|
58
55
|
export class PreferenceTreeModel extends TreeModelImpl {
|
|
59
56
|
|
|
60
|
-
@inject(
|
|
57
|
+
@inject(PreferenceSchemaService) protected readonly schemaProvider: PreferenceSchemaService;
|
|
61
58
|
@inject(PreferencesSearchbarWidget) protected readonly filterInput: PreferencesSearchbarWidget;
|
|
62
59
|
@inject(PreferenceTreeGenerator) protected readonly treeGenerator: PreferenceTreeGenerator;
|
|
63
60
|
@inject(PreferencesScopeTabBar) protected readonly scopeTracker: PreferencesScopeTabBar;
|
|
@@ -86,8 +83,8 @@ export class PreferenceTreeModel extends TreeModelImpl {
|
|
|
86
83
|
return this._isFiltered;
|
|
87
84
|
}
|
|
88
85
|
|
|
89
|
-
get propertyList():
|
|
90
|
-
return this.schemaProvider.
|
|
86
|
+
get propertyList(): ReadonlyMap<string, PreferenceDataProperty> {
|
|
87
|
+
return this.schemaProvider.getSchemaProperties();
|
|
91
88
|
}
|
|
92
89
|
|
|
93
90
|
get currentScope(): Preference.SelectedScopeDetails {
|
|
@@ -14,28 +14,23 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { injectable, inject,
|
|
18
|
-
import { MenuModelRegistry, CommandRegistry, nls } from '@theia/core';
|
|
17
|
+
import { injectable, inject, optional } from '@theia/core/shared/inversify';
|
|
18
|
+
import { MenuModelRegistry, CommandRegistry, nls, PreferenceScope, PreferenceService } from '@theia/core';
|
|
19
19
|
import {
|
|
20
20
|
CommonMenus,
|
|
21
21
|
AbstractViewContribution,
|
|
22
22
|
CommonCommands,
|
|
23
23
|
KeybindingRegistry,
|
|
24
24
|
Widget,
|
|
25
|
-
PreferenceScope,
|
|
26
|
-
PreferenceProvider,
|
|
27
|
-
PreferenceService,
|
|
28
25
|
QuickInputService,
|
|
29
26
|
QuickPickItem,
|
|
30
27
|
isFirefox,
|
|
31
|
-
PreferenceSchemaProvider,
|
|
32
28
|
} from '@theia/core/lib/browser';
|
|
33
29
|
import { isOSX } from '@theia/core/lib/common/os';
|
|
34
30
|
import { TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
35
31
|
import { EditorManager, EditorWidget } from '@theia/editor/lib/browser';
|
|
36
32
|
import URI from '@theia/core/lib/common/uri';
|
|
37
33
|
import { PreferencesWidget } from './views/preference-widget';
|
|
38
|
-
import { WorkspacePreferenceProvider } from './workspace-preference-provider';
|
|
39
34
|
import { Preference, PreferencesCommands, PreferenceMenus } from './util/preference-types';
|
|
40
35
|
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
|
41
36
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
@@ -46,14 +41,12 @@ import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
|
46
41
|
export class PreferencesContribution extends AbstractViewContribution<PreferencesWidget> {
|
|
47
42
|
|
|
48
43
|
@inject(FileService) protected readonly fileService: FileService;
|
|
49
|
-
@inject(PreferenceProvider) @named(PreferenceScope.Workspace) protected readonly workspacePreferenceProvider: WorkspacePreferenceProvider;
|
|
50
44
|
@inject(EditorManager) protected readonly editorManager: EditorManager;
|
|
51
45
|
@inject(PreferenceService) protected readonly preferenceService: PreferenceService;
|
|
52
46
|
@inject(ClipboardService) protected readonly clipboardService: ClipboardService;
|
|
53
47
|
@inject(PreferencesWidget) protected readonly scopeTracker: PreferencesWidget;
|
|
54
48
|
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
|
|
55
49
|
@inject(QuickInputService) @optional() protected readonly quickInputService: QuickInputService;
|
|
56
|
-
@inject(PreferenceSchemaProvider) protected readonly schema: PreferenceSchemaProvider;
|
|
57
50
|
|
|
58
51
|
constructor() {
|
|
59
52
|
super({
|
|
@@ -17,20 +17,17 @@
|
|
|
17
17
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
18
|
import URI from '@theia/core/lib/common/uri';
|
|
19
19
|
import { JsonSchemaRegisterContext, JsonSchemaContribution, JsonSchemaDataStore } from '@theia/core/lib/browser/json-schema-store';
|
|
20
|
-
import { PreferenceSchemaProvider } from '@theia/core/lib/browser/preferences/preference-contribution';
|
|
21
|
-
import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
|
|
22
|
-
import { PreferenceScope } from '@theia/core/lib/browser';
|
|
23
20
|
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
21
|
+
import { PreferenceSchemaService, PreferenceConfigurations, PreferenceScope } from '@theia/core';
|
|
22
|
+
import { UserStorageUri } from '@theia/userstorage/lib/browser';
|
|
24
23
|
|
|
25
24
|
const PREFERENCE_URI_PREFIX = 'vscode://schemas/settings/';
|
|
26
|
-
const USER_STORAGE_PREFIX = 'user-storage:/';
|
|
27
25
|
|
|
28
26
|
@injectable()
|
|
29
27
|
export class PreferencesJsonSchemaContribution implements JsonSchemaContribution {
|
|
30
|
-
protected serializeSchema = (scope: PreferenceScope) => JSON.stringify(this.schemaProvider.getSchema(scope));
|
|
31
28
|
|
|
32
|
-
@inject(
|
|
33
|
-
protected readonly schemaProvider:
|
|
29
|
+
@inject(PreferenceSchemaService)
|
|
30
|
+
protected readonly schemaProvider: PreferenceSchemaService;
|
|
34
31
|
|
|
35
32
|
@inject(PreferenceConfigurations)
|
|
36
33
|
protected readonly preferenceConfigurations: PreferenceConfigurations;
|
|
@@ -47,39 +44,39 @@ export class PreferencesJsonSchemaContribution implements JsonSchemaContribution
|
|
|
47
44
|
this.registerSchema(PreferenceScope.Workspace, context);
|
|
48
45
|
this.registerSchema(PreferenceScope.Folder, context);
|
|
49
46
|
|
|
47
|
+
context.registerSchema({
|
|
48
|
+
fileMatch: `file://**/${this.preferenceConfigurations.getConfigName()}.json`,
|
|
49
|
+
url: this.getSchemaURIForScope(PreferenceScope.Folder).toString()
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
context.registerSchema({
|
|
53
|
+
fileMatch: UserStorageUri.resolve(this.preferenceConfigurations.getConfigName() + '.json').toString(),
|
|
54
|
+
url: this.getSchemaURIForScope(PreferenceScope.User).toString()
|
|
55
|
+
});
|
|
56
|
+
|
|
50
57
|
this.workspaceService.updateSchema('settings', { $ref: this.getSchemaURIForScope(PreferenceScope.Workspace).toString() });
|
|
51
|
-
this.schemaProvider.
|
|
58
|
+
this.schemaProvider.onDidChangeSchema(() => this.updateInMemoryResources());
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
protected registerSchema(scope: PreferenceScope, context: JsonSchemaRegisterContext): void {
|
|
55
62
|
const scopeStr = PreferenceScope[scope].toLowerCase();
|
|
56
63
|
const uri = new URI(PREFERENCE_URI_PREFIX + scopeStr);
|
|
57
64
|
|
|
58
|
-
this.jsonSchemaData.setSchema(uri, this.
|
|
59
|
-
|
|
60
|
-
context.registerSchema({
|
|
61
|
-
fileMatch: this.getFileMatch(scopeStr),
|
|
62
|
-
url: uri.toString()
|
|
63
|
-
});
|
|
65
|
+
this.jsonSchemaData.setSchema(uri, (this.schemaProvider.getJSONSchema(scope)));
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
protected updateInMemoryResources(): void {
|
|
67
69
|
this.jsonSchemaData.setSchema(this.getSchemaURIForScope(PreferenceScope.Default),
|
|
68
|
-
this.
|
|
70
|
+
(this.schemaProvider.getJSONSchema(PreferenceScope.Default)));
|
|
69
71
|
this.jsonSchemaData.setSchema(this.getSchemaURIForScope(PreferenceScope.User),
|
|
70
|
-
this.
|
|
72
|
+
this.schemaProvider.getJSONSchema(PreferenceScope.User));
|
|
71
73
|
this.jsonSchemaData.setSchema(this.getSchemaURIForScope(PreferenceScope.Workspace),
|
|
72
|
-
this.
|
|
74
|
+
this.schemaProvider.getJSONSchema(PreferenceScope.Workspace));
|
|
73
75
|
this.jsonSchemaData.setSchema(this.getSchemaURIForScope(PreferenceScope.Folder),
|
|
74
|
-
this.
|
|
76
|
+
this.schemaProvider.getJSONSchema(PreferenceScope.Folder));
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
protected getSchemaURIForScope(scope: PreferenceScope): URI {
|
|
78
80
|
return new URI(PREFERENCE_URI_PREFIX + PreferenceScope[scope].toLowerCase());
|
|
79
81
|
}
|
|
80
|
-
|
|
81
|
-
protected getFileMatch(scope: string): string[] {
|
|
82
|
-
const baseName = this.preferenceConfigurations.getConfigName() + '.json';
|
|
83
|
-
return [baseName, new URI(USER_STORAGE_PREFIX + scope).resolve(baseName).toString()];
|
|
84
|
-
}
|
|
85
82
|
}
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import {
|
|
18
|
+
import { LabelProvider, codicon } from '@theia/core/lib/browser';
|
|
19
19
|
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
20
|
-
import { CommandRegistry, MenuModelRegistry, Command } from '@theia/core/lib/common';
|
|
20
|
+
import { CommandRegistry, MenuModelRegistry, Command, PreferenceScope } from '@theia/core/lib/common';
|
|
21
21
|
import { Preference, PreferenceMenus } from './preference-types';
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
-
import { CompositeTreeNode
|
|
19
|
-
import { PreferenceConfigurations } from '@theia/core
|
|
20
|
-
import { Emitter } from '@theia/core';
|
|
18
|
+
import { CompositeTreeNode } from '@theia/core/lib/browser';
|
|
19
|
+
import { Emitter, OVERRIDE_PROPERTY_PATTERN, PreferenceConfigurations, PreferenceDataProperty, PreferenceSchemaService } from '@theia/core';
|
|
21
20
|
import debounce = require('@theia/core/shared/lodash.debounce');
|
|
22
21
|
import { Preference } from './preference-types';
|
|
23
22
|
import { COMMONLY_USED_SECTION_PREFIX, PreferenceLayoutProvider } from './preference-layout';
|
|
@@ -35,7 +34,7 @@ export interface CreatePreferencesGroupOptions {
|
|
|
35
34
|
@injectable()
|
|
36
35
|
export class PreferenceTreeGenerator {
|
|
37
36
|
|
|
38
|
-
@inject(
|
|
37
|
+
@inject(PreferenceSchemaService) protected readonly schemaProvider: PreferenceSchemaService;
|
|
39
38
|
@inject(PreferenceConfigurations) protected readonly preferenceConfigs: PreferenceConfigurations;
|
|
40
39
|
@inject(PreferenceLayoutProvider) protected readonly layoutProvider: PreferenceLayoutProvider;
|
|
41
40
|
@inject(PreferenceTreeLabelProvider) protected readonly labelProvider: PreferenceTreeLabelProvider;
|
|
@@ -57,15 +56,13 @@ export class PreferenceTreeGenerator {
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
protected async doInit(): Promise<void> {
|
|
60
|
-
|
|
61
|
-
this.schemaProvider.onDidPreferenceSchemaChanged(() => this.handleChangedSchema());
|
|
59
|
+
this.schemaProvider.onDidChangeSchema(() => this.handleChangedSchema());
|
|
62
60
|
this.handleChangedSchema();
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
generateTree(): CompositeTreeNode {
|
|
66
64
|
this._idCache.clear();
|
|
67
|
-
const
|
|
68
|
-
const propertyNames = Object.keys(preferencesSchema.properties);
|
|
65
|
+
const properties = this.schemaProvider.getSchemaProperties();
|
|
69
66
|
const groups = new Map<string, Preference.CompositeTreeNode>();
|
|
70
67
|
const root = this.createRootNode();
|
|
71
68
|
|
|
@@ -88,12 +85,11 @@ export class PreferenceTreeGenerator {
|
|
|
88
85
|
});
|
|
89
86
|
}
|
|
90
87
|
for (const preference of commonlyUsedLayout.settings ?? []) {
|
|
91
|
-
if (preference in
|
|
92
|
-
this.createLeafNode(preference, commonlyUsed,
|
|
88
|
+
if (preference in properties) {
|
|
89
|
+
this.createLeafNode(preference, commonlyUsed, properties.get(preference)!);
|
|
93
90
|
}
|
|
94
91
|
}
|
|
95
|
-
for (const propertyName of
|
|
96
|
-
const property = preferencesSchema.properties[propertyName];
|
|
92
|
+
for (const [propertyName, property] of properties.entries()) {
|
|
97
93
|
if (!property.hidden && !property.deprecationMessage && !this.preferenceConfigs.isSectionName(propertyName) && !OVERRIDE_PROPERTY_PATTERN.test(propertyName)) {
|
|
98
94
|
if (property.owner) {
|
|
99
95
|
this.createPluginLeafNode(propertyName, property, root, groups);
|