@theia/plugin-ext 1.29.0-next.6 → 1.29.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.
Files changed (143) 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 +16 -16
  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/authentication-main.d.ts +3 -6
  12. package/lib/main/browser/authentication-main.d.ts.map +1 -1
  13. package/lib/main/browser/authentication-main.js +16 -37
  14. package/lib/main/browser/authentication-main.js.map +1 -1
  15. package/lib/main/browser/comments/comment-thread-widget.d.ts +2 -0
  16. package/lib/main/browser/comments/comment-thread-widget.d.ts.map +1 -1
  17. package/lib/main/browser/comments/comment-thread-widget.js +4 -3
  18. package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
  19. package/lib/main/browser/debug/debug-main.d.ts +1 -1
  20. package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
  21. package/lib/main/browser/debug/debug-main.js +20 -10
  22. package/lib/main/browser/debug/debug-main.js.map +1 -1
  23. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts +4 -4
  24. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts.map +1 -1
  25. package/lib/main/browser/debug/plugin-debug-session-factory.js.map +1 -1
  26. package/lib/main/browser/languages-main.d.ts +6 -1
  27. package/lib/main/browser/languages-main.d.ts.map +1 -1
  28. package/lib/main/browser/languages-main.js +15 -1
  29. package/lib/main/browser/languages-main.js.map +1 -1
  30. package/lib/main/browser/plugin-ext-frontend-module.d.ts +1 -0
  31. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  32. package/lib/main/browser/plugin-ext-frontend-module.js +1 -0
  33. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  34. package/lib/main/browser/theme-icon-override.d.ts +2 -0
  35. package/lib/main/browser/theme-icon-override.d.ts.map +1 -0
  36. package/lib/main/browser/theme-icon-override.js +217 -0
  37. package/lib/main/browser/theme-icon-override.js.map +1 -0
  38. package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
  39. package/lib/main/browser/view/plugin-view-registry.js +0 -1
  40. package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
  41. package/lib/main/browser/view/plugin-view-widget.d.ts +9 -8
  42. package/lib/main/browser/view/plugin-view-widget.d.ts.map +1 -1
  43. package/lib/main/browser/view/plugin-view-widget.js +7 -4
  44. package/lib/main/browser/view/plugin-view-widget.js.map +1 -1
  45. package/lib/main/browser/view/tree-view-decorator-service.d.ts +1 -1
  46. package/lib/main/browser/view/tree-view-decorator-service.d.ts.map +1 -1
  47. package/lib/main/browser/view/tree-view-decorator-service.js +1 -1
  48. package/lib/main/browser/view/tree-view-decorator-service.js.map +1 -1
  49. package/lib/main/node/plugin-ext-backend-module.d.ts +1 -1
  50. package/lib/main/node/plugin-ext-backend-module.d.ts.map +1 -1
  51. package/lib/main/node/plugin-ext-backend-module.js +4 -1
  52. package/lib/main/node/plugin-ext-backend-module.js.map +1 -1
  53. package/lib/main/node/plugin-localization-backend-contribution.d.ts +10 -0
  54. package/lib/main/node/plugin-localization-backend-contribution.d.ts.map +1 -0
  55. package/lib/main/node/plugin-localization-backend-contribution.js +59 -0
  56. package/lib/main/node/plugin-localization-backend-contribution.js.map +1 -0
  57. package/lib/plugin/authentication-ext.d.ts +1 -11
  58. package/lib/plugin/authentication-ext.d.ts.map +1 -1
  59. package/lib/plugin/authentication-ext.js +3 -55
  60. package/lib/plugin/authentication-ext.js.map +1 -1
  61. package/lib/plugin/languages/code-action.d.ts.map +1 -1
  62. package/lib/plugin/languages/code-action.js +8 -9
  63. package/lib/plugin/languages/code-action.js.map +1 -1
  64. package/lib/plugin/languages/document-highlight.d.ts.map +1 -1
  65. package/lib/plugin/languages/document-highlight.js +0 -1
  66. package/lib/plugin/languages/document-highlight.js.map +1 -1
  67. package/lib/plugin/languages/evaluatable-expression.d.ts +12 -0
  68. package/lib/plugin/languages/evaluatable-expression.d.ts.map +1 -0
  69. package/lib/plugin/languages/evaluatable-expression.js +41 -0
  70. package/lib/plugin/languages/evaluatable-expression.js.map +1 -0
  71. package/lib/plugin/languages/util.d.ts +2 -2
  72. package/lib/plugin/languages/util.d.ts.map +1 -1
  73. package/lib/plugin/languages/util.js +0 -2
  74. package/lib/plugin/languages/util.js.map +1 -1
  75. package/lib/plugin/languages.d.ts +3 -1
  76. package/lib/plugin/languages.d.ts.map +1 -1
  77. package/lib/plugin/languages.js +11 -0
  78. package/lib/plugin/languages.js.map +1 -1
  79. package/lib/plugin/plugin-context.d.ts.map +1 -1
  80. package/lib/plugin/plugin-context.js +7 -35
  81. package/lib/plugin/plugin-context.js.map +1 -1
  82. package/lib/plugin/plugin-storage.d.ts +1 -0
  83. package/lib/plugin/plugin-storage.d.ts.map +1 -1
  84. package/lib/plugin/plugin-storage.js +3 -0
  85. package/lib/plugin/plugin-storage.js.map +1 -1
  86. package/lib/plugin/preference-registry.d.ts.map +1 -1
  87. package/lib/plugin/preference-registry.js +5 -0
  88. package/lib/plugin/preference-registry.js.map +1 -1
  89. package/lib/plugin/preference-registry.spec.js +44 -1
  90. package/lib/plugin/preference-registry.spec.js.map +1 -1
  91. package/lib/plugin/quick-open.d.ts +5 -1
  92. package/lib/plugin/quick-open.d.ts.map +1 -1
  93. package/lib/plugin/quick-open.js +27 -4
  94. package/lib/plugin/quick-open.js.map +1 -1
  95. package/lib/plugin/type-converters.d.ts +7 -6
  96. package/lib/plugin/type-converters.d.ts.map +1 -1
  97. package/lib/plugin/type-converters.js +54 -55
  98. package/lib/plugin/type-converters.js.map +1 -1
  99. package/lib/plugin/types-impl.d.ts +13 -3
  100. package/lib/plugin/types-impl.d.ts.map +1 -1
  101. package/lib/plugin/types-impl.js +28 -10
  102. package/lib/plugin/types-impl.js.map +1 -1
  103. package/lib/plugin/workspace.d.ts.map +1 -1
  104. package/lib/plugin/workspace.js +6 -1
  105. package/lib/plugin/workspace.js.map +1 -1
  106. package/lib/plugin-ext-backend-electron-module.js +2 -2
  107. package/lib/plugin-ext-backend-electron-module.js.map +1 -1
  108. package/lib/plugin-ext-backend-module.js +2 -2
  109. package/lib/plugin-ext-backend-module.js.map +1 -1
  110. package/package.json +26 -26
  111. package/src/common/plugin-api-rpc-model.ts +10 -0
  112. package/src/common/plugin-api-rpc.ts +13 -15
  113. package/src/common/rpc-protocol.ts +5 -5
  114. package/src/main/browser/authentication-main.ts +17 -42
  115. package/src/main/browser/comments/comment-thread-widget.tsx +5 -3
  116. package/src/main/browser/debug/debug-main.ts +20 -12
  117. package/src/main/browser/debug/plugin-debug-session-factory.ts +3 -3
  118. package/src/main/browser/languages-main.ts +23 -1
  119. package/src/main/browser/plugin-ext-frontend-module.ts +1 -0
  120. package/src/main/browser/style/tree.css +2 -0
  121. package/src/main/browser/theme-icon-override.ts +221 -0
  122. package/src/main/browser/view/plugin-view-registry.ts +0 -1
  123. package/src/main/browser/view/plugin-view-widget.ts +14 -11
  124. package/src/main/browser/view/tree-view-decorator-service.ts +2 -2
  125. package/src/main/node/plugin-ext-backend-module.ts +6 -1
  126. package/src/main/node/plugin-localization-backend-contribution.ts +42 -0
  127. package/src/plugin/authentication-ext.ts +3 -70
  128. package/src/plugin/debug/debug-ext.ts +1 -1
  129. package/src/plugin/languages/code-action.ts +9 -12
  130. package/src/plugin/languages/document-highlight.ts +1 -2
  131. package/src/plugin/languages/evaluatable-expression.ts +47 -0
  132. package/src/plugin/languages/util.ts +2 -4
  133. package/src/plugin/languages.ts +15 -0
  134. package/src/plugin/plugin-context.ts +12 -41
  135. package/src/plugin/plugin-storage.ts +4 -0
  136. package/src/plugin/preference-registry.spec.ts +45 -1
  137. package/src/plugin/preference-registry.ts +5 -0
  138. package/src/plugin/quick-open.ts +32 -6
  139. package/src/plugin/type-converters.ts +58 -59
  140. package/src/plugin/types-impl.ts +36 -14
  141. package/src/plugin/workspace.ts +5 -1
  142. package/src/plugin-ext-backend-electron-module.ts +2 -2
  143. package/src/plugin-ext-backend-module.ts +2 -2
@@ -62,11 +62,13 @@ import {
62
62
  CallHierarchyIncomingCall,
63
63
  CallHierarchyOutgoingCall,
64
64
  LinkedEditingRanges,
65
+ EvaluatableExpression
65
66
  } from '../common/plugin-api-rpc-model';
66
67
  import { CompletionAdapter } from './languages/completion';
67
68
  import { Diagnostics } from './languages/diagnostics';
68
69
  import { SignatureHelpAdapter } from './languages/signature';
69
70
  import { HoverAdapter } from './languages/hover';
71
+ import { EvaluatableExpressionAdapter } from './languages/evaluatable-expression';
70
72
  import { DocumentHighlightAdapter } from './languages/document-highlight';
71
73
  import { DocumentFormattingAdapter } from './languages/document-formatting';
72
74
  import { RangeFormattingAdapter } from './languages/range-formatting';
@@ -100,6 +102,7 @@ import { serializeEnterRules, serializeIndentation, serializeRegExp } from './la
100
102
  type Adapter = CompletionAdapter |
101
103
  SignatureHelpAdapter |
102
104
  HoverAdapter |
105
+ EvaluatableExpressionAdapter |
103
106
  DocumentHighlightAdapter |
104
107
  DocumentFormattingAdapter |
105
108
  RangeFormattingAdapter |
@@ -350,6 +353,18 @@ export class LanguagesExtImpl implements LanguagesExt {
350
353
  }
351
354
  // ### Hover Provider end
352
355
 
356
+ // ### EvaluatableExpression Provider begin
357
+ registerEvaluatableExpressionProvider(selector: theia.DocumentSelector, provider: theia.EvaluatableExpressionProvider, pluginInfo: PluginInfo): theia.Disposable {
358
+ const callId = this.addNewAdapter(new EvaluatableExpressionAdapter(provider, this.documents));
359
+ this.proxy.$registerEvaluatableExpressionProvider(callId, pluginInfo, this.transformDocumentSelector(selector));
360
+ return this.createDisposable(callId);
361
+ }
362
+
363
+ $provideEvaluatableExpression(handle: number, resource: UriComponents, position: Position, token: theia.CancellationToken): Promise<EvaluatableExpression | undefined> {
364
+ return this.withAdapter(handle, EvaluatableExpressionAdapter, adapter => adapter.provideEvaluatableExpression(URI.revive(resource), position, token), undefined);
365
+ }
366
+ // ### EvaluatableExpression Provider end
367
+
353
368
  // ### Document Highlight Provider begin
354
369
  registerDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.DocumentHighlightProvider, pluginInfo: PluginInfo): theia.Disposable {
355
370
  const callId = this.addNewAdapter(new DocumentHighlightAdapter(provider, this.documents));
@@ -78,6 +78,7 @@ import {
78
78
  SignatureHelp,
79
79
  SignatureHelpTriggerKind,
80
80
  Hover,
81
+ EvaluatableExpression,
81
82
  DocumentHighlightKind,
82
83
  DocumentHighlight,
83
84
  DocumentLink,
@@ -143,7 +144,8 @@ import {
143
144
  ExtensionMode,
144
145
  LinkedEditingRanges,
145
146
  LanguageStatusSeverity,
146
- TextDocumentChangeReason
147
+ TextDocumentChangeReason,
148
+ InputBoxValidationSeverity
147
149
  } from './types-impl';
148
150
  import { AuthenticationExtImpl } from './authentication-ext';
149
151
  import { SymbolKind } from '../common/plugin-api-rpc-model';
@@ -223,50 +225,14 @@ export function createAPIFactory(
223
225
 
224
226
  return function (plugin: InternalPlugin): typeof theia {
225
227
  const authentication: typeof theia.authentication = {
226
- // support older (< 1.53.0) and newer version of authentication provider registration
227
- registerAuthenticationProvider(
228
- id: string | theia.AuthenticationProvider, label?: string, provider?: theia.AuthenticationProvider, options?: theia.AuthenticationProviderOptions):
229
- theia.Disposable {
230
- // collect registration data based on registration type: new (all parameters given) vs old (data stored in provider)
231
- const isNewRegistration = typeof id === 'string';
232
- const regProvider = isNewRegistration ? provider! : id;
233
- const regId = isNewRegistration ? id : regProvider.id;
234
- const regLabel = isNewRegistration ? label! : regProvider.label;
235
- const regOptions = isNewRegistration ? options : { supportsMultipleAccounts: regProvider.supportsMultipleAccounts };
236
-
237
- // ensure that all methods of the new AuthenticationProvider are available or delegate otherwise
238
- if (!regProvider['createSession']) {
239
- regProvider['createSession'] = (scopes: string[]) => regProvider.login(scopes);
240
- }
241
- if (!regProvider['removeSession']) {
242
- regProvider['removeSession'] = (sessionId: string) => regProvider.logout(sessionId);
243
- }
244
- return authenticationExt.registerAuthenticationProvider(regId, regLabel, regProvider, regOptions);
245
- },
246
- get onDidChangeAuthenticationProviders(): theia.Event<theia.AuthenticationProvidersChangeEvent> {
247
- return authenticationExt.onDidChangeAuthenticationProviders;
248
- },
249
- getProviderIds(): Thenable<ReadonlyArray<string>> {
250
- return Promise.resolve(authenticationExt.providerIds);
251
- },
252
- get providerIds(): string[] {
253
- return authenticationExt.providerIds;
254
- },
255
- get providers(): ReadonlyArray<theia.AuthenticationProviderInformation> {
256
- 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);
257
230
  },
258
231
  getSession(providerId: string, scopes: string[], options: theia.AuthenticationGetSessionOptions) {
259
232
  return authenticationExt.getSession(plugin, providerId, scopes, options as any);
260
233
  },
261
- logout(providerId: string, sessionId: string): Thenable<void> {
262
- return authenticationExt.logout(providerId, sessionId);
263
- },
264
234
  get onDidChangeSessions(): theia.Event<theia.AuthenticationSessionsChangeEvent> {
265
235
  return authenticationExt.onDidChangeSessions;
266
- },
267
- async hasSession(providerId: string, scopes: readonly string[]): Promise<boolean> {
268
- const session = await authenticationExt.getSession(plugin, providerId, scopes, { silent: true });
269
- return !!session;
270
236
  }
271
237
  };
272
238
  const commands: typeof theia.commands = {
@@ -391,7 +357,7 @@ export function createAPIFactory(
391
357
  }
392
358
  },
393
359
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
394
- showQuickPick(items: any, options: theia.QuickPickOptions, token?: theia.CancellationToken): any {
360
+ showQuickPick(items: any, options?: theia.QuickPickOptions, token?: theia.CancellationToken): any {
395
361
  return quickOpenExt.showQuickPick(items, options, token);
396
362
  },
397
363
  createQuickPick<T extends QuickPickItem>(): QuickPick<T> {
@@ -731,6 +697,9 @@ export function createAPIFactory(
731
697
  registerHoverProvider(selector: theia.DocumentSelector, provider: theia.HoverProvider): theia.Disposable {
732
698
  return languagesExt.registerHoverProvider(selector, provider, pluginToPluginInfo(plugin));
733
699
  },
700
+ registerEvaluatableExpressionProvider(selector: theia.DocumentSelector, provider: theia.EvaluatableExpressionProvider): theia.Disposable {
701
+ return languagesExt.registerEvaluatableExpressionProvider(selector, provider, pluginToPluginInfo(plugin));
702
+ },
734
703
  registerDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.DocumentHighlightProvider): theia.Disposable {
735
704
  return languagesExt.registerDocumentHighlightProvider(selector, provider, pluginToPluginInfo(plugin));
736
705
  },
@@ -991,6 +960,7 @@ export function createAPIFactory(
991
960
  SignatureHelp,
992
961
  SignatureHelpTriggerKind,
993
962
  Hover,
963
+ EvaluatableExpression,
994
964
  DocumentHighlightKind,
995
965
  DocumentHighlight,
996
966
  DocumentLink,
@@ -1056,7 +1026,8 @@ export function createAPIFactory(
1056
1026
  FileDecoration,
1057
1027
  CancellationError,
1058
1028
  ExtensionMode,
1059
- LinkedEditingRanges
1029
+ LinkedEditingRanges,
1030
+ InputBoxValidationSeverity
1060
1031
  };
1061
1032
  };
1062
1033
  }
@@ -38,6 +38,10 @@ export class Memento implements theia.Memento {
38
38
  }
39
39
  }
40
40
 
41
+ keys(): string[] {
42
+ return Object.entries(this.cache).filter(([, value]) => value !== undefined).map(([key]) => key);
43
+ }
44
+
41
45
  get<T>(key: string): T | undefined;
42
46
  get<T>(key: string, defaultValue: T): T;
43
47
  get<T>(key: string, defaultValue?: T): T | undefined {
@@ -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 {
@@ -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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
622
- export function isModelLocation(thing: any): thing is model.Location {
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 (('scheme' in thing) && typeof thing.scheme === 'string') &&
647
- (('path' in thing) && typeof thing.path === 'string') &&
648
- (('query' in thing) && typeof thing.query === 'string') &&
649
- (('fragment' in thing) && typeof thing.fragment === 'string');
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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
653
- export function isModelCallHierarchyItem(thing: any): thing is model.CallHierarchyItem {
654
- if (!thing) {
655
- return false;
656
- }
657
- return isModelRange(thing.range)
658
- && isModelRange(thing.selectionRange)
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 isModelCallHierarchyIncomingCall(thing: any): thing is model.CallHierarchyIncomingCall {
665
- if (!thing) {
666
- return false;
667
- }
668
- const maybeIncomingCall = thing as model.CallHierarchyIncomingCall;
669
- return 'from' in maybeIncomingCall && 'fromRanges' in maybeIncomingCall && isModelCallHierarchyItem(maybeIncomingCall.from);
670
- }
671
-
672
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
673
- export function isModelCallHierarchyOutgoingCall(thing: any): thing is model.CallHierarchyOutgoingCall {
674
- if (!thing) {
675
- return false;
676
- }
677
- const maybeOutgoingCall = thing as model.CallHierarchyOutgoingCall;
678
- 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);
679
678
  }
680
679
 
681
680
  export function toLocation(value: model.Location): types.Location {
@@ -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(): any {
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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
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
- if (!thing) {
555
- return false;
556
- }
557
- return Position.isPosition((<Range>thing).start)
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(): any {
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 (<any>Object).setPrototypeOf === 'function') {
1622
- (<any>Object).setPrototypeOf(this, FileSystemError.prototype);
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: any): arg is string[] | undefined {
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: any, arg1: any, arg2: any, arg3?: any, arg4?: any): void {
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') {
@@ -2756,4 +2772,10 @@ export class SemanticTokensEdits {
2756
2772
  }
2757
2773
  }
2758
2774
 
2775
+ export enum InputBoxValidationSeverity {
2776
+ Info = 1,
2777
+ Warning = 2,
2778
+ Error = 3
2779
+ }
2780
+
2759
2781
  // #endregion
@@ -243,8 +243,12 @@ export class WorkspaceExtImpl implements WorkspaceExt {
243
243
  // `file` and `untitled` schemas are reserved by `workspace.openTextDocument` API:
244
244
  // `file`-scheme for opening a file
245
245
  // `untitled`-scheme for opening a new file that should be saved
246
- if (scheme === Schemes.file || scheme === Schemes.untitled || this.documentContentProviders.has(scheme)) {
246
+ if (scheme === Schemes.file || scheme === Schemes.untitled) {
247
247
  throw new Error(`Text Content Document Provider for scheme '${scheme}' is already registered`);
248
+ } else if (this.documentContentProviders.has(scheme)) {
249
+ // TODO: we should be able to handle multiple registrations, but for now we should ensure that it doesn't crash plugin activation.
250
+ console.warn(`Repeat registration of TextContentDocumentProvider for scheme '${scheme}'. This registration will be ignored.`);
251
+ return { dispose: () => { } };
248
252
  }
249
253
 
250
254
  this.documentContentProviders.set(scheme, provider);
@@ -18,7 +18,7 @@ import { ContainerModule } from '@theia/core/shared/inversify';
18
18
  import { bindElectronBackend } from './hosted/node-electron/plugin-ext-hosted-electron-backend-module';
19
19
  import { bindMainBackend } from './main/node/plugin-ext-backend-module';
20
20
 
21
- export default new ContainerModule(bind => {
22
- bindMainBackend(bind);
21
+ export default new ContainerModule((bind, unbind, isBound, rebind) => {
22
+ bindMainBackend(bind, unbind, isBound, rebind);
23
23
  bindElectronBackend(bind);
24
24
  });
@@ -18,7 +18,7 @@ import { ContainerModule } from '@theia/core/shared/inversify';
18
18
  import { bindHostedBackend } from './hosted/node/plugin-ext-hosted-backend-module';
19
19
  import { bindMainBackend } from './main/node/plugin-ext-backend-module';
20
20
 
21
- export default new ContainerModule(bind => {
22
- bindMainBackend(bind);
21
+ export default new ContainerModule((bind, unbind, isBound, rebind) => {
22
+ bindMainBackend(bind, unbind, isBound, rebind);
23
23
  bindHostedBackend(bind);
24
24
  });