@theia/plugin-ext 1.29.0-next.9 → 1.29.1

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 (119) hide show
  1. package/lib/common/plugin-api-rpc.d.ts +13 -15
  2. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc.js.map +1 -1
  4. package/lib/common/rpc-protocol.d.ts +1 -1
  5. package/lib/common/rpc-protocol.d.ts.map +1 -1
  6. package/lib/common/rpc-protocol.js +3 -3
  7. package/lib/common/rpc-protocol.js.map +1 -1
  8. package/lib/main/browser/authentication-main.d.ts +3 -6
  9. package/lib/main/browser/authentication-main.d.ts.map +1 -1
  10. package/lib/main/browser/authentication-main.js +16 -37
  11. package/lib/main/browser/authentication-main.js.map +1 -1
  12. package/lib/main/browser/comments/comment-thread-widget.d.ts +2 -0
  13. package/lib/main/browser/comments/comment-thread-widget.d.ts.map +1 -1
  14. package/lib/main/browser/comments/comment-thread-widget.js +4 -3
  15. package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
  16. package/lib/main/browser/debug/debug-main.d.ts +1 -1
  17. package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
  18. package/lib/main/browser/debug/debug-main.js +20 -10
  19. package/lib/main/browser/debug/debug-main.js.map +1 -1
  20. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts +4 -4
  21. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts.map +1 -1
  22. package/lib/main/browser/debug/plugin-debug-session-factory.js.map +1 -1
  23. package/lib/main/browser/plugin-ext-frontend-module.d.ts +1 -0
  24. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  25. package/lib/main/browser/plugin-ext-frontend-module.js +1 -0
  26. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  27. package/lib/main/browser/theme-icon-override.d.ts +2 -0
  28. package/lib/main/browser/theme-icon-override.d.ts.map +1 -0
  29. package/lib/main/browser/theme-icon-override.js +217 -0
  30. package/lib/main/browser/theme-icon-override.js.map +1 -0
  31. package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
  32. package/lib/main/browser/view/plugin-view-registry.js +0 -1
  33. package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
  34. package/lib/main/browser/view/plugin-view-widget.d.ts +9 -8
  35. package/lib/main/browser/view/plugin-view-widget.d.ts.map +1 -1
  36. package/lib/main/browser/view/plugin-view-widget.js +7 -4
  37. package/lib/main/browser/view/plugin-view-widget.js.map +1 -1
  38. package/lib/main/browser/view/tree-view-decorator-service.d.ts +1 -1
  39. package/lib/main/browser/view/tree-view-decorator-service.d.ts.map +1 -1
  40. package/lib/main/browser/view/tree-view-decorator-service.js +1 -1
  41. package/lib/main/browser/view/tree-view-decorator-service.js.map +1 -1
  42. package/lib/main/node/plugin-ext-backend-module.d.ts +1 -1
  43. package/lib/main/node/plugin-ext-backend-module.d.ts.map +1 -1
  44. package/lib/main/node/plugin-ext-backend-module.js +4 -1
  45. package/lib/main/node/plugin-ext-backend-module.js.map +1 -1
  46. package/lib/main/node/plugin-localization-backend-contribution.d.ts +10 -0
  47. package/lib/main/node/plugin-localization-backend-contribution.d.ts.map +1 -0
  48. package/lib/main/node/plugin-localization-backend-contribution.js +59 -0
  49. package/lib/main/node/plugin-localization-backend-contribution.js.map +1 -0
  50. package/lib/plugin/authentication-ext.d.ts +1 -11
  51. package/lib/plugin/authentication-ext.d.ts.map +1 -1
  52. package/lib/plugin/authentication-ext.js +3 -55
  53. package/lib/plugin/authentication-ext.js.map +1 -1
  54. package/lib/plugin/languages/code-action.d.ts.map +1 -1
  55. package/lib/plugin/languages/code-action.js +8 -9
  56. package/lib/plugin/languages/code-action.js.map +1 -1
  57. package/lib/plugin/languages/document-highlight.d.ts.map +1 -1
  58. package/lib/plugin/languages/document-highlight.js +0 -1
  59. package/lib/plugin/languages/document-highlight.js.map +1 -1
  60. package/lib/plugin/languages/util.d.ts +2 -2
  61. package/lib/plugin/languages/util.d.ts.map +1 -1
  62. package/lib/plugin/languages/util.js +0 -2
  63. package/lib/plugin/languages/util.js.map +1 -1
  64. package/lib/plugin/plugin-context.d.ts.map +1 -1
  65. package/lib/plugin/plugin-context.js +3 -35
  66. package/lib/plugin/plugin-context.js.map +1 -1
  67. package/lib/plugin/preference-registry.d.ts.map +1 -1
  68. package/lib/plugin/preference-registry.js +5 -0
  69. package/lib/plugin/preference-registry.js.map +1 -1
  70. package/lib/plugin/preference-registry.spec.js +44 -1
  71. package/lib/plugin/preference-registry.spec.js.map +1 -1
  72. package/lib/plugin/quick-open.d.ts +5 -1
  73. package/lib/plugin/quick-open.d.ts.map +1 -1
  74. package/lib/plugin/quick-open.js +27 -4
  75. package/lib/plugin/quick-open.js.map +1 -1
  76. package/lib/plugin/type-converters.d.ts +6 -6
  77. package/lib/plugin/type-converters.d.ts.map +1 -1
  78. package/lib/plugin/type-converters.js +45 -53
  79. package/lib/plugin/type-converters.js.map +1 -1
  80. package/lib/plugin/types-impl.d.ts +8 -3
  81. package/lib/plugin/types-impl.d.ts.map +1 -1
  82. package/lib/plugin/types-impl.js +12 -8
  83. package/lib/plugin/types-impl.js.map +1 -1
  84. package/lib/plugin/workspace.d.ts.map +1 -1
  85. package/lib/plugin/workspace.js +6 -1
  86. package/lib/plugin/workspace.js.map +1 -1
  87. package/lib/plugin-ext-backend-electron-module.js +2 -2
  88. package/lib/plugin-ext-backend-electron-module.js.map +1 -1
  89. package/lib/plugin-ext-backend-module.js +2 -2
  90. package/lib/plugin-ext-backend-module.js.map +1 -1
  91. package/package.json +26 -26
  92. package/src/common/plugin-api-rpc.ts +10 -15
  93. package/src/common/rpc-protocol.ts +5 -5
  94. package/src/main/browser/authentication-main.ts +17 -42
  95. package/src/main/browser/comments/comment-thread-widget.tsx +5 -3
  96. package/src/main/browser/debug/debug-main.ts +20 -12
  97. package/src/main/browser/debug/plugin-debug-session-factory.ts +3 -3
  98. package/src/main/browser/plugin-ext-frontend-module.ts +1 -0
  99. package/src/main/browser/style/tree.css +2 -0
  100. package/src/main/browser/theme-icon-override.ts +221 -0
  101. package/src/main/browser/view/plugin-view-registry.ts +0 -1
  102. package/src/main/browser/view/plugin-view-widget.ts +14 -11
  103. package/src/main/browser/view/tree-view-decorator-service.ts +2 -2
  104. package/src/main/node/plugin-ext-backend-module.ts +6 -1
  105. package/src/main/node/plugin-localization-backend-contribution.ts +42 -0
  106. package/src/plugin/authentication-ext.ts +3 -70
  107. package/src/plugin/debug/debug-ext.ts +1 -1
  108. package/src/plugin/languages/code-action.ts +9 -12
  109. package/src/plugin/languages/document-highlight.ts +1 -2
  110. package/src/plugin/languages/util.ts +2 -4
  111. package/src/plugin/plugin-context.ts +7 -41
  112. package/src/plugin/preference-registry.spec.ts +45 -1
  113. package/src/plugin/preference-registry.ts +5 -0
  114. package/src/plugin/quick-open.ts +32 -6
  115. package/src/plugin/type-converters.ts +51 -59
  116. package/src/plugin/types-impl.ts +18 -14
  117. package/src/plugin/workspace.ts +5 -1
  118. package/src/plugin-ext-backend-electron-module.ts +2 -2
  119. package/src/plugin-ext-backend-module.ts +2 -2
@@ -0,0 +1,42 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 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 { inject, injectable } from '@theia/core/shared/inversify';
18
+ import { LocalizationBackendContribution } from '@theia/core/lib/node/i18n/localization-backend-contribution';
19
+ import { PluginDeployer } from '../../common/plugin-protocol';
20
+ import { PluginDeployerImpl } from './plugin-deployer-impl';
21
+ import { Deferred } from '@theia/core/lib/common/promise-util';
22
+
23
+ @injectable()
24
+ export class PluginLocalizationBackendContribution extends LocalizationBackendContribution {
25
+ @inject(PluginDeployer)
26
+ protected readonly pluginDeployer: PluginDeployerImpl;
27
+ protected readonly pluginsDeployed = new Deferred();
28
+
29
+ override async initialize(): Promise<void> {
30
+ this.pluginDeployer.onDidDeploy(() => {
31
+ this.pluginsDeployed.resolve();
32
+ });
33
+ await super.initialize();
34
+ }
35
+
36
+ override async waitForInitialization(): Promise<void> {
37
+ await Promise.all([
38
+ super.waitForInitialization(),
39
+ this.pluginsDeployed.promise,
40
+ ]);
41
+ }
42
+ }
@@ -34,13 +34,6 @@ export class AuthenticationExtImpl implements AuthenticationExt {
34
34
  private proxy: AuthenticationMain;
35
35
  private authenticationProviders: Map<string, theia.AuthenticationProvider> = new Map<string, theia.AuthenticationProvider>();
36
36
 
37
- private _providerIds: string[] = [];
38
-
39
- private _providers: theia.AuthenticationProviderInformation[] = [];
40
-
41
- private onDidChangeAuthenticationProvidersEmitter = new Emitter<theia.AuthenticationProvidersChangeEvent>();
42
- readonly onDidChangeAuthenticationProviders: Event<theia.AuthenticationProvidersChangeEvent> = this.onDidChangeAuthenticationProvidersEmitter.event;
43
-
44
37
  private onDidChangeSessionsEmitter = new Emitter<theia.AuthenticationSessionsChangeEvent>();
45
38
  readonly onDidChangeSessions: Event<theia.AuthenticationSessionsChangeEvent> = this.onDidChangeSessionsEmitter.event;
46
39
 
@@ -48,18 +41,6 @@ export class AuthenticationExtImpl implements AuthenticationExt {
48
41
  this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.AUTHENTICATION_MAIN);
49
42
  }
50
43
 
51
- getProviderIds(): Promise<ReadonlyArray<string>> {
52
- return this.proxy.$getProviderIds();
53
- }
54
-
55
- get providerIds(): string[] {
56
- return this._providerIds;
57
- }
58
-
59
- get providers(): ReadonlyArray<theia.AuthenticationProviderInformation> {
60
- return Object.freeze(this._providers.slice());
61
- }
62
-
63
44
  async getSession(requestingExtension: InternalPlugin, providerId: string, scopes: readonly string[],
64
45
  options: theia.AuthenticationGetSessionOptions & ({ createIfNone: true } | { forceNewSession: true } | { forceNewSession: { detail: string } })):
65
46
  Promise<theia.AuthenticationSession>;
@@ -76,29 +57,14 @@ export class AuthenticationExtImpl implements AuthenticationExt {
76
57
  return this.proxy.$getSession(providerId, scopes, extensionId, extensionName, options);
77
58
  }
78
59
 
79
- async logout(providerId: string, sessionId: string): Promise<void> {
80
- return this.proxy.$removeSession(providerId, sessionId);
81
- }
82
-
83
60
  registerAuthenticationProvider(id: string, label: string, provider: theia.AuthenticationProvider, options?: theia.AuthenticationProviderOptions): theia.Disposable {
84
61
  if (this.authenticationProviders.get(id)) {
85
62
  throw new Error(`An authentication provider with id '${id}' is already registered.`);
86
63
  }
87
64
 
88
65
  this.authenticationProviders.set(id, provider);
89
- if (this._providerIds.indexOf(id) === -1) {
90
- this._providerIds.push(id);
91
- }
92
-
93
- if (!this._providers.find(p => p.id === id)) {
94
- this._providers.push({
95
- id,
96
- label
97
- });
98
- }
99
-
100
66
  const listener = provider.onDidChangeSessions(e => {
101
- this.proxy.$sendDidChangeSessions(id, e);
67
+ this.proxy.$onDidChangeSessions(id, e);
102
68
  });
103
69
 
104
70
  this.proxy.$registerAuthenticationProvider(id, label, !!options?.supportsMultipleAccounts);
@@ -106,16 +72,6 @@ export class AuthenticationExtImpl implements AuthenticationExt {
106
72
  return new Disposable(() => {
107
73
  listener.dispose();
108
74
  this.authenticationProviders.delete(id);
109
- const index = this._providerIds.findIndex(pid => id === pid);
110
- if (index > -1) {
111
- this._providerIds.splice(index);
112
- }
113
-
114
- const i = this._providers.findIndex(p => p.id === id);
115
- if (i > -1) {
116
- this._providers.splice(i);
117
- }
118
-
119
75
  this.proxy.$unregisterAuthenticationProvider(id);
120
76
  });
121
77
  }
@@ -163,30 +119,7 @@ export class AuthenticationExtImpl implements AuthenticationExt {
163
119
  throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
164
120
  }
165
121
 
166
- $onDidChangeAuthenticationSessions(id: string, label: string): Promise<void> {
167
- this.onDidChangeSessionsEmitter.fire({ provider: { id, label } });
168
- return Promise.resolve();
169
- }
170
-
171
- async $onDidChangeAuthenticationProviders(added: theia.AuthenticationProviderInformation[], removed: theia.AuthenticationProviderInformation[]): Promise<void> {
172
- added.forEach(id => {
173
- if (this._providers.indexOf(id) === -1) {
174
- this._providers.push(id);
175
- }
176
- });
177
-
178
- removed.forEach(p => {
179
- const index = this._providers.findIndex(provider => provider.id === p.id);
180
- if (index > -1) {
181
- this._providers.splice(index);
182
- }
183
- });
184
-
185
- this.onDidChangeAuthenticationProvidersEmitter.fire({ added, removed });
186
- }
187
-
188
- $setProviders(providers: theia.AuthenticationProviderInformation[]): Promise<void> {
189
- this._providers.push(...providers);
190
- return Promise.resolve(undefined);
122
+ async $onDidChangeAuthenticationSessions(provider: theia.AuthenticationProviderInformation): Promise<void> {
123
+ this.onDidChangeSessionsEmitter.fire({ provider });
191
124
  }
192
125
  }
@@ -31,7 +31,7 @@ import uuid = require('uuid');
31
31
  import { DebugAdapter } from '@theia/debug/lib/common/debug-model';
32
32
  import { PluginDebugAdapterCreator } from './plugin-debug-adapter-creator';
33
33
  import { NodeDebugAdapterCreator } from '../node/debug/plugin-node-debug-adapter-creator';
34
- import { DebugProtocol } from 'vscode-debugprotocol';
34
+ import { DebugProtocol } from '@vscode/debugprotocol';
35
35
 
36
36
  interface ConfigurationProviderRecord {
37
37
  handle: number;
@@ -145,20 +145,17 @@ export class CodeActionAdapter {
145
145
  return this.cacheId++;
146
146
  }
147
147
 
148
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
149
- private static _isCommand(smth: any): smth is theia.Command {
150
- return typeof (<theia.Command>smth).command === 'string';
148
+ private static _isCommand(arg: unknown): arg is theia.Command {
149
+ return !!arg && typeof arg === 'object' && typeof (arg as theia.Command).command === 'string';
151
150
  }
152
151
 
153
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
- private static _isSelection(obj: any): obj is Selection {
155
- return (
156
- obj
157
- && (typeof obj.selectionStartLineNumber === 'number')
158
- && (typeof obj.selectionStartColumn === 'number')
159
- && (typeof obj.positionLineNumber === 'number')
160
- && (typeof obj.positionColumn === 'number')
161
- );
152
+ private static _isSelection(obj: unknown): obj is Selection {
153
+ const selection = obj as Selection;
154
+ return !!obj && typeof obj === 'object'
155
+ && typeof selection.selectionStartLineNumber === 'number'
156
+ && typeof selection.selectionStartColumn === 'number'
157
+ && typeof selection.positionLineNumber === 'number'
158
+ && typeof selection.positionColumn === 'number';
162
159
  }
163
160
 
164
161
  }
@@ -55,8 +55,7 @@ export class DocumentHighlightAdapter {
55
55
  });
56
56
  }
57
57
 
58
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
- private isDocumentHighlightArray(array: any): array is types.DocumentHighlight[] {
58
+ private isDocumentHighlightArray(array: unknown): array is types.DocumentHighlight[] {
60
59
  return Array.isArray(array) && array.length > 0 && array[0] instanceof types.DocumentHighlight;
61
60
  }
62
61
  }
@@ -17,12 +17,10 @@
17
17
  import * as theia from '@theia/plugin';
18
18
  import * as types from '../types-impl';
19
19
 
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- export function isLocationArray(array: any): array is types.Location[] {
20
+ export function isLocationArray(array: unknown): array is types.Location[] {
22
21
  return Array.isArray(array) && array.length > 0 && array[0] instanceof types.Location;
23
22
  }
24
23
 
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- export function isDefinitionLinkArray(array: any): array is theia.DefinitionLink[] {
24
+ export function isDefinitionLinkArray(array: unknown): array is theia.DefinitionLink[] {
27
25
  return Array.isArray(array) && array.length > 0 && array[0].hasOwnProperty('targetUri') && array[0].hasOwnProperty('targetRange');
28
26
  }
@@ -144,7 +144,8 @@ import {
144
144
  ExtensionMode,
145
145
  LinkedEditingRanges,
146
146
  LanguageStatusSeverity,
147
- TextDocumentChangeReason
147
+ TextDocumentChangeReason,
148
+ InputBoxValidationSeverity
148
149
  } from './types-impl';
149
150
  import { AuthenticationExtImpl } from './authentication-ext';
150
151
  import { SymbolKind } from '../common/plugin-api-rpc-model';
@@ -224,50 +225,14 @@ export function createAPIFactory(
224
225
 
225
226
  return function (plugin: InternalPlugin): typeof theia {
226
227
  const authentication: typeof theia.authentication = {
227
- // support older (< 1.53.0) and newer version of authentication provider registration
228
- registerAuthenticationProvider(
229
- id: string | theia.AuthenticationProvider, label?: string, provider?: theia.AuthenticationProvider, options?: theia.AuthenticationProviderOptions):
230
- theia.Disposable {
231
- // collect registration data based on registration type: new (all parameters given) vs old (data stored in provider)
232
- const isNewRegistration = typeof id === 'string';
233
- const regProvider = isNewRegistration ? provider! : id;
234
- const regId = isNewRegistration ? id : regProvider.id;
235
- const regLabel = isNewRegistration ? label! : regProvider.label;
236
- const regOptions = isNewRegistration ? options : { supportsMultipleAccounts: regProvider.supportsMultipleAccounts };
237
-
238
- // ensure that all methods of the new AuthenticationProvider are available or delegate otherwise
239
- if (!regProvider['createSession']) {
240
- regProvider['createSession'] = (scopes: string[]) => regProvider.login(scopes);
241
- }
242
- if (!regProvider['removeSession']) {
243
- regProvider['removeSession'] = (sessionId: string) => regProvider.logout(sessionId);
244
- }
245
- return authenticationExt.registerAuthenticationProvider(regId, regLabel, regProvider, regOptions);
246
- },
247
- get onDidChangeAuthenticationProviders(): theia.Event<theia.AuthenticationProvidersChangeEvent> {
248
- return authenticationExt.onDidChangeAuthenticationProviders;
249
- },
250
- getProviderIds(): Thenable<ReadonlyArray<string>> {
251
- return Promise.resolve(authenticationExt.providerIds);
252
- },
253
- get providerIds(): string[] {
254
- return authenticationExt.providerIds;
255
- },
256
- get providers(): ReadonlyArray<theia.AuthenticationProviderInformation> {
257
- return authenticationExt.providers;
228
+ registerAuthenticationProvider(id: string, label: string, provider: theia.AuthenticationProvider, options?: theia.AuthenticationProviderOptions): theia.Disposable {
229
+ return authenticationExt.registerAuthenticationProvider(id, label, provider, options);
258
230
  },
259
231
  getSession(providerId: string, scopes: string[], options: theia.AuthenticationGetSessionOptions) {
260
232
  return authenticationExt.getSession(plugin, providerId, scopes, options as any);
261
233
  },
262
- logout(providerId: string, sessionId: string): Thenable<void> {
263
- return authenticationExt.logout(providerId, sessionId);
264
- },
265
234
  get onDidChangeSessions(): theia.Event<theia.AuthenticationSessionsChangeEvent> {
266
235
  return authenticationExt.onDidChangeSessions;
267
- },
268
- async hasSession(providerId: string, scopes: readonly string[]): Promise<boolean> {
269
- const session = await authenticationExt.getSession(plugin, providerId, scopes, { silent: true });
270
- return !!session;
271
236
  }
272
237
  };
273
238
  const commands: typeof theia.commands = {
@@ -392,7 +357,7 @@ export function createAPIFactory(
392
357
  }
393
358
  },
394
359
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
395
- showQuickPick(items: any, options: theia.QuickPickOptions, token?: theia.CancellationToken): any {
360
+ showQuickPick(items: any, options?: theia.QuickPickOptions, token?: theia.CancellationToken): any {
396
361
  return quickOpenExt.showQuickPick(items, options, token);
397
362
  },
398
363
  createQuickPick<T extends QuickPickItem>(): QuickPick<T> {
@@ -1061,7 +1026,8 @@ export function createAPIFactory(
1061
1026
  FileDecoration,
1062
1027
  CancellationError,
1063
1028
  ExtensionMode,
1064
- LinkedEditingRanges
1029
+ LinkedEditingRanges,
1030
+ InputBoxValidationSeverity
1065
1031
  };
1066
1032
  };
1067
1033
  }
@@ -112,7 +112,6 @@ describe('PreferenceRegistryExtImpl:', () => {
112
112
  });
113
113
  });
114
114
 
115
- /* eslint-disable no-unused-expressions */
116
115
  describe('toConfigurationChangeEvent', () => {
117
116
  // E.g. deletion of a `tasks.json`.
118
117
  it('Handles deletion of a section', () => {
@@ -252,4 +251,49 @@ describe('PreferenceRegistryExtImpl:', () => {
252
251
  expect(valuesRetrieved.tabSize).equal(4);
253
252
  });
254
253
  });
254
+
255
+ describe('Proxy Behavior', () => {
256
+ const deepConfig = {
257
+ 'python.linting.enabled': true,
258
+ 'python.linting.flake8Args': [],
259
+ 'python.linting.flake8CategorySeverity.E': 'Error',
260
+ 'python.linting.flake8CategorySeverity.F': 'Error',
261
+ 'python.linting.flake8CategorySeverity.W': 'Warning',
262
+ 'python.linting.flake8Enabled': false,
263
+ 'python.linting.flake8Path': 'flake8',
264
+ 'python.linting.ignorePatterns': ['.vscode/*.py', '**/site-packages/**/*.py'],
265
+ 'python.linting.lintOnSave': true,
266
+ 'python.linting.maxNumberOfProblems': 100,
267
+ 'python.linting.banditArgs': [],
268
+ 'python.linting.banditEnabled': false,
269
+ 'python.linting.banditPath': 'bandit',
270
+ 'python.linting.mypyArgs': [
271
+ '--ignore-missing-imports',
272
+ '--follow-imports=silent',
273
+ '--show-column-numbers'
274
+ ],
275
+ 'python.linting.mypyCategorySeverity.error': 'Error',
276
+ 'python.linting.mypyCategorySeverity.note': 'Information',
277
+ 'python.linting.mypyEnabled': false,
278
+ 'python.linting.mypyPath': 'mypy',
279
+ };
280
+ // https://github.com/eclipse-theia/theia/issues/11501
281
+ it("Doesn't violate proxy rules and return a proxy when the underlying object is expected.", () => {
282
+ preferenceRegistryExtImpl.init({
283
+ [PreferenceScope.Default]: deepConfig,
284
+ [PreferenceScope.User]: {},
285
+ [PreferenceScope.Workspace]: {},
286
+ [PreferenceScope.Folder]: {
287
+ [workspaceRoot.toString()]: {},
288
+ }
289
+ });
290
+ const pythonConfig = preferenceRegistryExtImpl.getConfiguration('python', workspaceRoot);
291
+ const lintConfig = pythonConfig.get<Record<string, unknown>>('linting')!;
292
+ const stringDictionary = Object.create(null);
293
+ Object.keys(lintConfig).forEach(key => {
294
+ stringDictionary[key] = lintConfig[key];
295
+ });
296
+ expect(Boolean('Made it this far without throwing an error')).to.be.true;
297
+ });
298
+ });
255
299
  });
@@ -129,6 +129,11 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
129
129
  }
130
130
  return new Proxy(target, {
131
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
+ }
132
137
  if (typeof prop === 'string' && prop.toLowerCase() === 'tojson') {
133
138
  cloneTarget();
134
139
  return () => clonedTarget;
@@ -24,13 +24,14 @@ import { CancellationToken } from '@theia/core/lib/common/cancellation';
24
24
  import { RPCProtocol } from '../common/rpc-protocol';
25
25
  import { Emitter, Event } from '@theia/core/lib/common/event';
26
26
  import { DisposableCollection } from '@theia/core/lib/common/disposable';
27
- import { QuickInputButtons, QuickPickItemKind, ThemeIcon } from './types-impl';
27
+ import { InputBoxValidationSeverity, QuickInputButtons, QuickPickItemKind, ThemeIcon } from './types-impl';
28
28
  import { URI } from '@theia/core/shared/vscode-uri';
29
29
  import * as path from 'path';
30
30
  import { convertToTransferQuickPickItems } from './type-converters';
31
31
  import { PluginPackage } from '../common/plugin-protocol';
32
32
  import { QuickInputButtonHandle } from '@theia/core/lib/browser';
33
33
  import { MaybePromise } from '@theia/core/lib/common/types';
34
+ import Severity from '@theia/monaco-editor-core/esm/vs/base/common/severity';
34
35
 
35
36
  const canceledName = 'Canceled';
36
37
  /**
@@ -65,7 +66,7 @@ export function getDarkIconUri(iconPath: URI | { light: URI; dark: URI; }): URI
65
66
  export class QuickOpenExtImpl implements QuickOpenExt {
66
67
  private proxy: QuickOpenMain;
67
68
  private onDidSelectItem: undefined | ((handle: number) => void);
68
- private validateInputHandler?: (input: string) => MaybePromise<string | null | undefined>;
69
+ private validateInputHandler?: (input: string) => MaybePromise<string | theia.InputBoxValidationMessage | null | undefined>;
69
70
  private _sessions = new Map<number, QuickInputExt>(); // Each quickinput will have a number so that we know where to fire events
70
71
  private _instances = 0;
71
72
 
@@ -155,11 +156,36 @@ export class QuickOpenExtImpl implements QuickOpenExt {
155
156
  return this.proxy.$showInputBox(options, typeof this.validateInputHandler === 'function');
156
157
  }
157
158
 
158
- $validateInput(input: string): Promise<string | null | undefined> | undefined {
159
- if (this.validateInputHandler) {
160
- return Promise.resolve(this.validateInputHandler(input));
159
+ async $validateInput(input: string): Promise<string | { content: string; severity: Severity; } | null | undefined> {
160
+ if (!this.validateInputHandler) {
161
+ return;
162
+ }
163
+
164
+ const result = await this.validateInputHandler(input);
165
+ if (!result || typeof result === 'string') {
166
+ return result;
161
167
  }
162
- return undefined;
168
+
169
+ let severity: Severity;
170
+ switch (result.severity) {
171
+ case InputBoxValidationSeverity.Info:
172
+ severity = Severity.Info;
173
+ break;
174
+ case InputBoxValidationSeverity.Warning:
175
+ severity = Severity.Warning;
176
+ break;
177
+ case InputBoxValidationSeverity.Error:
178
+ severity = Severity.Error;
179
+ break;
180
+ default:
181
+ severity = result.message ? Severity.Error : Severity.Ignore;
182
+ break;
183
+ }
184
+
185
+ return {
186
+ content: result.message,
187
+ severity
188
+ };
163
189
  }
164
190
 
165
191
  // ---- QuickInput
@@ -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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
141
- function isDecorationOptions(something: any): something is theia.DecorationOptions {
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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
- function isCodeblock(thing: any): thing is Codeblock {
187
- return thing && typeof thing === 'object'
188
- && typeof (<Codeblock>thing).language === 'string'
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 {
@@ -625,64 +623,58 @@ export function toSymbolTag(kind: model.SymbolTag): types.SymbolTag {
625
623
  }
626
624
  }
627
625
 
628
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
629
- export function isModelLocation(thing: any): thing is model.Location {
630
- if (!thing) {
631
- return false;
632
- }
633
- return isModelRange((<model.Location>thing).range) &&
634
- isUriComponents((<model.Location>thing).uri);
635
- }
636
-
637
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
638
- export function isModelRange(thing: any): thing is model.Range {
639
- if (!thing) {
626
+ export function isModelLocation(arg: unknown): arg is model.Location {
627
+ if (!arg) {
640
628
  return false;
641
629
  }
642
- return (('startLineNumber' in thing) && typeof thing.startLineNumber === 'number') &&
643
- (('startColumn' in thing) && typeof thing.startColumn === 'number') &&
644
- (('endLineNumber' in thing) && typeof thing.endLineNumber === 'number') &&
645
- (('endColumn' in thing) && typeof thing.endColumn === 'number');
630
+ return !!arg &&
631
+ typeof arg === 'object' &&
632
+ isModelRange((arg as model.Location).range) &&
633
+ isUriComponents((arg as model.Location).uri);
646
634
  }
647
635
 
648
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
649
- export function isUriComponents(thing: any): thing is UriComponents {
650
- if (!thing) {
651
- return false;
652
- }
653
- return (('scheme' in thing) && typeof thing.scheme === 'string') &&
654
- (('path' in thing) && typeof thing.path === 'string') &&
655
- (('query' in thing) && typeof thing.query === 'string') &&
656
- (('fragment' in thing) && typeof thing.fragment === 'string');
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';
657
643
  }
658
644
 
659
645
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
660
- export function isModelCallHierarchyItem(thing: any): thing is model.CallHierarchyItem {
661
- if (!thing) {
662
- return false;
663
- }
664
- return isModelRange(thing.range)
665
- && isModelRange(thing.selectionRange)
666
- && isUriComponents(thing.uri)
667
- && !!thing.name;
668
- }
669
-
670
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
671
- export function isModelCallHierarchyIncomingCall(thing: any): thing is model.CallHierarchyIncomingCall {
672
- if (!thing) {
673
- return false;
674
- }
675
- const maybeIncomingCall = thing as model.CallHierarchyIncomingCall;
676
- return 'from' in maybeIncomingCall && 'fromRanges' in maybeIncomingCall && isModelCallHierarchyItem(maybeIncomingCall.from);
677
- }
678
-
679
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
680
- export function isModelCallHierarchyOutgoingCall(thing: any): thing is model.CallHierarchyOutgoingCall {
681
- if (!thing) {
682
- return false;
683
- }
684
- const maybeOutgoingCall = thing as model.CallHierarchyOutgoingCall;
685
- return 'to' in maybeOutgoingCall && 'fromRanges' in maybeOutgoingCall && isModelCallHierarchyItem(maybeOutgoingCall.to);
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);
686
678
  }
687
679
 
688
680
  export function toLocation(value: model.Location): types.Location {