@theia/plugin-ext 1.28.0 → 1.29.0-next.11

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 (93) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +7 -0
  2. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc-model.js.map +1 -1
  4. package/lib/common/plugin-api-rpc.d.ts +15 -9
  5. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  6. package/lib/common/plugin-api-rpc.js.map +1 -1
  7. package/lib/common/rpc-protocol.d.ts +1 -1
  8. package/lib/common/rpc-protocol.d.ts.map +1 -1
  9. package/lib/common/rpc-protocol.js +3 -3
  10. package/lib/common/rpc-protocol.js.map +1 -1
  11. package/lib/main/browser/languages-main.d.ts +6 -1
  12. package/lib/main/browser/languages-main.d.ts.map +1 -1
  13. package/lib/main/browser/languages-main.js +15 -1
  14. package/lib/main/browser/languages-main.js.map +1 -1
  15. package/lib/main/browser/preference-registry-main.d.ts +4 -3
  16. package/lib/main/browser/preference-registry-main.d.ts.map +1 -1
  17. package/lib/main/browser/preference-registry-main.js +26 -14
  18. package/lib/main/browser/preference-registry-main.js.map +1 -1
  19. package/lib/main/browser/view/tree-view-decorator-service.d.ts +1 -1
  20. package/lib/main/browser/view/tree-view-decorator-service.d.ts.map +1 -1
  21. package/lib/main/browser/view/tree-view-decorator-service.js +1 -1
  22. package/lib/main/browser/view/tree-view-decorator-service.js.map +1 -1
  23. package/lib/main/browser/workspace-main.d.ts.map +1 -1
  24. package/lib/main/browser/workspace-main.js +1 -4
  25. package/lib/main/browser/workspace-main.js.map +1 -1
  26. package/lib/plugin/languages/code-action.d.ts.map +1 -1
  27. package/lib/plugin/languages/code-action.js +8 -9
  28. package/lib/plugin/languages/code-action.js.map +1 -1
  29. package/lib/plugin/languages/document-highlight.d.ts.map +1 -1
  30. package/lib/plugin/languages/document-highlight.js +0 -1
  31. package/lib/plugin/languages/document-highlight.js.map +1 -1
  32. package/lib/plugin/languages/evaluatable-expression.d.ts +12 -0
  33. package/lib/plugin/languages/evaluatable-expression.d.ts.map +1 -0
  34. package/lib/plugin/languages/evaluatable-expression.js +41 -0
  35. package/lib/plugin/languages/evaluatable-expression.js.map +1 -0
  36. package/lib/plugin/languages/util.d.ts +2 -2
  37. package/lib/plugin/languages/util.d.ts.map +1 -1
  38. package/lib/plugin/languages/util.js +0 -2
  39. package/lib/plugin/languages/util.js.map +1 -1
  40. package/lib/plugin/languages.d.ts +3 -1
  41. package/lib/plugin/languages.d.ts.map +1 -1
  42. package/lib/plugin/languages.js +11 -0
  43. package/lib/plugin/languages.js.map +1 -1
  44. package/lib/plugin/plugin-context.d.ts.map +1 -1
  45. package/lib/plugin/plugin-context.js +4 -0
  46. package/lib/plugin/plugin-context.js.map +1 -1
  47. package/lib/plugin/plugin-storage.d.ts +1 -0
  48. package/lib/plugin/plugin-storage.d.ts.map +1 -1
  49. package/lib/plugin/plugin-storage.js +3 -0
  50. package/lib/plugin/plugin-storage.js.map +1 -1
  51. package/lib/plugin/preference-registry.d.ts +15 -2
  52. package/lib/plugin/preference-registry.d.ts.map +1 -1
  53. package/lib/plugin/preference-registry.js +105 -62
  54. package/lib/plugin/preference-registry.js.map +1 -1
  55. package/lib/plugin/preference-registry.spec.js +207 -35
  56. package/lib/plugin/preference-registry.spec.js.map +1 -1
  57. package/lib/plugin/type-converters.d.ts +7 -6
  58. package/lib/plugin/type-converters.d.ts.map +1 -1
  59. package/lib/plugin/type-converters.js +54 -55
  60. package/lib/plugin/type-converters.js.map +1 -1
  61. package/lib/plugin/types-impl.d.ts +8 -3
  62. package/lib/plugin/types-impl.d.ts.map +1 -1
  63. package/lib/plugin/types-impl.js +22 -10
  64. package/lib/plugin/types-impl.js.map +1 -1
  65. package/package.json +24 -24
  66. package/src/common/plugin-api-rpc-model.ts +10 -0
  67. package/src/common/plugin-api-rpc.ts +18 -9
  68. package/src/common/rpc-protocol.ts +5 -5
  69. package/src/main/browser/languages-main.ts +23 -1
  70. package/src/main/browser/preference-registry-main.ts +23 -14
  71. package/src/main/browser/view/tree-view-decorator-service.ts +2 -2
  72. package/src/main/browser/workspace-main.ts +1 -5
  73. package/src/plugin/languages/code-action.ts +9 -12
  74. package/src/plugin/languages/document-highlight.ts +1 -2
  75. package/src/plugin/languages/evaluatable-expression.ts +47 -0
  76. package/src/plugin/languages/util.ts +2 -4
  77. package/src/plugin/languages.ts +15 -0
  78. package/src/plugin/plugin-context.ts +6 -1
  79. package/src/plugin/plugin-storage.ts +4 -0
  80. package/src/plugin/preference-registry.spec.ts +247 -39
  81. package/src/plugin/preference-registry.ts +107 -71
  82. package/src/plugin/type-converters.ts +58 -59
  83. package/src/plugin/types-impl.ts +30 -14
  84. package/lib/plugin/preferences/configuration.d.ts +0 -35
  85. package/lib/plugin/preferences/configuration.d.ts.map +0 -1
  86. package/lib/plugin/preferences/configuration.js +0 -137
  87. package/lib/plugin/preferences/configuration.js.map +0 -1
  88. package/lib/plugin/preferences/configuration.spec.d.ts +0 -2
  89. package/lib/plugin/preferences/configuration.spec.d.ts.map +0 -1
  90. package/lib/plugin/preferences/configuration.spec.js +0 -178
  91. package/lib/plugin/preferences/configuration.spec.js.map +0 -1
  92. package/src/plugin/preferences/configuration.spec.ts +0 -292
  93. package/src/plugin/preferences/configuration.ts +0 -167
@@ -1,167 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 Red Hat, Inc. 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 { WorkspaceExtImpl } from '../workspace';
18
- import { isObject } from '../../common/types';
19
- import cloneDeep = require('lodash.clonedeep');
20
- import { URI } from '@theia/core/shared/vscode-uri';
21
-
22
- /* eslint-disable @typescript-eslint/no-explicit-any */
23
-
24
- export class Configuration {
25
-
26
- private combinedConfig: ConfigurationModel | undefined;
27
- private folderCombinedConfigs: { [resource: string]: ConfigurationModel } = {};
28
-
29
- constructor(
30
- private defaultConfiguration: ConfigurationModel,
31
- private userConfiguration: ConfigurationModel,
32
- private workspaceConfiguration: ConfigurationModel = new ConfigurationModel(),
33
- private folderConfigurations: { [resource: string]: ConfigurationModel } = {},
34
- ) { }
35
-
36
- getValue(section: string | undefined, workspace: WorkspaceExtImpl, resource?: URI): any {
37
- return this.getCombinedResourceConfig(workspace, resource).getValue(section);
38
- }
39
-
40
- inspect<C>(key: string, workspace: WorkspaceExtImpl, resource?: URI): {
41
- default: C,
42
- user: C,
43
- workspace: C | undefined,
44
- workspaceFolder: C | undefined,
45
- value: C,
46
- } {
47
- const combinedConfiguration = this.getCombinedResourceConfig(workspace, resource);
48
- const folderConfiguration = this.getFolderResourceConfig(workspace, resource);
49
- return {
50
- default: this.defaultConfiguration.getValue(key),
51
- user: this.userConfiguration.getValue(key),
52
- workspace: workspace ? this.workspaceConfiguration.getValue(key) : undefined,
53
- workspaceFolder: folderConfiguration ? folderConfiguration.getValue(key) : undefined,
54
- value: combinedConfiguration.getValue(key)
55
- };
56
- }
57
-
58
- private getCombinedResourceConfig(workspace: WorkspaceExtImpl, resource?: URI): ConfigurationModel {
59
- const combinedConfig = this.getCombinedConfig();
60
- if (!workspace || !resource) {
61
- return combinedConfig;
62
- }
63
-
64
- const workspaceFolder = workspace.getWorkspaceFolder(resource);
65
- if (!workspaceFolder) {
66
- return combinedConfig;
67
- }
68
-
69
- return this.getFolderCombinedConfig(workspaceFolder.uri.toString()) || combinedConfig;
70
- }
71
-
72
- private getCombinedConfig(): ConfigurationModel {
73
- if (!this.combinedConfig) {
74
- this.combinedConfig = this.defaultConfiguration.merge(this.userConfiguration, this.workspaceConfiguration);
75
- }
76
- return this.combinedConfig;
77
- }
78
-
79
- private getFolderCombinedConfig(folder: string): ConfigurationModel | undefined {
80
- if (this.folderCombinedConfigs[folder]) {
81
- return this.folderCombinedConfigs[folder];
82
- }
83
-
84
- const combinedConfig = this.getCombinedConfig();
85
- const folderConfig = this.folderConfigurations[folder];
86
- if (!folderConfig) {
87
- return combinedConfig;
88
- }
89
-
90
- const folderCombinedConfig = combinedConfig.merge(folderConfig);
91
- this.folderCombinedConfigs[folder] = folderCombinedConfig;
92
-
93
- return folderCombinedConfig;
94
- }
95
-
96
- private getFolderResourceConfig(workspace: WorkspaceExtImpl, resource?: URI): ConfigurationModel | undefined {
97
- if (!workspace || !resource) {
98
- return;
99
- }
100
-
101
- const workspaceFolder = workspace.getWorkspaceFolder(resource);
102
- if (!workspaceFolder) {
103
- return;
104
- }
105
- return this.folderConfigurations[workspaceFolder.uri.toString()];
106
- }
107
-
108
- }
109
-
110
- export class ConfigurationModel {
111
-
112
- constructor(
113
- private contents: any = Object.create(null),
114
- private keys: string[] = [],
115
- ) { }
116
-
117
- getValue(section?: string): any {
118
- if (!section) {
119
- return this.contents;
120
- }
121
-
122
- const path = section.split('.');
123
- let current = this.contents;
124
- for (let i = 0; i < path.length; i++) {
125
- if (typeof current !== 'object' || current === null) {
126
- return undefined;
127
- }
128
- current = current[path[i]];
129
- }
130
- return current;
131
- }
132
-
133
- merge(...others: ConfigurationModel[]): ConfigurationModel {
134
- const contents = cloneDeep(this.contents);
135
- const allKeys = [...this.keys];
136
-
137
- for (const other of others) {
138
- this.mergeContents(contents, other.contents);
139
- this.mergeKeys(allKeys, other.keys);
140
- }
141
- return new ConfigurationModel(contents, allKeys);
142
- }
143
-
144
- private mergeContents(source: any, target: any): void {
145
- for (const key of Object.keys(target)) {
146
- if (key === '__proto__') {
147
- continue;
148
- }
149
- if (key in source) {
150
- if (isObject(source[key]) && isObject(target[key])) {
151
- this.mergeContents(source[key], target[key]);
152
- continue;
153
- }
154
- }
155
- source[key] = cloneDeep(target[key]);
156
- }
157
- }
158
-
159
- private mergeKeys(source: string[], target: string[]): void {
160
- for (const key of target) {
161
- if (source.indexOf(key) === -1) {
162
- source.push(key);
163
- }
164
- }
165
- }
166
-
167
- }