@theia/plugin-ext 1.28.0-next.9 → 1.29.0-next.10

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 (200) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +8 -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 +12 -3
  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/plugin-protocol.d.ts +4 -0
  8. package/lib/common/plugin-protocol.d.ts.map +1 -1
  9. package/lib/common/plugin-protocol.js.map +1 -1
  10. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  11. package/lib/hosted/browser/hosted-plugin.js +4 -2
  12. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  13. package/lib/hosted/browser/worker/worker-env-ext.d.ts +1 -0
  14. package/lib/hosted/browser/worker/worker-env-ext.d.ts.map +1 -1
  15. package/lib/hosted/browser/worker/worker-env-ext.js +3 -0
  16. package/lib/hosted/browser/worker/worker-env-ext.js.map +1 -1
  17. package/lib/hosted/node/scanners/scanner-theia.d.ts +5 -1
  18. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  19. package/lib/hosted/node/scanners/scanner-theia.js +22 -15
  20. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  21. package/lib/main/browser/comments/comment-thread-widget.js +5 -5
  22. package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
  23. package/lib/main/browser/debug/debug-main.d.ts +1 -0
  24. package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
  25. package/lib/main/browser/debug/debug-main.js +10 -0
  26. package/lib/main/browser/debug/debug-main.js.map +1 -1
  27. package/lib/main/browser/languages-main.d.ts +6 -1
  28. package/lib/main/browser/languages-main.d.ts.map +1 -1
  29. package/lib/main/browser/languages-main.js +15 -1
  30. package/lib/main/browser/languages-main.js.map +1 -1
  31. package/lib/main/browser/menus/menus-contribution-handler.d.ts +24 -88
  32. package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
  33. package/lib/main/browser/menus/menus-contribution-handler.js +108 -518
  34. package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
  35. package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts +44 -0
  36. package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts.map +1 -0
  37. package/lib/main/browser/menus/plugin-menu-command-adapter.js +274 -0
  38. package/lib/main/browser/menus/plugin-menu-command-adapter.js.map +1 -0
  39. package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts +18 -0
  40. package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts.map +1 -0
  41. package/lib/main/browser/menus/vscode-theia-menu-mappings.js +88 -0
  42. package/lib/main/browser/menus/vscode-theia-menu-mappings.js.map +1 -0
  43. package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
  44. package/lib/main/browser/plugin-contribution-handler.js +9 -4
  45. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  46. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  47. package/lib/main/browser/plugin-ext-frontend-module.js +4 -3
  48. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  49. package/lib/main/browser/plugin-frontend-contribution.d.ts +0 -2
  50. package/lib/main/browser/plugin-frontend-contribution.d.ts.map +1 -1
  51. package/lib/main/browser/plugin-frontend-contribution.js +0 -8
  52. package/lib/main/browser/plugin-frontend-contribution.js.map +1 -1
  53. package/lib/main/browser/plugin-shared-style.d.ts.map +1 -1
  54. package/lib/main/browser/plugin-shared-style.js +0 -1
  55. package/lib/main/browser/plugin-shared-style.js.map +1 -1
  56. package/lib/main/browser/preference-registry-main.d.ts +4 -3
  57. package/lib/main/browser/preference-registry-main.d.ts.map +1 -1
  58. package/lib/main/browser/preference-registry-main.js +26 -14
  59. package/lib/main/browser/preference-registry-main.js.map +1 -1
  60. package/lib/main/browser/scm-main.d.ts +1 -0
  61. package/lib/main/browser/scm-main.d.ts.map +1 -1
  62. package/lib/main/browser/scm-main.js +7 -0
  63. package/lib/main/browser/scm-main.js.map +1 -1
  64. package/lib/main/browser/view/tree-view-widget.js +2 -2
  65. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  66. package/lib/main/browser/workspace-main.d.ts.map +1 -1
  67. package/lib/main/browser/workspace-main.js +1 -4
  68. package/lib/main/browser/workspace-main.js.map +1 -1
  69. package/lib/main/node/handlers/plugin-theia-file-handler.d.ts +0 -4
  70. package/lib/main/node/handlers/plugin-theia-file-handler.d.ts.map +1 -1
  71. package/lib/main/node/handlers/plugin-theia-file-handler.js +0 -26
  72. package/lib/main/node/handlers/plugin-theia-file-handler.js.map +1 -1
  73. package/lib/main/node/plugin-ext-backend-module.d.ts.map +1 -1
  74. package/lib/main/node/plugin-ext-backend-module.js +0 -2
  75. package/lib/main/node/plugin-ext-backend-module.js.map +1 -1
  76. package/lib/main/node/resolvers/local-plugin-deployer-resolver.d.ts.map +1 -1
  77. package/lib/main/node/resolvers/local-plugin-deployer-resolver.js.map +1 -1
  78. package/lib/plugin/debug/debug-ext.d.ts +3 -1
  79. package/lib/plugin/debug/debug-ext.d.ts.map +1 -1
  80. package/lib/plugin/debug/debug-ext.js +26 -4
  81. package/lib/plugin/debug/debug-ext.js.map +1 -1
  82. package/lib/plugin/debug/plugin-debug-adapter-session.d.ts +1 -0
  83. package/lib/plugin/debug/plugin-debug-adapter-session.d.ts.map +1 -1
  84. package/lib/plugin/debug/plugin-debug-adapter-session.js +3 -0
  85. package/lib/plugin/debug/plugin-debug-adapter-session.js.map +1 -1
  86. package/lib/plugin/env.d.ts +11 -0
  87. package/lib/plugin/env.d.ts.map +1 -1
  88. package/lib/plugin/env.js +20 -0
  89. package/lib/plugin/env.js.map +1 -1
  90. package/lib/plugin/languages/evaluatable-expression.d.ts +12 -0
  91. package/lib/plugin/languages/evaluatable-expression.d.ts.map +1 -0
  92. package/lib/plugin/languages/evaluatable-expression.js +41 -0
  93. package/lib/plugin/languages/evaluatable-expression.js.map +1 -0
  94. package/lib/plugin/languages/signature.d.ts.map +1 -1
  95. package/lib/plugin/languages/signature.js +5 -1
  96. package/lib/plugin/languages/signature.js.map +1 -1
  97. package/lib/plugin/languages.d.ts +3 -1
  98. package/lib/plugin/languages.d.ts.map +1 -1
  99. package/lib/plugin/languages.js +11 -0
  100. package/lib/plugin/languages.js.map +1 -1
  101. package/lib/plugin/node/debug/debug.spec.d.ts +2 -0
  102. package/lib/plugin/node/debug/debug.spec.d.ts.map +1 -0
  103. package/lib/plugin/node/debug/debug.spec.js +68 -0
  104. package/lib/plugin/node/debug/debug.spec.js.map +1 -0
  105. package/lib/plugin/node/env-node-ext.d.ts +3 -0
  106. package/lib/plugin/node/env-node-ext.d.ts.map +1 -1
  107. package/lib/plugin/node/env-node-ext.js +11 -0
  108. package/lib/plugin/node/env-node-ext.js.map +1 -1
  109. package/lib/plugin/plugin-context.d.ts.map +1 -1
  110. package/lib/plugin/plugin-context.js +14 -0
  111. package/lib/plugin/plugin-context.js.map +1 -1
  112. package/lib/plugin/plugin-manager.d.ts.map +1 -1
  113. package/lib/plugin/plugin-manager.js +1 -0
  114. package/lib/plugin/plugin-manager.js.map +1 -1
  115. package/lib/plugin/plugin-storage.d.ts +1 -0
  116. package/lib/plugin/plugin-storage.d.ts.map +1 -1
  117. package/lib/plugin/plugin-storage.js +3 -0
  118. package/lib/plugin/plugin-storage.js.map +1 -1
  119. package/lib/plugin/preference-registry.d.ts +15 -2
  120. package/lib/plugin/preference-registry.d.ts.map +1 -1
  121. package/lib/plugin/preference-registry.js +105 -62
  122. package/lib/plugin/preference-registry.js.map +1 -1
  123. package/lib/plugin/preference-registry.spec.js +207 -35
  124. package/lib/plugin/preference-registry.spec.js.map +1 -1
  125. package/lib/plugin/quick-open.d.ts.map +1 -1
  126. package/lib/plugin/quick-open.js +1 -0
  127. package/lib/plugin/quick-open.js.map +1 -1
  128. package/lib/plugin/scm.d.ts +3 -0
  129. package/lib/plugin/scm.d.ts.map +1 -1
  130. package/lib/plugin/scm.js +8 -0
  131. package/lib/plugin/scm.js.map +1 -1
  132. package/lib/plugin/type-converters.d.ts +1 -0
  133. package/lib/plugin/type-converters.d.ts.map +1 -1
  134. package/lib/plugin/type-converters.js +13 -4
  135. package/lib/plugin/type-converters.js.map +1 -1
  136. package/lib/plugin/types-impl.d.ts +9 -3
  137. package/lib/plugin/types-impl.d.ts.map +1 -1
  138. package/lib/plugin/types-impl.js +26 -11
  139. package/lib/plugin/types-impl.js.map +1 -1
  140. package/package.json +27 -27
  141. package/src/common/plugin-api-rpc-model.ts +11 -0
  142. package/src/common/plugin-api-rpc.ts +15 -3
  143. package/src/common/plugin-protocol.ts +4 -0
  144. package/src/hosted/browser/hosted-plugin.ts +4 -2
  145. package/src/hosted/browser/worker/worker-env-ext.ts +4 -0
  146. package/src/hosted/node/scanners/scanner-theia.ts +21 -15
  147. package/src/main/browser/comments/comment-thread-widget.tsx +5 -5
  148. package/src/main/browser/debug/debug-main.ts +9 -0
  149. package/src/main/browser/languages-main.ts +29 -2
  150. package/src/main/browser/menus/menus-contribution-handler.ts +104 -578
  151. package/src/main/browser/menus/plugin-menu-command-adapter.ts +259 -0
  152. package/src/main/browser/menus/vscode-theia-menu-mappings.ts +85 -0
  153. package/src/main/browser/plugin-contribution-handler.ts +3 -1
  154. package/src/main/browser/plugin-ext-frontend-module.ts +4 -3
  155. package/src/main/browser/plugin-frontend-contribution.ts +0 -9
  156. package/src/main/browser/plugin-shared-style.ts +0 -1
  157. package/src/main/browser/preference-registry-main.ts +23 -14
  158. package/src/main/browser/scm-main.ts +10 -0
  159. package/src/main/browser/view/tree-view-widget.tsx +2 -2
  160. package/src/main/browser/workspace-main.ts +1 -5
  161. package/src/main/node/handlers/plugin-theia-file-handler.ts +0 -26
  162. package/src/main/node/plugin-ext-backend-module.ts +0 -2
  163. package/src/main/node/resolvers/local-plugin-deployer-resolver.ts +4 -8
  164. package/src/plugin/debug/debug-ext.ts +30 -5
  165. package/src/plugin/debug/plugin-debug-adapter-session.ts +4 -0
  166. package/src/plugin/env.ts +30 -0
  167. package/src/plugin/languages/evaluatable-expression.ts +47 -0
  168. package/src/plugin/languages/signature.ts +3 -1
  169. package/src/plugin/languages.ts +15 -0
  170. package/src/plugin/node/debug/debug.spec.ts +94 -0
  171. package/src/plugin/node/env-node-ext.ts +13 -1
  172. package/src/plugin/plugin-context.ts +16 -1
  173. package/src/plugin/plugin-manager.ts +1 -0
  174. package/src/plugin/plugin-storage.ts +4 -0
  175. package/src/plugin/preference-registry.spec.ts +247 -39
  176. package/src/plugin/preference-registry.ts +107 -71
  177. package/src/plugin/quick-open.ts +1 -0
  178. package/src/plugin/scm.ts +11 -0
  179. package/src/plugin/type-converters.ts +11 -2
  180. package/src/plugin/types-impl.ts +25 -5
  181. package/lib/main/browser/plugin-ext-deploy-command.d.ts +0 -10
  182. package/lib/main/browser/plugin-ext-deploy-command.d.ts.map +0 -1
  183. package/lib/main/browser/plugin-ext-deploy-command.js +0 -64
  184. package/lib/main/browser/plugin-ext-deploy-command.js.map +0 -1
  185. package/lib/main/node/resolvers/local-file-plugin-deployer-resolver.d.ts +0 -8
  186. package/lib/main/node/resolvers/local-file-plugin-deployer-resolver.d.ts.map +0 -1
  187. package/lib/main/node/resolvers/local-file-plugin-deployer-resolver.js +0 -43
  188. package/lib/main/node/resolvers/local-file-plugin-deployer-resolver.js.map +0 -1
  189. package/lib/plugin/preferences/configuration.d.ts +0 -35
  190. package/lib/plugin/preferences/configuration.d.ts.map +0 -1
  191. package/lib/plugin/preferences/configuration.js +0 -137
  192. package/lib/plugin/preferences/configuration.js.map +0 -1
  193. package/lib/plugin/preferences/configuration.spec.d.ts +0 -2
  194. package/lib/plugin/preferences/configuration.spec.d.ts.map +0 -1
  195. package/lib/plugin/preferences/configuration.spec.js +0 -178
  196. package/lib/plugin/preferences/configuration.spec.js.map +0 -1
  197. package/src/main/browser/plugin-ext-deploy-command.ts +0 -50
  198. package/src/main/node/resolvers/local-file-plugin-deployer-resolver.ts +0 -34
  199. package/src/plugin/preferences/configuration.spec.ts +0 -292
  200. package/src/plugin/preferences/configuration.ts +0 -167
@@ -23,13 +23,15 @@ import { PluginPackageDebuggersContribution } from '../../common/plugin-protocol
23
23
  import { RPCProtocol } from '../../common/rpc-protocol';
24
24
  import { CommandRegistryImpl } from '../command-registry';
25
25
  import { ConnectionImpl } from '../../common/connection';
26
- import { Disposable, Breakpoint as BreakpointExt, SourceBreakpoint, FunctionBreakpoint, Location, Range } from '../types-impl';
26
+ import { DEBUG_SCHEME, SCHEME_PATTERN } from '@theia/debug/lib/common/debug-uri-utils';
27
+ import { Disposable, Breakpoint as BreakpointExt, SourceBreakpoint, FunctionBreakpoint, Location, Range, URI as URIImpl } from '../types-impl';
27
28
  import { PluginDebugAdapterSession } from './plugin-debug-adapter-session';
28
29
  import { PluginDebugAdapterTracker } from './plugin-debug-adapter-tracker';
29
30
  import uuid = require('uuid');
30
31
  import { DebugAdapter } from '@theia/debug/lib/common/debug-model';
31
32
  import { PluginDebugAdapterCreator } from './plugin-debug-adapter-creator';
32
33
  import { NodeDebugAdapterCreator } from '../node/debug/plugin-node-debug-adapter-creator';
34
+ import { DebugProtocol } from 'vscode-debugprotocol';
33
35
 
34
36
  interface ConfigurationProviderRecord {
35
37
  handle: number;
@@ -176,6 +178,27 @@ export class DebugExtImpl implements DebugExt {
176
178
  return this.proxy.$stopDebugging(session?.id);
177
179
  }
178
180
 
181
+ asDebugSourceUri(source: theia.DebugProtocolSource, session?: theia.DebugSession): theia.Uri {
182
+ return this.getDebugSourceUri(source, session?.id);
183
+ }
184
+
185
+ private getDebugSourceUri(raw: DebugProtocol.Source, sessionId?: string): theia.Uri {
186
+ if (raw.sourceReference && raw.sourceReference > 0) {
187
+ let query = 'ref=' + String(raw.sourceReference);
188
+ if (sessionId) {
189
+ query += `&session=${sessionId}`;
190
+ }
191
+ return URIImpl.from({ scheme: DEBUG_SCHEME, path: raw.path ?? '', query });
192
+ }
193
+ if (!raw.path) {
194
+ throw new Error('Unrecognized source type: ' + JSON.stringify(raw));
195
+ }
196
+ if (raw.path.match(SCHEME_PATTERN)) {
197
+ return URIImpl.parse(raw.path);
198
+ }
199
+ return URIImpl.file(raw.path);
200
+ }
201
+
179
202
  registerDebugAdapterDescriptorFactory(debugType: string, factory: theia.DebugAdapterDescriptorFactory): Disposable {
180
203
  if (this.descriptorFactories.has(debugType)) {
181
204
  throw new Error(`Descriptor factory for ${debugType} has been already registered`);
@@ -279,13 +302,13 @@ export class DebugExtImpl implements DebugExt {
279
302
  this.onDidChangeBreakpointsEmitter.fire({ added: a, removed: r, changed: c });
280
303
  }
281
304
 
282
- protected toBreakpointExt({ functionName, location, enabled, condition, hitCondition, logMessage }: Breakpoint): BreakpointExt | undefined {
305
+ protected toBreakpointExt({ functionName, location, enabled, condition, hitCondition, logMessage, id }: Breakpoint): BreakpointExt | undefined {
283
306
  if (location) {
284
307
  const range = new Range(location.range.startLineNumber, location.range.startColumn, location.range.endLineNumber, location.range.endColumn);
285
- return new SourceBreakpoint(new Location(URI.revive(location.uri), range), enabled, condition, hitCondition, logMessage);
308
+ return new SourceBreakpoint(new Location(URI.revive(location.uri), range), enabled, condition, hitCondition, logMessage, id);
286
309
  }
287
310
  if (functionName) {
288
- return new FunctionBreakpoint(functionName!, enabled, condition, hitCondition, logMessage);
311
+ return new FunctionBreakpoint(functionName!, enabled, condition, hitCondition, logMessage, id);
289
312
  }
290
313
  return undefined;
291
314
  }
@@ -305,7 +328,9 @@ export class DebugExtImpl implements DebugExt {
305
328
  return response.body;
306
329
  }
307
330
  return Promise.reject(new Error(response.message ?? 'custom request failed'));
308
- }
331
+ },
332
+ getDebugProtocolBreakpoint: async (breakpoint: Breakpoint) =>
333
+ this.proxy.$getDebugProtocolBreakpoint(sessionId, breakpoint.id)
309
334
  };
310
335
 
311
336
  const tracker = await this.createDebugAdapterTracker(theiaSession);
@@ -61,6 +61,10 @@ export class PluginDebugAdapterSession extends DebugAdapterSessionImpl {
61
61
  return this.theiaSession.customRequest(command, args);
62
62
  }
63
63
 
64
+ async getDebugProtocolBreakpoint(breakpoint: theia.Breakpoint): Promise<theia.DebugProtocolBreakpoint | undefined> {
65
+ return this.theiaSession.getDebugProtocolBreakpoint(breakpoint);
66
+ }
67
+
64
68
  protected override onDebugAdapterError(error: Error): void {
65
69
  if (this.tracker.onError) {
66
70
  this.tracker.onError(error);
package/src/plugin/env.ts CHANGED
@@ -14,6 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
+ import { Emitter, Event } from '@theia/core/lib/common/event';
17
18
  import * as theia from '@theia/plugin';
18
19
  import { RPCProtocol } from '../common/rpc-protocol';
19
20
  import { EnvMain, PLUGIN_RPC_CONTEXT } from '../common/plugin-api-rpc';
@@ -29,11 +30,18 @@ export abstract class EnvExtImpl {
29
30
  private ui: theia.UIKind;
30
31
  private envMachineId: string;
31
32
  private envSessionId: string;
33
+ private host: string;
34
+ private _isTelemetryEnabled: boolean;
35
+ private _remoteName: string | undefined;
36
+ private onDidChangeTelemetryEnabledEmitter = new Emitter<boolean>();
32
37
 
33
38
  constructor(rpc: RPCProtocol) {
34
39
  this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.ENV_MAIN);
35
40
  this.envSessionId = v4();
36
41
  this.envMachineId = v4();
42
+ // we don't support telemetry at the moment
43
+ this._isTelemetryEnabled = false;
44
+ this._remoteName = undefined;
37
45
  }
38
46
 
39
47
  getEnvVariable(envVarName: string): Promise<string | undefined> {
@@ -73,6 +81,10 @@ export abstract class EnvExtImpl {
73
81
  this.ui = uiKind;
74
82
  }
75
83
 
84
+ setAppHost(appHost: string): void {
85
+ this.host = appHost;
86
+ }
87
+
76
88
  getClientOperatingSystem(): Promise<theia.OperatingSystem> {
77
89
  return this.proxy.$getClientOperatingSystem();
78
90
  }
@@ -83,6 +95,24 @@ export abstract class EnvExtImpl {
83
95
 
84
96
  abstract get appRoot(): string;
85
97
 
98
+ abstract get isNewAppInstall(): boolean;
99
+
100
+ get appHost(): string {
101
+ return this.host;
102
+ }
103
+
104
+ get isTelemetryEnabled(): boolean {
105
+ return this._isTelemetryEnabled;
106
+ }
107
+
108
+ get onDidChangeTelemetryEnabled(): Event<boolean> {
109
+ return this.onDidChangeTelemetryEnabledEmitter.event;
110
+ }
111
+
112
+ get remoteName(): string | undefined {
113
+ return this._remoteName;
114
+ }
115
+
86
116
  get language(): string {
87
117
  return this.lang;
88
118
  }
@@ -0,0 +1,47 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 STMicroelectronics and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { URI } from '@theia/core/shared/vscode-uri';
18
+ import * as theia from '@theia/plugin';
19
+ import { Position } from '../../common/plugin-api-rpc';
20
+ import { EvaluatableExpression } from '../../common/plugin-api-rpc-model';
21
+ import { DocumentsExtImpl } from '../documents';
22
+ import * as Converter from '../type-converters';
23
+
24
+ export class EvaluatableExpressionAdapter {
25
+
26
+ constructor(
27
+ private readonly provider: theia.EvaluatableExpressionProvider,
28
+ private readonly documents: DocumentsExtImpl
29
+ ) { }
30
+
31
+ async provideEvaluatableExpression(resource: URI, position: Position, token: theia.CancellationToken): Promise<EvaluatableExpression | undefined> {
32
+ const documentData = this.documents.getDocumentData(resource);
33
+ if (!documentData) {
34
+ return Promise.reject(new Error(`There is no document data for ${resource}`));
35
+ }
36
+
37
+ const document = documentData.document;
38
+ const pos = Converter.toPosition(position);
39
+
40
+ return Promise.resolve(this.provider.provideEvaluatableExpression(document, pos, token)).then(expression => {
41
+ if (!expression) {
42
+ return undefined;
43
+ }
44
+ return Converter.fromEvaluatableExpression(expression);
45
+ });
46
+ }
47
+ }
@@ -52,6 +52,7 @@ export class SignatureHelpAdapter {
52
52
  if (!value) {
53
53
  return undefined;
54
54
  }
55
+ value.activeParameter = value.signatures[value.activeSignature].activeParameter ?? value.activeParameter;
55
56
  const id = this.idSequence++;
56
57
  this.cache.set(id, value);
57
58
  return Converter.SignatureHelp.from(id, value);
@@ -65,7 +66,8 @@ export class SignatureHelpAdapter {
65
66
  if (saved) {
66
67
  activeSignatureHelp = saved;
67
68
  activeSignatureHelp.activeSignature = revivedSignatureHelp.activeSignature;
68
- activeSignatureHelp.activeParameter = revivedSignatureHelp.activeParameter;
69
+ const { activeSignature } = revivedSignatureHelp;
70
+ activeSignatureHelp.activeParameter = revivedSignatureHelp.signatures[activeSignature].activeParameter ?? revivedSignatureHelp.activeParameter;
69
71
  } else {
70
72
  activeSignatureHelp = revivedSignatureHelp;
71
73
  }
@@ -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));
@@ -0,0 +1,94 @@
1
+ /********************************************************************************
2
+ * Copyright (C) 2022 STMicroelectronics and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ import { DebugSession } from '@theia/plugin';
17
+ import * as chai from 'chai';
18
+ import { ProxyIdentifier, RPCProtocol } from '../../../common/rpc-protocol';
19
+
20
+ import { DebugExtImpl } from '../../debug/debug-ext';
21
+
22
+ const expect = chai.expect;
23
+
24
+ describe('Debug API', () => {
25
+
26
+ describe('#asDebugSourceURI', () => {
27
+
28
+ const mockRPCProtocol: RPCProtocol = {
29
+ getProxy<T>(_proxyId: ProxyIdentifier<T>): T {
30
+ return {} as T;
31
+ },
32
+ set<T, R extends T>(_id: ProxyIdentifier<T>, instance: R): R {
33
+ return instance;
34
+ },
35
+ dispose(): void {
36
+ // Nothing
37
+ }
38
+ };
39
+
40
+ const debug = new DebugExtImpl(mockRPCProtocol);
41
+
42
+ it('should use sourceReference, path and sessionId', () => {
43
+ const source = {
44
+ sourceReference: 3,
45
+ path: 'test/path'
46
+ };
47
+ const session = { id: 'test-session' } as DebugSession;
48
+ const uri = debug.asDebugSourceUri(source, session);
49
+ expect(uri.toString(true)).to.be.equal('debug:test/path?ref=3&session=test-session');
50
+ });
51
+
52
+ it('should use sourceReference', () => {
53
+ const source = {
54
+ sourceReference: 5
55
+ };
56
+ const uri = debug.asDebugSourceUri(source);
57
+ expect(uri.toString(true)).to.be.equal('debug:?ref=5');
58
+ });
59
+
60
+ it('should use sourceReference and session', () => {
61
+ const source = {
62
+ sourceReference: 5
63
+ };
64
+ const session = { id: 'test-session' } as DebugSession;
65
+ const uri = debug.asDebugSourceUri(source, session);
66
+ expect(uri.toString(true)).to.be.equal('debug:?ref=5&session=test-session');
67
+ });
68
+
69
+ it('should use sourceReference and path', () => {
70
+ const source = {
71
+ sourceReference: 4,
72
+ path: 'test/path'
73
+ };
74
+ const uri = debug.asDebugSourceUri(source);
75
+ expect(uri.toString(true)).to.be.equal('debug:test/path?ref=4');
76
+ });
77
+
78
+ it('should use path', () => {
79
+ const source = {
80
+ path: 'scheme:/full/path'
81
+ };
82
+ const uri = debug.asDebugSourceUri(source);
83
+ expect(uri.toString(true)).to.be.equal('scheme:/full/path');
84
+ });
85
+
86
+ it('should use file path', () => {
87
+ const source = {
88
+ path: '/full/path'
89
+ };
90
+ const uri = debug.asDebugSourceUri(source);
91
+ expect(uri.toString(true)).to.be.equal('file:///full/path');
92
+ });
93
+ });
94
+ });
@@ -19,6 +19,7 @@ import { EnvExtImpl } from '../env';
19
19
  import { RPCProtocol } from '../../common/rpc-protocol';
20
20
  import { createHash } from 'crypto';
21
21
  import { v4 } from 'uuid';
22
+ import fs = require('fs');
22
23
 
23
24
  /**
24
25
  * Provides machineId using mac address. It's only possible on node side
@@ -27,6 +28,7 @@ import { v4 } from 'uuid';
27
28
  export class EnvNodeExtImpl extends EnvExtImpl {
28
29
 
29
30
  private macMachineId: string;
31
+ private _isNewAppInstall: boolean;
30
32
 
31
33
  constructor(rpc: RPCProtocol) {
32
34
  super(rpc);
@@ -37,7 +39,7 @@ export class EnvNodeExtImpl extends EnvExtImpl {
37
39
  this.macMachineId = createHash('sha256').update(macAddress, 'utf8').digest('hex');
38
40
  }
39
41
  });
40
-
42
+ this._isNewAppInstall = this.computeIsNewAppInstall();
41
43
  }
42
44
 
43
45
  /**
@@ -54,4 +56,14 @@ export class EnvNodeExtImpl extends EnvExtImpl {
54
56
  return __dirname;
55
57
  }
56
58
 
59
+ get isNewAppInstall(): boolean {
60
+ return this._isNewAppInstall;
61
+ }
62
+
63
+ private computeIsNewAppInstall(): boolean {
64
+ const creation = fs.statSync(__filename).birthtimeMs;
65
+ const current = Date.now();
66
+ const dayMs = 24 * 3600 * 1000;
67
+ return (current - creation) < dayMs;
68
+ }
57
69
  }
@@ -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,
@@ -559,7 +560,7 @@ export function createAPIFactory(
559
560
  extHostFileSystemEvent.getOnWillDeleteFileEvent(plugin)(listener, thisArg, disposables),
560
561
  onWillRenameFiles: (listener: (e: theia.FileWillRenameEvent) => any, thisArg?: any, disposables?: theia.Disposable[]) =>
561
562
  extHostFileSystemEvent.getOnWillRenameFileEvent(plugin)(listener, thisArg, disposables),
562
- getConfiguration(section?, resource?): theia.WorkspaceConfiguration {
563
+ getConfiguration(section, resource): theia.WorkspaceConfiguration {
563
564
  return preferenceRegistryExt.getConfiguration(section, resource);
564
565
  },
565
566
  onDidChangeConfiguration(listener, thisArgs?, disposables?): theia.Disposable {
@@ -639,7 +640,14 @@ export function createAPIFactory(
639
640
  const env: typeof theia.env = Object.freeze({
640
641
  get appName(): string { return envExt.appName; },
641
642
  get appRoot(): string { return envExt.appRoot; },
643
+ get appHost(): string { return envExt.appHost; },
642
644
  get language(): string { return envExt.language; },
645
+ get isNewAppInstall(): boolean { return envExt.isNewAppInstall; },
646
+ get isTelemetryEnabled(): boolean { return envExt.isTelemetryEnabled; },
647
+ get onDidChangeTelemetryEnabled(): theia.Event<boolean> {
648
+ return envExt.onDidChangeTelemetryEnabled;
649
+ },
650
+ get remoteName(): string | undefined { return envExt.remoteName; },
643
651
  get machineId(): string { return envExt.machineId; },
644
652
  get sessionId(): string { return envExt.sessionId; },
645
653
  get uriScheme(): string { return envExt.uriScheme; },
@@ -724,6 +732,9 @@ export function createAPIFactory(
724
732
  registerHoverProvider(selector: theia.DocumentSelector, provider: theia.HoverProvider): theia.Disposable {
725
733
  return languagesExt.registerHoverProvider(selector, provider, pluginToPluginInfo(plugin));
726
734
  },
735
+ registerEvaluatableExpressionProvider(selector: theia.DocumentSelector, provider: theia.EvaluatableExpressionProvider): theia.Disposable {
736
+ return languagesExt.registerEvaluatableExpressionProvider(selector, provider, pluginToPluginInfo(plugin));
737
+ },
727
738
  registerDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.DocumentHighlightProvider): theia.Disposable {
728
739
  return languagesExt.registerDocumentHighlightProvider(selector, provider, pluginToPluginInfo(plugin));
729
740
  },
@@ -868,6 +879,9 @@ export function createAPIFactory(
868
879
  },
869
880
  removeBreakpoints(breakpoints: readonly theia.Breakpoint[]): void {
870
881
  debugExt.removeBreakpoints(breakpoints);
882
+ },
883
+ asDebugSourceUri(source: theia.DebugProtocolSource, session?: theia.DebugSession): theia.Uri {
884
+ return debugExt.asDebugSourceUri(source, session);
871
885
  }
872
886
  };
873
887
 
@@ -981,6 +995,7 @@ export function createAPIFactory(
981
995
  SignatureHelp,
982
996
  SignatureHelpTriggerKind,
983
997
  Hover,
998
+ EvaluatableExpression,
984
999
  DocumentHighlightKind,
985
1000
  DocumentHighlight,
986
1001
  DocumentLink,
@@ -201,6 +201,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
201
201
  this.envExt.setShell(params.env.shell);
202
202
  this.envExt.setUIKind(params.env.uiKind);
203
203
  this.envExt.setApplicationName(params.env.appName);
204
+ this.envExt.setAppHost(params.env.appHost);
204
205
 
205
206
  this.preferencesManager.init(params.preferences);
206
207
 
@@ -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 {