@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.
- package/lib/common/plugin-api-rpc-model.d.ts +7 -0
- package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc-model.js.map +1 -1
- package/lib/common/plugin-api-rpc.d.ts +15 -9
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/rpc-protocol.d.ts +1 -1
- package/lib/common/rpc-protocol.d.ts.map +1 -1
- package/lib/common/rpc-protocol.js +3 -3
- package/lib/common/rpc-protocol.js.map +1 -1
- package/lib/main/browser/languages-main.d.ts +6 -1
- package/lib/main/browser/languages-main.d.ts.map +1 -1
- package/lib/main/browser/languages-main.js +15 -1
- package/lib/main/browser/languages-main.js.map +1 -1
- package/lib/main/browser/preference-registry-main.d.ts +4 -3
- package/lib/main/browser/preference-registry-main.d.ts.map +1 -1
- package/lib/main/browser/preference-registry-main.js +26 -14
- package/lib/main/browser/preference-registry-main.js.map +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.d.ts +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.d.ts.map +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.js +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.js.map +1 -1
- package/lib/main/browser/workspace-main.d.ts.map +1 -1
- package/lib/main/browser/workspace-main.js +1 -4
- package/lib/main/browser/workspace-main.js.map +1 -1
- package/lib/plugin/languages/code-action.d.ts.map +1 -1
- package/lib/plugin/languages/code-action.js +8 -9
- package/lib/plugin/languages/code-action.js.map +1 -1
- package/lib/plugin/languages/document-highlight.d.ts.map +1 -1
- package/lib/plugin/languages/document-highlight.js +0 -1
- package/lib/plugin/languages/document-highlight.js.map +1 -1
- package/lib/plugin/languages/evaluatable-expression.d.ts +12 -0
- package/lib/plugin/languages/evaluatable-expression.d.ts.map +1 -0
- package/lib/plugin/languages/evaluatable-expression.js +41 -0
- package/lib/plugin/languages/evaluatable-expression.js.map +1 -0
- package/lib/plugin/languages/util.d.ts +2 -2
- package/lib/plugin/languages/util.d.ts.map +1 -1
- package/lib/plugin/languages/util.js +0 -2
- package/lib/plugin/languages/util.js.map +1 -1
- package/lib/plugin/languages.d.ts +3 -1
- package/lib/plugin/languages.d.ts.map +1 -1
- package/lib/plugin/languages.js +11 -0
- package/lib/plugin/languages.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +4 -0
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/plugin-storage.d.ts +1 -0
- package/lib/plugin/plugin-storage.d.ts.map +1 -1
- package/lib/plugin/plugin-storage.js +3 -0
- package/lib/plugin/plugin-storage.js.map +1 -1
- package/lib/plugin/preference-registry.d.ts +15 -2
- package/lib/plugin/preference-registry.d.ts.map +1 -1
- package/lib/plugin/preference-registry.js +105 -62
- package/lib/plugin/preference-registry.js.map +1 -1
- package/lib/plugin/preference-registry.spec.js +207 -35
- package/lib/plugin/preference-registry.spec.js.map +1 -1
- package/lib/plugin/type-converters.d.ts +7 -6
- package/lib/plugin/type-converters.d.ts.map +1 -1
- package/lib/plugin/type-converters.js +54 -55
- package/lib/plugin/type-converters.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +8 -3
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +22 -10
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +24 -24
- package/src/common/plugin-api-rpc-model.ts +10 -0
- package/src/common/plugin-api-rpc.ts +18 -9
- package/src/common/rpc-protocol.ts +5 -5
- package/src/main/browser/languages-main.ts +23 -1
- package/src/main/browser/preference-registry-main.ts +23 -14
- package/src/main/browser/view/tree-view-decorator-service.ts +2 -2
- package/src/main/browser/workspace-main.ts +1 -5
- package/src/plugin/languages/code-action.ts +9 -12
- package/src/plugin/languages/document-highlight.ts +1 -2
- package/src/plugin/languages/evaluatable-expression.ts +47 -0
- package/src/plugin/languages/util.ts +2 -4
- package/src/plugin/languages.ts +15 -0
- package/src/plugin/plugin-context.ts +6 -1
- package/src/plugin/plugin-storage.ts +4 -0
- package/src/plugin/preference-registry.spec.ts +247 -39
- package/src/plugin/preference-registry.ts +107 -71
- package/src/plugin/type-converters.ts +58 -59
- package/src/plugin/types-impl.ts +30 -14
- package/lib/plugin/preferences/configuration.d.ts +0 -35
- package/lib/plugin/preferences/configuration.d.ts.map +0 -1
- package/lib/plugin/preferences/configuration.js +0 -137
- package/lib/plugin/preferences/configuration.js.map +0 -1
- package/lib/plugin/preferences/configuration.spec.d.ts +0 -2
- package/lib/plugin/preferences/configuration.spec.d.ts.map +0 -1
- package/lib/plugin/preferences/configuration.spec.js +0 -178
- package/lib/plugin/preferences/configuration.spec.js.map +0 -1
- package/src/plugin/preferences/configuration.spec.ts +0 -292
- package/src/plugin/preferences/configuration.ts +0 -167
|
@@ -17,17 +17,20 @@
|
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
18
|
|
|
19
19
|
import { Emitter, Event } from '@theia/core/lib/common/event';
|
|
20
|
+
import { URI } from '@theia/core/shared/vscode-uri';
|
|
21
|
+
import { ResourceMap } from '@theia/monaco-editor-core/esm/vs/base/common/map';
|
|
22
|
+
import { IConfigurationOverrides, IOverrides } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
|
|
23
|
+
import { Configuration, ConfigurationModel } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configurationModels';
|
|
24
|
+
import { Workspace, WorkspaceFolder } from '@theia/monaco-editor-core/esm/vs/platform/workspace/common/workspace';
|
|
20
25
|
import * as theia from '@theia/plugin';
|
|
26
|
+
import { platform } from 'os';
|
|
27
|
+
import { v4 } from 'uuid';
|
|
21
28
|
import {
|
|
22
|
-
PLUGIN_RPC_CONTEXT,
|
|
23
|
-
|
|
24
|
-
PreferenceRegistryMain,
|
|
25
|
-
PreferenceData,
|
|
26
|
-
PreferenceChangeExt
|
|
29
|
+
PLUGIN_RPC_CONTEXT, PreferenceChangeExt, PreferenceData, PreferenceRegistryExt,
|
|
30
|
+
PreferenceRegistryMain
|
|
27
31
|
} from '../common/plugin-api-rpc';
|
|
28
32
|
import { RPCProtocol } from '../common/rpc-protocol';
|
|
29
33
|
import { isObject, mixin } from '../common/types';
|
|
30
|
-
import { Configuration, ConfigurationModel } from './preferences/configuration';
|
|
31
34
|
import { WorkspaceExtImpl } from './workspace';
|
|
32
35
|
import cloneDeep = require('lodash.clonedeep');
|
|
33
36
|
|
|
@@ -35,14 +38,14 @@ const injectionRe = /\b__proto__\b|\bconstructor\.prototype\b/;
|
|
|
35
38
|
|
|
36
39
|
enum ConfigurationTarget {
|
|
37
40
|
Global = 1,
|
|
38
|
-
Workspace = 2,
|
|
39
|
-
WorkspaceFolder = 3
|
|
41
|
+
Workspace = 2, // eslint-disable-line @typescript-eslint/no-shadow
|
|
42
|
+
WorkspaceFolder = 3 // eslint-disable-line @typescript-eslint/no-shadow
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
enum PreferenceScope {
|
|
45
|
+
export enum PreferenceScope {
|
|
43
46
|
Default,
|
|
44
47
|
User,
|
|
45
|
-
Workspace,
|
|
48
|
+
Workspace, // eslint-disable-line @typescript-eslint/no-shadow
|
|
46
49
|
Folder,
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -68,6 +71,13 @@ function lookUp(tree: any, key: string): any {
|
|
|
68
71
|
return node;
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
export class TheiaWorkspace extends Workspace {
|
|
75
|
+
constructor(ext: WorkspaceExtImpl) {
|
|
76
|
+
const folders = (ext.workspaceFolders ?? []).map(folder => new WorkspaceFolder(folder));
|
|
77
|
+
super(v4(), folders, false, ext.workspaceFile ?? null, () => ['win32', 'darwin'].includes(platform()));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
71
81
|
export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
|
|
72
82
|
private proxy: PreferenceRegistryMain;
|
|
73
83
|
private _preferences: Configuration;
|
|
@@ -91,11 +101,11 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
|
|
|
91
101
|
this._onDidChangeConfiguration.fire(this.toConfigurationChangeEvent(eventData));
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
getConfiguration(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
getConfiguration(rawSection?: string, rawScope?: theia.ConfigurationScope | null, extensionId?: string): theia.WorkspaceConfiguration {
|
|
105
|
+
const overrides = this.parseConfigurationAccessOptions(rawScope);
|
|
106
|
+
|
|
107
|
+
const preferences = this.toReadonlyValue(
|
|
108
|
+
this._preferences.getValue(rawSection, overrides, new TheiaWorkspace(this.workspace)));
|
|
99
109
|
|
|
100
110
|
const configuration: theia.WorkspaceConfiguration = {
|
|
101
111
|
has(key: string): boolean {
|
|
@@ -119,6 +129,11 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
|
|
|
119
129
|
}
|
|
120
130
|
return new Proxy(target, {
|
|
121
131
|
get: (targ: any, prop: string) => {
|
|
132
|
+
const config = Object.getOwnPropertyDescriptor(targ, prop);
|
|
133
|
+
// This check ensures that https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/get#invariants are satisfied
|
|
134
|
+
if (config?.configurable === false && config?.writable === false) {
|
|
135
|
+
return targ[prop];
|
|
136
|
+
}
|
|
122
137
|
if (typeof prop === 'string' && prop.toLowerCase() === 'tojson') {
|
|
123
138
|
cloneTarget();
|
|
124
139
|
return () => clonedTarget;
|
|
@@ -153,37 +168,28 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
|
|
|
153
168
|
return cloneOnWriteProxy(result, key);
|
|
154
169
|
}
|
|
155
170
|
},
|
|
156
|
-
update: (key: string, value: any,
|
|
157
|
-
|
|
158
|
-
const
|
|
171
|
+
update: (key: string, value: any, targetScope?: ConfigurationTarget | boolean, withLanguageOverride?: boolean): PromiseLike<void> => {
|
|
172
|
+
const resourceStr = overrides.resource?.toString();
|
|
173
|
+
const fullPath = `${overrides.overrideIdentifier ? `[${overrides.overrideIdentifier}].` : ''}${rawSection}.${key}`;
|
|
159
174
|
if (typeof value !== 'undefined') {
|
|
160
|
-
return this.proxy.$updateConfigurationOption(
|
|
175
|
+
return this.proxy.$updateConfigurationOption(targetScope, fullPath, value, resourceStr, withLanguageOverride);
|
|
161
176
|
} else {
|
|
162
|
-
return this.proxy.$removeConfigurationOption(
|
|
177
|
+
return this.proxy.$removeConfigurationOption(targetScope, fullPath, resourceStr, withLanguageOverride);
|
|
163
178
|
}
|
|
164
179
|
},
|
|
165
180
|
inspect: <T>(key: string): ConfigurationInspect<T> | undefined => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const result = cloneDeep(this._preferences.inspect<T>(key, this.workspace, resource));
|
|
181
|
+
const path = `${rawSection}.${key}`;
|
|
182
|
+
const result = this._preferences.inspect<T>(path, overrides, new TheiaWorkspace(this.workspace));
|
|
169
183
|
|
|
170
184
|
if (!result) {
|
|
171
185
|
return undefined;
|
|
172
186
|
}
|
|
173
187
|
|
|
174
188
|
const configInspect: ConfigurationInspect<T> = { key };
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
configInspect.globalValue = result.user;
|
|
180
|
-
}
|
|
181
|
-
if (typeof result.workspace !== 'undefined') {
|
|
182
|
-
configInspect.workspaceValue = result.workspace;
|
|
183
|
-
}
|
|
184
|
-
if (typeof result.workspaceFolder !== 'undefined') {
|
|
185
|
-
configInspect.workspaceFolderValue = result.workspaceFolder;
|
|
186
|
-
}
|
|
189
|
+
configInspect.defaultValue = result.default?.value;
|
|
190
|
+
configInspect.globalValue = result.user?.value;
|
|
191
|
+
configInspect.workspaceValue = result.workspace?.value;
|
|
192
|
+
configInspect.workspaceFolderValue = result.workspaceFolder?.value;
|
|
187
193
|
return configInspect;
|
|
188
194
|
}
|
|
189
195
|
};
|
|
@@ -198,7 +204,14 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
|
|
|
198
204
|
private toReadonlyValue(data: any): any {
|
|
199
205
|
const readonlyProxy = (target: any): any => isObject(target)
|
|
200
206
|
? new Proxy(target, {
|
|
201
|
-
get: (targ: any, prop: string) =>
|
|
207
|
+
get: (targ: any, prop: string) => {
|
|
208
|
+
const config = Object.getOwnPropertyDescriptor(targ, prop);
|
|
209
|
+
// This check ensures that https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/get#invariants are satisfied
|
|
210
|
+
if (config?.configurable === false && config?.writable === false) {
|
|
211
|
+
return targ[prop];
|
|
212
|
+
}
|
|
213
|
+
return readonlyProxy(targ[prop]);
|
|
214
|
+
},
|
|
202
215
|
set: (targ: any, prop: string, val: any) => {
|
|
203
216
|
throw new Error(`TypeError: Cannot assign to read only property '${prop}' of object`);
|
|
204
217
|
},
|
|
@@ -222,70 +235,93 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
|
|
|
222
235
|
const defaultConfiguration = this.getConfigurationModel(data[PreferenceScope.Default]);
|
|
223
236
|
const userConfiguration = this.getConfigurationModel(data[PreferenceScope.User]);
|
|
224
237
|
const workspaceConfiguration = this.getConfigurationModel(data[PreferenceScope.Workspace]);
|
|
225
|
-
const folderConfigurations =
|
|
238
|
+
const folderConfigurations = new ResourceMap<ConfigurationModel>();
|
|
226
239
|
Object.keys(data[PreferenceScope.Folder]).forEach(resource => {
|
|
227
|
-
folderConfigurations
|
|
240
|
+
folderConfigurations.set(URI.parse(resource), this.getConfigurationModel(data[PreferenceScope.Folder][resource]));
|
|
228
241
|
});
|
|
229
|
-
return new Configuration(defaultConfiguration, userConfiguration, workspaceConfiguration, folderConfigurations);
|
|
242
|
+
return new Configuration(defaultConfiguration, userConfiguration, undefined, workspaceConfiguration, folderConfigurations);
|
|
230
243
|
}
|
|
231
244
|
|
|
232
245
|
private getConfigurationModel(data: { [key: string]: any }): ConfigurationModel {
|
|
233
246
|
if (!data) {
|
|
234
247
|
return new ConfigurationModel();
|
|
235
248
|
}
|
|
236
|
-
|
|
249
|
+
const configData = this.parseConfigurationData(data);
|
|
250
|
+
return new ConfigurationModel(configData.contents, configData.keys, configData.overrides);
|
|
237
251
|
}
|
|
238
252
|
|
|
239
|
-
private readonly OVERRIDE_PROPERTY = '
|
|
253
|
+
private readonly OVERRIDE_PROPERTY = '^\\[(.*)\\]$';
|
|
240
254
|
private readonly OVERRIDE_PROPERTY_PATTERN = new RegExp(this.OVERRIDE_PROPERTY);
|
|
255
|
+
private readonly OVERRIDE_KEY_TEST = /^\[([^\]]+)\]\./;
|
|
241
256
|
|
|
242
|
-
private parseConfigurationData(data: { [key: string]: any }): {
|
|
243
|
-
|
|
257
|
+
private parseConfigurationData(data: { [key: string]: any }): Omit<IOverrides, 'identifiers'> & { overrides: IOverrides[] } {
|
|
258
|
+
const keys = new Array<string>();
|
|
259
|
+
const overrides: Record<string, IOverrides> = Object.create(null);
|
|
260
|
+
const contents = Object.keys(data).reduce((result: any, key: string) => {
|
|
244
261
|
if (injectionRe.test(key)) {
|
|
245
262
|
return result;
|
|
246
263
|
}
|
|
247
264
|
const parts = key.split('.');
|
|
248
265
|
let branch = result;
|
|
249
|
-
|
|
266
|
+
const isOverride = this.OVERRIDE_KEY_TEST.test(key);
|
|
267
|
+
if (!isOverride) {
|
|
268
|
+
keys.push(key);
|
|
269
|
+
}
|
|
250
270
|
for (let i = 0; i < parts.length; i++) {
|
|
251
|
-
if (i ===
|
|
271
|
+
if (i === 0 && isOverride) {
|
|
272
|
+
const identifier = this.OVERRIDE_PROPERTY_PATTERN.exec(parts[i])![1];
|
|
273
|
+
if (!overrides[identifier]) {
|
|
274
|
+
overrides[identifier] = { keys: [], identifiers: [identifier], contents: Object.create(null) };
|
|
275
|
+
}
|
|
276
|
+
branch = overrides[identifier].contents;
|
|
277
|
+
overrides[identifier].keys.push(key.slice(parts[i].length + 1));
|
|
278
|
+
} else if (i === parts.length - 1) {
|
|
252
279
|
branch[parts[i]] = data[key];
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
branch = branch[parts[i]];
|
|
259
|
-
|
|
260
|
-
// overridden properties should be transformed into
|
|
261
|
-
// "[overridden_identifier]" : {
|
|
262
|
-
// "property1" : "value1"
|
|
263
|
-
// "property2" : "value2"
|
|
264
|
-
// }
|
|
265
|
-
if (i === 0 && this.OVERRIDE_PROPERTY_PATTERN.test(parts[i])) {
|
|
266
|
-
branch[key.substring(parts[0].length + 1)] = data[key];
|
|
267
|
-
break;
|
|
280
|
+
} else {
|
|
281
|
+
if (!branch[parts[i]]) {
|
|
282
|
+
branch[parts[i]] = Object.create(null);
|
|
283
|
+
}
|
|
284
|
+
branch = branch[parts[i]];
|
|
268
285
|
}
|
|
269
286
|
}
|
|
270
287
|
return result;
|
|
271
288
|
}, Object.create(null));
|
|
289
|
+
return { contents, keys, overrides: Object.values(overrides) };
|
|
272
290
|
}
|
|
273
291
|
|
|
274
292
|
private toConfigurationChangeEvent(eventData: PreferenceChangeExt[]): theia.ConfigurationChangeEvent {
|
|
275
293
|
return Object.freeze({
|
|
276
|
-
affectsConfiguration: (section: string,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
294
|
+
affectsConfiguration: (section: string, scope?: theia.ConfigurationScope): boolean => {
|
|
295
|
+
const { resource, overrideIdentifier } = this.parseConfigurationAccessOptions(scope);
|
|
296
|
+
const sectionWithLanguage = overrideIdentifier ? `[${overrideIdentifier}].${section}` : section;
|
|
297
|
+
return eventData.some(change => {
|
|
298
|
+
const matchesUri = !resource || !change.scope || (resource.toString() + '/').startsWith(change.scope.endsWith('/') ? change.scope : change.scope + '/');
|
|
299
|
+
const sliceIndex = overrideIdentifier ? 0 : (this.OVERRIDE_KEY_TEST.exec(change.preferenceName)?.[0].length ?? 0);
|
|
300
|
+
const changedPreferenceName = sliceIndex ? change.preferenceName.slice(sliceIndex) : change.preferenceName;
|
|
301
|
+
return matchesUri && (
|
|
302
|
+
sectionWithLanguage === changedPreferenceName
|
|
303
|
+
|| sectionWithLanguage.startsWith(`${changedPreferenceName}.`)
|
|
304
|
+
|| changedPreferenceName.startsWith(`${sectionWithLanguage}.`));
|
|
305
|
+
});
|
|
287
306
|
}
|
|
288
307
|
});
|
|
289
308
|
}
|
|
290
309
|
|
|
310
|
+
protected parseConfigurationAccessOptions(scope?: theia.ConfigurationScope | null): IConfigurationOverrides {
|
|
311
|
+
if (!scope) {
|
|
312
|
+
return {};
|
|
313
|
+
}
|
|
314
|
+
let overrideIdentifier: string | undefined = undefined;
|
|
315
|
+
let resource: theia.Uri | undefined;
|
|
316
|
+
if ('uri' in scope || 'languageId' in scope) {
|
|
317
|
+
resource = scope.uri;
|
|
318
|
+
} else {
|
|
319
|
+
resource = scope;
|
|
320
|
+
}
|
|
321
|
+
if ('languageId' in scope) {
|
|
322
|
+
overrideIdentifier = scope.languageId;
|
|
323
|
+
}
|
|
324
|
+
return { resource, overrideIdentifier };
|
|
325
|
+
}
|
|
326
|
+
|
|
291
327
|
}
|
|
@@ -137,9 +137,8 @@ export function toPosition(position: Position): types.Position {
|
|
|
137
137
|
return new types.Position(position.lineNumber - 1, position.column - 1);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return (typeof something.range !== 'undefined');
|
|
140
|
+
function isDecorationOptions(arg: unknown): arg is theia.DecorationOptions {
|
|
141
|
+
return !!arg && typeof arg === 'object' && typeof (arg as theia.DecorationOptions).range !== 'undefined';
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
export function isDecorationOptionsArr(something: theia.Range[] | theia.DecorationOptions[]): something is theia.DecorationOptions[] {
|
|
@@ -182,11 +181,10 @@ interface Codeblock {
|
|
|
182
181
|
value: string;
|
|
183
182
|
}
|
|
184
183
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
&& typeof (
|
|
189
|
-
&& typeof (<Codeblock>thing).value === 'string';
|
|
184
|
+
function isCodeblock(arg: unknown): arg is Codeblock {
|
|
185
|
+
return !!arg && typeof arg === 'object'
|
|
186
|
+
&& typeof (arg as Codeblock).language === 'string'
|
|
187
|
+
&& typeof (arg as Codeblock).value === 'string';
|
|
190
188
|
}
|
|
191
189
|
|
|
192
190
|
export function fromMarkdown(markup: theia.MarkdownString | theia.MarkedString): MarkdownStringDTO {
|
|
@@ -396,6 +394,13 @@ export function fromHover(hover: theia.Hover): model.Hover {
|
|
|
396
394
|
};
|
|
397
395
|
}
|
|
398
396
|
|
|
397
|
+
export function fromEvaluatableExpression(evaluatableExpression: theia.EvaluatableExpression): model.EvaluatableExpression {
|
|
398
|
+
return <model.EvaluatableExpression>{
|
|
399
|
+
range: fromRange(evaluatableExpression.range),
|
|
400
|
+
expression: evaluatableExpression.expression
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
399
404
|
export function fromLocation(location: theia.Location): model.Location {
|
|
400
405
|
return <model.Location>{
|
|
401
406
|
uri: location.uri,
|
|
@@ -618,64 +623,58 @@ export function toSymbolTag(kind: model.SymbolTag): types.SymbolTag {
|
|
|
618
623
|
}
|
|
619
624
|
}
|
|
620
625
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
if (!thing) {
|
|
624
|
-
return false;
|
|
625
|
-
}
|
|
626
|
-
return isModelRange((<model.Location>thing).range) &&
|
|
627
|
-
isUriComponents((<model.Location>thing).uri);
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
631
|
-
export function isModelRange(thing: any): thing is model.Range {
|
|
632
|
-
if (!thing) {
|
|
633
|
-
return false;
|
|
634
|
-
}
|
|
635
|
-
return (('startLineNumber' in thing) && typeof thing.startLineNumber === 'number') &&
|
|
636
|
-
(('startColumn' in thing) && typeof thing.startColumn === 'number') &&
|
|
637
|
-
(('endLineNumber' in thing) && typeof thing.endLineNumber === 'number') &&
|
|
638
|
-
(('endColumn' in thing) && typeof thing.endColumn === 'number');
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
642
|
-
export function isUriComponents(thing: any): thing is UriComponents {
|
|
643
|
-
if (!thing) {
|
|
626
|
+
export function isModelLocation(arg: unknown): arg is model.Location {
|
|
627
|
+
if (!arg) {
|
|
644
628
|
return false;
|
|
645
629
|
}
|
|
646
|
-
return
|
|
647
|
-
|
|
648
|
-
((
|
|
649
|
-
((
|
|
630
|
+
return !!arg &&
|
|
631
|
+
typeof arg === 'object' &&
|
|
632
|
+
isModelRange((arg as model.Location).range) &&
|
|
633
|
+
isUriComponents((arg as model.Location).uri);
|
|
650
634
|
}
|
|
651
635
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
&& isUriComponents(thing.uri)
|
|
660
|
-
&& !!thing.name;
|
|
636
|
+
export function isModelRange(arg: unknown): arg is model.Range {
|
|
637
|
+
const range = arg as model.Range;
|
|
638
|
+
return !!arg && typeof arg === 'object' &&
|
|
639
|
+
typeof range.startLineNumber === 'number' &&
|
|
640
|
+
typeof range.startColumn === 'number' &&
|
|
641
|
+
typeof range.endLineNumber === 'number' &&
|
|
642
|
+
typeof range.endColumn === 'number';
|
|
661
643
|
}
|
|
662
644
|
|
|
663
645
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
664
|
-
export function
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
export function
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
646
|
+
export function isUriComponents(arg: unknown): arg is UriComponents {
|
|
647
|
+
const uriComponents = arg as UriComponents;
|
|
648
|
+
return !!arg && typeof arg === 'object' &&
|
|
649
|
+
typeof uriComponents.scheme === 'string' &&
|
|
650
|
+
typeof uriComponents.path === 'string' &&
|
|
651
|
+
typeof uriComponents.query === 'string' &&
|
|
652
|
+
typeof uriComponents.fragment === 'string';
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export function isModelCallHierarchyItem(arg: unknown): arg is model.CallHierarchyItem {
|
|
656
|
+
const item = arg as model.CallHierarchyItem;
|
|
657
|
+
return !!item && typeof item === 'object'
|
|
658
|
+
&& isModelRange(item.range)
|
|
659
|
+
&& isModelRange(item.selectionRange)
|
|
660
|
+
&& isUriComponents(item.uri)
|
|
661
|
+
&& !!item.name;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
export function isModelCallHierarchyIncomingCall(arg: unknown): arg is model.CallHierarchyIncomingCall {
|
|
665
|
+
const maybeIncomingCall = arg as model.CallHierarchyIncomingCall;
|
|
666
|
+
return !!arg && typeof arg === 'object' &&
|
|
667
|
+
'from' in maybeIncomingCall &&
|
|
668
|
+
'fromRanges' in maybeIncomingCall &&
|
|
669
|
+
isModelCallHierarchyItem(maybeIncomingCall.from);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export function isModelCallHierarchyOutgoingCall(arg: unknown): arg is model.CallHierarchyOutgoingCall {
|
|
673
|
+
const maybeOutgoingCall = arg as model.CallHierarchyOutgoingCall;
|
|
674
|
+
return !!arg && typeof arg === 'object' &&
|
|
675
|
+
'to' in maybeOutgoingCall &&
|
|
676
|
+
'fromRanges' in maybeOutgoingCall &&
|
|
677
|
+
isModelCallHierarchyItem(maybeOutgoingCall.to);
|
|
679
678
|
}
|
|
680
679
|
|
|
681
680
|
export function toLocation(value: model.Location): types.Location {
|
package/src/plugin/types-impl.ts
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
*--------------------------------------------------------------------------------------------*/
|
|
21
21
|
|
|
22
22
|
/* eslint-disable no-null/no-null */
|
|
23
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
24
23
|
|
|
25
24
|
import { UUID } from '@theia/core/shared/@phosphor/coreutils';
|
|
26
25
|
import { illegalArgument } from '../common/errors';
|
|
@@ -38,6 +37,7 @@ import { es5ClassCompat } from '../common/types';
|
|
|
38
37
|
* A reviver that takes URI's transferred via JSON.stringify() and makes
|
|
39
38
|
* instances of our local plugin API URI class (below)
|
|
40
39
|
*/
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
41
|
export function reviver(key: string | undefined, value: any): any {
|
|
42
42
|
const revived = ObjectsTransferrer.reviver(key, value);
|
|
43
43
|
if (CodeURI.isUri(revived)) {
|
|
@@ -423,7 +423,7 @@ export class Position {
|
|
|
423
423
|
return false;
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
toJSON():
|
|
426
|
+
toJSON(): unknown {
|
|
427
427
|
return { line: this.line, character: this.character };
|
|
428
428
|
}
|
|
429
429
|
}
|
|
@@ -546,19 +546,17 @@ export class Range {
|
|
|
546
546
|
return new Range(start, end);
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
-
|
|
550
|
-
static isRange(thing: any): thing is theia.Range {
|
|
549
|
+
static isRange(thing: unknown): thing is theia.Range {
|
|
551
550
|
if (thing instanceof Range) {
|
|
552
551
|
return true;
|
|
553
552
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
&& Position.isPosition((<Range>thing).end);
|
|
553
|
+
const range = thing as theia.Range;
|
|
554
|
+
return !!thing && typeof thing === 'object'
|
|
555
|
+
&& Position.isPosition(range.start)
|
|
556
|
+
&& Position.isPosition(range.end);
|
|
559
557
|
}
|
|
560
558
|
|
|
561
|
-
toJSON():
|
|
559
|
+
toJSON(): unknown {
|
|
562
560
|
return [this.start, this.end];
|
|
563
561
|
}
|
|
564
562
|
}
|
|
@@ -1119,6 +1117,24 @@ export class Hover {
|
|
|
1119
1117
|
}
|
|
1120
1118
|
}
|
|
1121
1119
|
|
|
1120
|
+
@es5ClassCompat
|
|
1121
|
+
export class EvaluatableExpression {
|
|
1122
|
+
|
|
1123
|
+
public range: Range;
|
|
1124
|
+
public expression?: string;
|
|
1125
|
+
|
|
1126
|
+
constructor(
|
|
1127
|
+
range: Range,
|
|
1128
|
+
expression?: string
|
|
1129
|
+
) {
|
|
1130
|
+
if (!range) {
|
|
1131
|
+
illegalArgument('range must be defined');
|
|
1132
|
+
}
|
|
1133
|
+
this.range = range;
|
|
1134
|
+
this.expression = expression;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1122
1138
|
export enum DocumentHighlightKind {
|
|
1123
1139
|
Text = 0,
|
|
1124
1140
|
Read = 1,
|
|
@@ -1618,8 +1634,8 @@ export class FileSystemError extends Error {
|
|
|
1618
1634
|
|
|
1619
1635
|
// workaround when extending builtin objects and when compiling to ES5, see:
|
|
1620
1636
|
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
1621
|
-
if (typeof
|
|
1622
|
-
|
|
1637
|
+
if (typeof Object.setPrototypeOf === 'function') {
|
|
1638
|
+
Object.setPrototypeOf(this, FileSystemError.prototype);
|
|
1623
1639
|
}
|
|
1624
1640
|
|
|
1625
1641
|
if (typeof Error.captureStackTrace === 'function' && typeof terminator === 'function') {
|
|
@@ -2537,7 +2553,7 @@ export class SemanticTokensLegend {
|
|
|
2537
2553
|
}
|
|
2538
2554
|
}
|
|
2539
2555
|
|
|
2540
|
-
function isStrArrayOrUndefined(arg:
|
|
2556
|
+
function isStrArrayOrUndefined(arg: unknown): arg is string[] | undefined {
|
|
2541
2557
|
return ((typeof arg === 'undefined') || (Array.isArray(arg) && arg.every(e => typeof e === 'string')));
|
|
2542
2558
|
}
|
|
2543
2559
|
|
|
@@ -2575,7 +2591,7 @@ export class SemanticTokensBuilder {
|
|
|
2575
2591
|
|
|
2576
2592
|
public push(line: number, char: number, length: number, tokenType: number, tokenModifiers?: number): void;
|
|
2577
2593
|
public push(range: Range, tokenType: string, tokenModifiers?: string[]): void;
|
|
2578
|
-
public push(arg0:
|
|
2594
|
+
public push(arg0: number | Range, arg1: number | string, arg2?: number | string[], arg3?: number, arg4?: number): void {
|
|
2579
2595
|
if (typeof arg0 === 'number' && typeof arg1 === 'number' && typeof arg2 === 'number' && typeof arg3 === 'number' &&
|
|
2580
2596
|
(typeof arg4 === 'number' || typeof arg4 === 'undefined')) {
|
|
2581
2597
|
if (typeof arg4 === 'undefined') {
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { WorkspaceExtImpl } from '../workspace';
|
|
2
|
-
import { URI } from '@theia/core/shared/vscode-uri';
|
|
3
|
-
export declare class Configuration {
|
|
4
|
-
private defaultConfiguration;
|
|
5
|
-
private userConfiguration;
|
|
6
|
-
private workspaceConfiguration;
|
|
7
|
-
private folderConfigurations;
|
|
8
|
-
private combinedConfig;
|
|
9
|
-
private folderCombinedConfigs;
|
|
10
|
-
constructor(defaultConfiguration: ConfigurationModel, userConfiguration: ConfigurationModel, workspaceConfiguration?: ConfigurationModel, folderConfigurations?: {
|
|
11
|
-
[resource: string]: ConfigurationModel;
|
|
12
|
-
});
|
|
13
|
-
getValue(section: string | undefined, workspace: WorkspaceExtImpl, resource?: URI): any;
|
|
14
|
-
inspect<C>(key: string, workspace: WorkspaceExtImpl, resource?: URI): {
|
|
15
|
-
default: C;
|
|
16
|
-
user: C;
|
|
17
|
-
workspace: C | undefined;
|
|
18
|
-
workspaceFolder: C | undefined;
|
|
19
|
-
value: C;
|
|
20
|
-
};
|
|
21
|
-
private getCombinedResourceConfig;
|
|
22
|
-
private getCombinedConfig;
|
|
23
|
-
private getFolderCombinedConfig;
|
|
24
|
-
private getFolderResourceConfig;
|
|
25
|
-
}
|
|
26
|
-
export declare class ConfigurationModel {
|
|
27
|
-
private contents;
|
|
28
|
-
private keys;
|
|
29
|
-
constructor(contents?: any, keys?: string[]);
|
|
30
|
-
getValue(section?: string): any;
|
|
31
|
-
merge(...others: ConfigurationModel[]): ConfigurationModel;
|
|
32
|
-
private mergeContents;
|
|
33
|
-
private mergeKeys;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/plugin/preferences/configuration.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAIpD,qBAAa,aAAa;IAMlB,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,oBAAoB;IAPhC,OAAO,CAAC,cAAc,CAAiC;IACvD,OAAO,CAAC,qBAAqB,CAAkD;gBAGnE,oBAAoB,EAAE,kBAAkB,EACxC,iBAAiB,EAAE,kBAAkB,EACrC,sBAAsB,GAAE,kBAA6C,EACrE,oBAAoB,GAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAAA;KAAO;IAGjF,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG;IAIvF,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG;QAClE,OAAO,EAAE,CAAC,CAAC;QACX,IAAI,EAAE,CAAC,CAAC;QACR,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC;QACzB,eAAe,EAAE,CAAC,GAAG,SAAS,CAAC;QAC/B,KAAK,EAAE,CAAC,CAAC;KACZ;IAYD,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,uBAAuB;CAYlC;AAED,qBAAa,kBAAkB;IAGvB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,IAAI;gBADJ,QAAQ,GAAE,GAAyB,EACnC,IAAI,GAAE,MAAM,EAAO;IAG/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG;IAgB/B,KAAK,CAAC,GAAG,MAAM,EAAE,kBAAkB,EAAE,GAAG,kBAAkB;IAW1D,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,SAAS;CAQpB"}
|