@theia/debug 1.56.0 → 1.57.0-next.112

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 (36) hide show
  1. package/README.md +12 -9
  2. package/lib/browser/console/debug-console-session.d.ts +1 -1
  3. package/lib/browser/console/debug-console-session.d.ts.map +1 -1
  4. package/lib/browser/debug-frontend-application-contribution.d.ts +4 -0
  5. package/lib/browser/debug-frontend-application-contribution.d.ts.map +1 -1
  6. package/lib/browser/debug-frontend-application-contribution.js +30 -1
  7. package/lib/browser/debug-frontend-application-contribution.js.map +1 -1
  8. package/lib/browser/debug-schema-updater.d.ts +2 -3
  9. package/lib/browser/debug-schema-updater.d.ts.map +1 -1
  10. package/lib/browser/debug-schema-updater.js +6 -6
  11. package/lib/browser/debug-schema-updater.js.map +1 -1
  12. package/lib/browser/debug-session.d.ts +2 -1
  13. package/lib/browser/debug-session.d.ts.map +1 -1
  14. package/lib/browser/debug-session.js +12 -8
  15. package/lib/browser/debug-session.js.map +1 -1
  16. package/lib/browser/disassembly-view/disassembly-view-widget.js +3 -3
  17. package/lib/browser/disassembly-view/disassembly-view-widget.js.map +1 -1
  18. package/lib/browser/editor/debug-editor-service.d.ts +2 -0
  19. package/lib/browser/editor/debug-editor-service.d.ts.map +1 -1
  20. package/lib/browser/editor/debug-editor-service.js +4 -0
  21. package/lib/browser/editor/debug-editor-service.js.map +1 -1
  22. package/lib/browser/model/debug-thread.d.ts +4 -0
  23. package/lib/browser/model/debug-thread.d.ts.map +1 -1
  24. package/lib/browser/model/debug-thread.js +17 -0
  25. package/lib/browser/model/debug-thread.js.map +1 -1
  26. package/lib/common/inline-debug-adapter.d.ts +1 -0
  27. package/lib/common/inline-debug-adapter.d.ts.map +1 -1
  28. package/lib/node/stream-debug-adapter.d.ts +1 -0
  29. package/lib/node/stream-debug-adapter.d.ts.map +1 -1
  30. package/package.json +17 -17
  31. package/src/browser/debug-frontend-application-contribution.ts +39 -2
  32. package/src/browser/debug-schema-updater.ts +5 -7
  33. package/src/browser/debug-session.tsx +13 -8
  34. package/src/browser/disassembly-view/disassembly-view-widget.ts +3 -3
  35. package/src/browser/editor/debug-editor-service.ts +6 -0
  36. package/src/browser/model/debug-thread.tsx +28 -4
@@ -20,7 +20,7 @@ import {
20
20
  import { injectable, inject } from '@theia/core/shared/inversify';
21
21
  import * as monaco from '@theia/monaco-editor-core';
22
22
  import { MenuModelRegistry, CommandRegistry, MAIN_MENU_BAR, Command, Emitter, Mutable, CompoundMenuNodeRole } from '@theia/core/lib/common';
23
- import { EDITOR_LINENUMBER_CONTEXT_MENU, EditorManager } from '@theia/editor/lib/browser';
23
+ import { EDITOR_CONTEXT_MENU, EDITOR_LINENUMBER_CONTEXT_MENU, EditorManager } from '@theia/editor/lib/browser';
24
24
  import { DebugSessionManager } from './debug-session-manager';
25
25
  import { DebugWidget } from './view/debug-widget';
26
26
  import { FunctionBreakpoint } from './breakpoint/breakpoint-marker';
@@ -241,6 +241,11 @@ export namespace DebugCommands {
241
241
  id: 'editor.debug.action.showDebugHover',
242
242
  label: 'Debug: Show Hover'
243
243
  });
244
+ export const JUMP_TO_CURSOR = Command.toDefaultLocalizedCommand({
245
+ id: 'editor.debug.action.jumpToCursor',
246
+ category: DEBUG_CATEGORY,
247
+ label: 'Jump to Cursor'
248
+ });
244
249
 
245
250
  export const RESTART_FRAME = Command.toDefaultLocalizedCommand({
246
251
  id: 'debug.frame.restart',
@@ -376,6 +381,9 @@ export namespace DebugEditorContextCommands {
376
381
  export const DISABLE_LOGPOINT = {
377
382
  id: 'debug.editor.context.logpoint.disable'
378
383
  };
384
+ export const JUMP_TO_CURSOR = {
385
+ id: 'debug.editor.context.jumpToCursor'
386
+ };
379
387
  }
380
388
  export namespace DebugBreakpointWidgetCommands {
381
389
  export const ACCEPT = {
@@ -613,6 +621,11 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
613
621
  DebugCommands.DISABLE_ALL_BREAKPOINTS
614
622
  );
615
623
 
624
+ const DEBUG_EDITOR_CONTEXT_MENU_GROUP = [...EDITOR_CONTEXT_MENU, '2_debug'];
625
+ registerMenuActions(DEBUG_EDITOR_CONTEXT_MENU_GROUP,
626
+ DebugCommands.JUMP_TO_CURSOR
627
+ );
628
+
616
629
  registerMenuActions(DebugEditorModel.CONTEXT_MENU,
617
630
  { ...DebugEditorContextCommands.ADD_BREAKPOINT, label: nls.localizeByDefault('Add Breakpoint') },
618
631
  { ...DebugEditorContextCommands.ADD_CONDITIONAL_BREAKPOINT, label: DebugCommands.ADD_CONDITIONAL_BREAKPOINT.label },
@@ -624,7 +637,8 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
624
637
  { ...DebugEditorContextCommands.REMOVE_LOGPOINT, label: DebugCommands.REMOVE_LOGPOINT.label },
625
638
  { ...DebugEditorContextCommands.EDIT_LOGPOINT, label: DebugCommands.EDIT_LOGPOINT.label },
626
639
  { ...DebugEditorContextCommands.ENABLE_LOGPOINT, label: nlsEnableBreakpoint('Logpoint') },
627
- { ...DebugEditorContextCommands.DISABLE_LOGPOINT, label: nlsDisableBreakpoint('Logpoint') }
640
+ { ...DebugEditorContextCommands.DISABLE_LOGPOINT, label: nlsDisableBreakpoint('Logpoint') },
641
+ { ...DebugEditorContextCommands.JUMP_TO_CURSOR, label: nls.localizeByDefault('Jump to Cursor') }
628
642
  );
629
643
  menus.linkSubmenu(EDITOR_LINENUMBER_CONTEXT_MENU, DebugEditorModel.CONTEXT_MENU, { role: CompoundMenuNodeRole.Group });
630
644
  }
@@ -837,6 +851,20 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
837
851
  isEnabled: () => this.editors.canShowHover()
838
852
  });
839
853
 
854
+ registry.registerCommand(DebugCommands.JUMP_TO_CURSOR, {
855
+ execute: () => {
856
+ const model = this.editors.model;
857
+ if (model && this.manager.currentThread) {
858
+ this.manager.currentThread.jumpToCursor(
859
+ model.editor.getResourceUri(),
860
+ model.position
861
+ );
862
+ }
863
+ },
864
+ isEnabled: () => !!this.manager.currentThread && this.manager.currentThread.supportsGoto,
865
+ isVisible: () => !!this.manager.currentThread && this.manager.currentThread.supportsGoto
866
+ });
867
+
840
868
  registry.registerCommand(DebugCommands.RESTART_FRAME, {
841
869
  execute: () => this.selectedFrame && this.selectedFrame.restart(),
842
870
  isEnabled: () => !!this.selectedFrame
@@ -936,6 +964,15 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
936
964
  isEnabled: position => this.isPosition(position) && !!this.editors.getLogpointEnabled(this.asPosition(position)),
937
965
  isVisible: position => this.isPosition(position) && !!this.editors.getLogpointEnabled(this.asPosition(position))
938
966
  });
967
+ registry.registerCommand(DebugEditorContextCommands.JUMP_TO_CURSOR, {
968
+ execute: position => {
969
+ if (this.isPosition(position) && this.editors.currentUri && this.manager.currentThread) {
970
+ this.manager.currentThread.jumpToCursor(this.editors.currentUri, this.asPosition(position));
971
+ }
972
+ },
973
+ isEnabled: () => !!this.manager.currentThread && this.manager.currentThread.supportsGoto,
974
+ isVisible: () => !!this.manager.currentThread && this.manager.currentThread.supportsGoto
975
+ });
939
976
 
940
977
  registry.registerCommand(DebugBreakpointWidgetCommands.ACCEPT, {
941
978
  execute: () => this.editors.acceptBreakpoint()
@@ -15,8 +15,8 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
- import { JsonSchemaRegisterContext, JsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
19
- import { InMemoryResources, deepClone, nls } from '@theia/core/lib/common';
18
+ import { JsonSchemaRegisterContext, JsonSchemaContribution, JsonSchemaDataStore } from '@theia/core/lib/browser/json-schema-store';
19
+ import { deepClone, nls } from '@theia/core/lib/common';
20
20
  import { IJSONSchema } from '@theia/core/lib/common/json-schema';
21
21
  import URI from '@theia/core/lib/common/uri';
22
22
  import { DebugService } from '../common/debug-service';
@@ -30,13 +30,13 @@ export class DebugSchemaUpdater implements JsonSchemaContribution {
30
30
 
31
31
  protected readonly uri = new URI(launchSchemaId);
32
32
 
33
- @inject(InMemoryResources) protected readonly inmemoryResources: InMemoryResources;
33
+ @inject(JsonSchemaDataStore) protected readonly jsonStorage: JsonSchemaDataStore;
34
34
  @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
35
35
  @inject(DebugService) protected readonly debug: DebugService;
36
36
 
37
37
  @postConstruct()
38
38
  protected init(): void {
39
- this.inmemoryResources.add(this.uri, '');
39
+ this.jsonStorage.setSchema(this.uri, '');
40
40
  }
41
41
 
42
42
  registerSchemas(context: JsonSchemaRegisterContext): void {
@@ -64,9 +64,7 @@ export class DebugSchemaUpdater implements JsonSchemaContribution {
64
64
  }
65
65
  }
66
66
  items.defaultSnippets!.push(...await this.debug.getConfigurationSnippets());
67
-
68
- const contents = JSON.stringify(schema);
69
- this.inmemoryResources.update(this.uri, contents);
67
+ this.jsonStorage.setSchema(this.uri, schema);
70
68
  }
71
69
  }
72
70
 
@@ -312,6 +312,16 @@ export class DebugSession implements CompositeTreeElement {
312
312
  return currentFrame ? currentFrame.getScopes() : [];
313
313
  }
314
314
 
315
+ showMessage(messageType: MessageType, message: string): void {
316
+ this.messages.showMessage({
317
+ type: messageType,
318
+ text: message,
319
+ options: {
320
+ timeout: 10000
321
+ }
322
+ });
323
+ }
324
+
315
325
  async start(): Promise<void> {
316
326
  await this.initialize();
317
327
  await this.launchOrAttach();
@@ -343,13 +353,7 @@ export class DebugSession implements CompositeTreeElement {
343
353
  try {
344
354
  await this.sendRequest((this.configuration.request as keyof DebugRequestTypes), this.configuration);
345
355
  } catch (reason) {
346
- this.messages.showMessage({
347
- type: MessageType.Error,
348
- text: reason.message || 'Debug session initialization failed. See console for details.',
349
- options: {
350
- timeout: 10000
351
- }
352
- });
356
+ this.showMessage(MessageType.Error, reason.message || 'Debug session initialization failed. See console for details.');
353
357
  throw reason;
354
358
  }
355
359
  }
@@ -373,11 +377,12 @@ export class DebugSession implements CompositeTreeElement {
373
377
  }
374
378
  this.breakpoints.setExceptionBreakpoints(exceptionBreakpoints);
375
379
  }
380
+ // mark as initialized, so updated breakpoints are shown in editor
381
+ this.initialized = true;
376
382
  await this.updateBreakpoints({ sourceModified: false });
377
383
  if (this.capabilities.supportsConfigurationDoneRequest) {
378
384
  await this.sendRequest('configurationDone', {});
379
385
  }
380
- this.initialized = true;
381
386
  await this.updateThreads(undefined);
382
387
  }
383
388
 
@@ -27,7 +27,7 @@ import { BareFontInfo } from '@theia/monaco-editor-core/esm/vs/editor/common/con
27
27
  import { WorkbenchTable } from '@theia/monaco-editor-core/esm/vs/platform/list/browser/listService';
28
28
  import { DebugState, DebugSession } from '../debug-session';
29
29
  import { EditorPreferences } from '@theia/editor/lib/browser';
30
- import { PixelRatio } from '@theia/monaco-editor-core/esm/vs/base/browser/browser';
30
+ import { PixelRatio } from '@theia/monaco-editor-core/esm/vs/base/browser/pixelRatio';
31
31
  import { DebugPreferences } from '../debug-preferences';
32
32
  import { DebugThread } from '../model/debug-thread';
33
33
  import { Event } from '@theia/monaco-editor-core/esm/vs/base/common/event';
@@ -89,8 +89,8 @@ export class DisassemblyViewWidget extends BaseWidget {
89
89
  this.node.tabIndex = -1;
90
90
  this.node.style.outline = 'none';
91
91
  this._previousDebuggingState = this.debugSessionManager.currentSession?.state ?? DebugState.Inactive;
92
- this._fontInfo = BareFontInfo.createFromRawSettings(this.toFontInfo(), PixelRatio.value);
93
- this.editorPreferences.onPreferenceChanged(() => this._fontInfo = BareFontInfo.createFromRawSettings(this.toFontInfo(), PixelRatio.value));
92
+ this._fontInfo = BareFontInfo.createFromRawSettings(this.toFontInfo(), PixelRatio.getInstance(window).value);
93
+ this.editorPreferences.onPreferenceChanged(() => this._fontInfo = BareFontInfo.createFromRawSettings(this.toFontInfo(), PixelRatio.getInstance(window).value));
94
94
  this.debugPreferences.onPreferenceChanged(e => {
95
95
  if (e.preferenceName === 'debug.disassemblyView.showSourceCode' && e.newValue !== this._enableSourceCodeRender) {
96
96
  this._enableSourceCodeRender = e.newValue;
@@ -24,6 +24,7 @@ import { DebugEditorModel, DebugEditorModelFactory } from './debug-editor-model'
24
24
  import { BreakpointManager, SourceBreakpointsChangeEvent } from '../breakpoint/breakpoint-manager';
25
25
  import { DebugSourceBreakpoint } from '../model/debug-source-breakpoint';
26
26
  import { DebugBreakpointWidget } from './debug-breakpoint-widget';
27
+ import URI from '@theia/core/lib/common/uri';
27
28
 
28
29
  @injectable()
29
30
  export class DebugEditorService {
@@ -71,6 +72,11 @@ export class DebugEditorService {
71
72
  return uri && this.models.get(uri.toString());
72
73
  }
73
74
 
75
+ get currentUri(): URI | undefined {
76
+ const { currentEditor } = this.editors;
77
+ return currentEditor && currentEditor.getResourceUri();
78
+ }
79
+
74
80
  getLogpoint(position: monaco.Position): DebugSourceBreakpoint | undefined {
75
81
  const logpoint = this.anyBreakpoint(position);
76
82
  return logpoint && logpoint.logMessage ? logpoint : undefined;
@@ -15,11 +15,13 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import * as React from '@theia/core/shared/react';
18
- import { CancellationTokenSource, Emitter, Event, nls } from '@theia/core';
18
+ import { CancellationTokenSource, Emitter, Event, MessageType, nls } from '@theia/core';
19
19
  import { DebugProtocol } from '@vscode/debugprotocol/lib/debugProtocol';
20
20
  import { TreeElement } from '@theia/core/lib/browser/source-tree';
21
21
  import { DebugStackFrame } from './debug-stack-frame';
22
22
  import { DebugSession } from '../debug-session';
23
+ import * as monaco from '@theia/monaco-editor-core';
24
+ import URI from '@theia/core/lib/common/uri';
23
25
 
24
26
  export type StoppedDetails = DebugProtocol.StoppedEvent['body'] & {
25
27
  framesErrorMessage?: string
@@ -111,6 +113,28 @@ export class DebugThread extends DebugThreadData implements TreeElement {
111
113
  return this.session.sendRequest('pause', this.toArgs());
112
114
  }
113
115
 
116
+ get supportsGoto(): boolean {
117
+ return !!this.session.capabilities.supportsGotoTargetsRequest;
118
+ }
119
+
120
+ async jumpToCursor(uri: URI, position: monaco.Position): Promise<DebugProtocol.GotoResponse | undefined> {
121
+ const source = await this.session?.toDebugSource(uri);
122
+
123
+ if (!source) {
124
+ return undefined;
125
+ }
126
+
127
+ const response: DebugProtocol.GotoTargetsResponse = await this.session.sendRequest('gotoTargets', { source, line: position.lineNumber, column: position.column });
128
+
129
+ if (response && response.body.targets.length === 0) {
130
+ this.session.showMessage(MessageType.Warning, 'No executable code is associated at the current cursor position.');
131
+ return;
132
+ }
133
+
134
+ const targetId = response.body.targets[0].id;
135
+ return this.session.sendRequest('goto', this.toArgs({ targetId }));
136
+ }
137
+
114
138
  async getExceptionInfo(): Promise<DebugExceptionInfo | undefined> {
115
139
  if (this.stoppedDetails && this.stoppedDetails.reason === 'exception') {
116
140
  if (this.session.capabilities.supportsExceptionInfoRequest) {
@@ -261,8 +285,8 @@ export class DebugThread extends DebugThreadData implements TreeElement {
261
285
  const localizedReason = this.getLocalizedReason(reason);
262
286
 
263
287
  return reason
264
- ? nls.localizeByDefault('Paused on {0}', localizedReason)
265
- : nls.localizeByDefault('Paused');
288
+ ? nls.localizeByDefault('Paused on {0}', localizedReason)
289
+ : nls.localizeByDefault('Paused');
266
290
  }
267
291
 
268
292
  protected getLocalizedReason(reason: string | undefined): string {
@@ -281,7 +305,7 @@ export class DebugThread extends DebugThreadData implements TreeElement {
281
305
  return nls.localize('theia/debug/goto', 'goto');
282
306
  case 'function breakpoint':
283
307
  return nls.localize('theia/debug/functionBreakpoint', 'function breakpoint');
284
- case 'data breakpoint':
308
+ case 'data breakpoint':
285
309
  return nls.localize('theia/debug/dataBreakpoint', 'data breakpoint');
286
310
  case 'instruction breakpoint':
287
311
  return nls.localize('theia/debug/instructionBreakpoint', 'instruction breakpoint');