@theia/debug 1.53.0-next.4 → 1.53.0-next.55

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 (88) hide show
  1. package/README.md +62 -62
  2. package/lib/browser/debug-configuration-manager.js +6 -6
  3. package/lib/browser/debug-frontend-application-contribution.d.ts.map +1 -1
  4. package/lib/browser/debug-frontend-application-contribution.js.map +1 -1
  5. package/lib/common/inline-debug-adapter.d.ts +1 -0
  6. package/lib/common/inline-debug-adapter.d.ts.map +1 -1
  7. package/package.json +16 -16
  8. package/src/browser/breakpoint/breakpoint-manager.ts +369 -369
  9. package/src/browser/breakpoint/breakpoint-marker.ts +104 -104
  10. package/src/browser/console/debug-console-contribution.tsx +240 -240
  11. package/src/browser/console/debug-console-items.tsx +384 -384
  12. package/src/browser/console/debug-console-session.ts +205 -205
  13. package/src/browser/debug-call-stack-item-type-key.ts +20 -20
  14. package/src/browser/debug-configuration-manager.ts +591 -591
  15. package/src/browser/debug-configuration-model.ts +100 -100
  16. package/src/browser/debug-contribution.ts +43 -43
  17. package/src/browser/debug-frontend-application-contribution.ts +1551 -1551
  18. package/src/browser/debug-frontend-module.ts +133 -133
  19. package/src/browser/debug-package.spec.ts +20 -20
  20. package/src/browser/debug-preferences.ts +98 -98
  21. package/src/browser/debug-prefix-configuration.ts +195 -195
  22. package/src/browser/debug-resource.ts +59 -59
  23. package/src/browser/debug-schema-updater.ts +149 -149
  24. package/src/browser/debug-session-connection.ts +357 -357
  25. package/src/browser/debug-session-contribution.ts +157 -157
  26. package/src/browser/debug-session-manager.ts +683 -683
  27. package/src/browser/debug-session-options.ts +120 -120
  28. package/src/browser/debug-session.tsx +974 -974
  29. package/src/browser/debug-tab-bar-decorator.ts +57 -57
  30. package/src/browser/debug-watch-manager.ts +93 -93
  31. package/src/browser/disassembly-view/disassembly-view-accessibility-provider.ts +43 -43
  32. package/src/browser/disassembly-view/disassembly-view-breakpoint-renderer.ts +119 -119
  33. package/src/browser/disassembly-view/disassembly-view-contribution.ts +109 -109
  34. package/src/browser/disassembly-view/disassembly-view-instruction-renderer.ts +245 -245
  35. package/src/browser/disassembly-view/disassembly-view-table-delegate.ts +39 -39
  36. package/src/browser/disassembly-view/disassembly-view-utilities.ts +55 -55
  37. package/src/browser/disassembly-view/disassembly-view-widget.ts +463 -463
  38. package/src/browser/editor/debug-breakpoint-widget.tsx +293 -293
  39. package/src/browser/editor/debug-editor-model.ts +529 -529
  40. package/src/browser/editor/debug-editor-service.ts +192 -192
  41. package/src/browser/editor/debug-editor.ts +20 -20
  42. package/src/browser/editor/debug-exception-widget.tsx +122 -122
  43. package/src/browser/editor/debug-expression-provider.ts +78 -78
  44. package/src/browser/editor/debug-hover-source.tsx +105 -105
  45. package/src/browser/editor/debug-hover-widget.ts +298 -298
  46. package/src/browser/editor/debug-inline-value-decorator.ts +373 -373
  47. package/src/browser/model/debug-breakpoint.tsx +151 -151
  48. package/src/browser/model/debug-function-breakpoint.tsx +101 -101
  49. package/src/browser/model/debug-instruction-breakpoint.tsx +68 -68
  50. package/src/browser/model/debug-source-breakpoint.tsx +237 -237
  51. package/src/browser/model/debug-source.ts +93 -93
  52. package/src/browser/model/debug-stack-frame.tsx +177 -177
  53. package/src/browser/model/debug-thread.tsx +292 -292
  54. package/src/browser/preferences/launch-preferences.ts +38 -38
  55. package/src/browser/style/index.css +453 -453
  56. package/src/browser/view/debug-action.tsx +57 -57
  57. package/src/browser/view/debug-breakpoints-source.tsx +53 -53
  58. package/src/browser/view/debug-breakpoints-widget.ts +71 -71
  59. package/src/browser/view/debug-configuration-select.tsx +269 -269
  60. package/src/browser/view/debug-configuration-widget.tsx +121 -121
  61. package/src/browser/view/debug-exception-breakpoint.tsx +68 -68
  62. package/src/browser/view/debug-session-widget.ts +124 -124
  63. package/src/browser/view/debug-stack-frames-source.tsx +75 -75
  64. package/src/browser/view/debug-stack-frames-widget.ts +135 -135
  65. package/src/browser/view/debug-threads-source.tsx +48 -48
  66. package/src/browser/view/debug-threads-widget.ts +126 -126
  67. package/src/browser/view/debug-toolbar-widget.tsx +145 -145
  68. package/src/browser/view/debug-variables-source.ts +43 -43
  69. package/src/browser/view/debug-variables-widget.ts +61 -61
  70. package/src/browser/view/debug-view-model.ts +230 -230
  71. package/src/browser/view/debug-watch-expression.tsx +88 -88
  72. package/src/browser/view/debug-watch-source.ts +41 -41
  73. package/src/browser/view/debug-watch-widget.ts +61 -61
  74. package/src/browser/view/debug-widget.ts +97 -97
  75. package/src/common/debug-adapter-contribution-registry.ts +206 -206
  76. package/src/common/debug-adapter-session.ts +102 -102
  77. package/src/common/debug-common.ts +19 -19
  78. package/src/common/debug-compound.ts +33 -33
  79. package/src/common/debug-configuration.ts +112 -112
  80. package/src/common/debug-model.ts +200 -200
  81. package/src/common/debug-service.ts +184 -184
  82. package/src/common/debug-uri-utils.ts +24 -24
  83. package/src/common/inline-debug-adapter.ts +47 -47
  84. package/src/node/debug-adapter-factory.ts +107 -107
  85. package/src/node/debug-adapter-session-manager.ts +106 -106
  86. package/src/node/debug-backend-module.ts +57 -57
  87. package/src/node/debug-service-impl.ts +119 -119
  88. package/src/node/stream-debug-adapter.ts +126 -126
@@ -1,126 +1,126 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable, inject, postConstruct, interfaces, Container } from '@theia/core/shared/inversify';
18
- import { MenuPath } from '@theia/core';
19
- import { TreeNode, NodeProps, SelectableTreeNode } from '@theia/core/lib/browser';
20
- import { SourceTreeWidget, TreeElementNode } from '@theia/core/lib/browser/source-tree';
21
- import { DebugThreadsSource } from './debug-threads-source';
22
- import { DebugSession } from '../debug-session';
23
- import { DebugThread } from '../model/debug-thread';
24
- import { DebugViewModel } from '../view/debug-view-model';
25
- import { DebugCallStackItemTypeKey } from '../debug-call-stack-item-type-key';
26
- import { nls } from '@theia/core/lib/common/nls';
27
-
28
- @injectable()
29
- export class DebugThreadsWidget extends SourceTreeWidget {
30
-
31
- static CONTEXT_MENU: MenuPath = ['debug-threads-context-menu'];
32
- static CONTROL_MENU = [...DebugThreadsWidget.CONTEXT_MENU, 'a_control'];
33
- static TERMINATE_MENU = [...DebugThreadsWidget.CONTEXT_MENU, 'b_terminate'];
34
- static OPEN_MENU = [...DebugThreadsWidget.CONTEXT_MENU, 'c_open'];
35
- static FACTORY_ID = 'debug:threads';
36
- static override createContainer(parent: interfaces.Container): Container {
37
- const child = SourceTreeWidget.createContainer(parent, {
38
- contextMenuPath: DebugThreadsWidget.CONTEXT_MENU,
39
- virtualized: false,
40
- scrollIfActive: true
41
- });
42
- child.bind(DebugThreadsSource).toSelf();
43
- child.unbind(SourceTreeWidget);
44
- child.bind(DebugThreadsWidget).toSelf();
45
- return child;
46
- }
47
- static createWidget(parent: interfaces.Container): DebugThreadsWidget {
48
- return DebugThreadsWidget.createContainer(parent).get(DebugThreadsWidget);
49
- }
50
-
51
- @inject(DebugThreadsSource)
52
- protected readonly threads: DebugThreadsSource;
53
-
54
- @inject(DebugViewModel)
55
- protected readonly viewModel: DebugViewModel;
56
-
57
- @inject(DebugCallStackItemTypeKey)
58
- protected readonly debugCallStackItemTypeKey: DebugCallStackItemTypeKey;
59
-
60
- @postConstruct()
61
- protected override init(): void {
62
- super.init();
63
- this.id = DebugThreadsWidget.FACTORY_ID + ':' + this.viewModel.id;
64
- this.title.label = nls.localize('theia/debug/threads', 'Threads');
65
- this.toDispose.push(this.threads);
66
- this.source = this.threads;
67
-
68
- this.toDispose.push(this.viewModel.onDidChange(() => this.updateWidgetSelection()));
69
- this.toDispose.push(this.model.onSelectionChanged(() => this.updateModelSelection()));
70
- }
71
-
72
- protected updatingSelection = false;
73
- protected updateWidgetSelection(): void {
74
- if (this.updatingSelection) {
75
- return;
76
- }
77
- this.updatingSelection = true;
78
- try {
79
- const { currentThread } = this.viewModel;
80
- if (currentThread) {
81
- const node = this.model.getNode(currentThread.id);
82
- if (SelectableTreeNode.is(node)) {
83
- this.model.selectNode(node);
84
- }
85
- }
86
- } finally {
87
- this.updatingSelection = false;
88
- }
89
- }
90
- protected updateModelSelection(): void {
91
- if (this.updatingSelection) {
92
- return;
93
- }
94
- this.updatingSelection = true;
95
- try {
96
- const node = this.model.selectedNodes[0];
97
- if (TreeElementNode.is(node)) {
98
- if (node.element instanceof DebugSession) {
99
- this.viewModel.currentSession = node.element;
100
- this.debugCallStackItemTypeKey.set('session');
101
- } else if (node.element instanceof DebugThread) {
102
- this.viewModel.currentSession = node.element.session;
103
- node.element.session.currentThread = node.element;
104
- this.debugCallStackItemTypeKey.set('thread');
105
- }
106
- }
107
- } finally {
108
- this.updatingSelection = false;
109
- }
110
- }
111
-
112
- protected override toContextMenuArgs(node: SelectableTreeNode): [number] | undefined {
113
- if (TreeElementNode.is(node) && node.element instanceof DebugThread) {
114
- return [node.element.raw.id];
115
- }
116
- return undefined;
117
- }
118
-
119
- protected override getDefaultNodeStyle(node: TreeNode, props: NodeProps): React.CSSProperties | undefined {
120
- if (this.threads.multiSession) {
121
- return super.getDefaultNodeStyle(node, props);
122
- }
123
- return undefined;
124
- }
125
-
126
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject, postConstruct, interfaces, Container } from '@theia/core/shared/inversify';
18
+ import { MenuPath } from '@theia/core';
19
+ import { TreeNode, NodeProps, SelectableTreeNode } from '@theia/core/lib/browser';
20
+ import { SourceTreeWidget, TreeElementNode } from '@theia/core/lib/browser/source-tree';
21
+ import { DebugThreadsSource } from './debug-threads-source';
22
+ import { DebugSession } from '../debug-session';
23
+ import { DebugThread } from '../model/debug-thread';
24
+ import { DebugViewModel } from '../view/debug-view-model';
25
+ import { DebugCallStackItemTypeKey } from '../debug-call-stack-item-type-key';
26
+ import { nls } from '@theia/core/lib/common/nls';
27
+
28
+ @injectable()
29
+ export class DebugThreadsWidget extends SourceTreeWidget {
30
+
31
+ static CONTEXT_MENU: MenuPath = ['debug-threads-context-menu'];
32
+ static CONTROL_MENU = [...DebugThreadsWidget.CONTEXT_MENU, 'a_control'];
33
+ static TERMINATE_MENU = [...DebugThreadsWidget.CONTEXT_MENU, 'b_terminate'];
34
+ static OPEN_MENU = [...DebugThreadsWidget.CONTEXT_MENU, 'c_open'];
35
+ static FACTORY_ID = 'debug:threads';
36
+ static override createContainer(parent: interfaces.Container): Container {
37
+ const child = SourceTreeWidget.createContainer(parent, {
38
+ contextMenuPath: DebugThreadsWidget.CONTEXT_MENU,
39
+ virtualized: false,
40
+ scrollIfActive: true
41
+ });
42
+ child.bind(DebugThreadsSource).toSelf();
43
+ child.unbind(SourceTreeWidget);
44
+ child.bind(DebugThreadsWidget).toSelf();
45
+ return child;
46
+ }
47
+ static createWidget(parent: interfaces.Container): DebugThreadsWidget {
48
+ return DebugThreadsWidget.createContainer(parent).get(DebugThreadsWidget);
49
+ }
50
+
51
+ @inject(DebugThreadsSource)
52
+ protected readonly threads: DebugThreadsSource;
53
+
54
+ @inject(DebugViewModel)
55
+ protected readonly viewModel: DebugViewModel;
56
+
57
+ @inject(DebugCallStackItemTypeKey)
58
+ protected readonly debugCallStackItemTypeKey: DebugCallStackItemTypeKey;
59
+
60
+ @postConstruct()
61
+ protected override init(): void {
62
+ super.init();
63
+ this.id = DebugThreadsWidget.FACTORY_ID + ':' + this.viewModel.id;
64
+ this.title.label = nls.localize('theia/debug/threads', 'Threads');
65
+ this.toDispose.push(this.threads);
66
+ this.source = this.threads;
67
+
68
+ this.toDispose.push(this.viewModel.onDidChange(() => this.updateWidgetSelection()));
69
+ this.toDispose.push(this.model.onSelectionChanged(() => this.updateModelSelection()));
70
+ }
71
+
72
+ protected updatingSelection = false;
73
+ protected updateWidgetSelection(): void {
74
+ if (this.updatingSelection) {
75
+ return;
76
+ }
77
+ this.updatingSelection = true;
78
+ try {
79
+ const { currentThread } = this.viewModel;
80
+ if (currentThread) {
81
+ const node = this.model.getNode(currentThread.id);
82
+ if (SelectableTreeNode.is(node)) {
83
+ this.model.selectNode(node);
84
+ }
85
+ }
86
+ } finally {
87
+ this.updatingSelection = false;
88
+ }
89
+ }
90
+ protected updateModelSelection(): void {
91
+ if (this.updatingSelection) {
92
+ return;
93
+ }
94
+ this.updatingSelection = true;
95
+ try {
96
+ const node = this.model.selectedNodes[0];
97
+ if (TreeElementNode.is(node)) {
98
+ if (node.element instanceof DebugSession) {
99
+ this.viewModel.currentSession = node.element;
100
+ this.debugCallStackItemTypeKey.set('session');
101
+ } else if (node.element instanceof DebugThread) {
102
+ this.viewModel.currentSession = node.element.session;
103
+ node.element.session.currentThread = node.element;
104
+ this.debugCallStackItemTypeKey.set('thread');
105
+ }
106
+ }
107
+ } finally {
108
+ this.updatingSelection = false;
109
+ }
110
+ }
111
+
112
+ protected override toContextMenuArgs(node: SelectableTreeNode): [number] | undefined {
113
+ if (TreeElementNode.is(node) && node.element instanceof DebugThread) {
114
+ return [node.element.raw.id];
115
+ }
116
+ return undefined;
117
+ }
118
+
119
+ protected override getDefaultNodeStyle(node: TreeNode, props: NodeProps): React.CSSProperties | undefined {
120
+ if (this.threads.multiSession) {
121
+ return super.getDefaultNodeStyle(node, props);
122
+ }
123
+ return undefined;
124
+ }
125
+
126
+ }
@@ -1,145 +1,145 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 Red Hat, Inc. 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import * as React from '@theia/core/shared/react';
18
- import { inject, postConstruct, injectable } from '@theia/core/shared/inversify';
19
- import { CommandMenuNode, CommandRegistry, CompoundMenuNode, Disposable, DisposableCollection, MenuModelRegistry, MenuPath } from '@theia/core';
20
- import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
21
- import { ReactWidget } from '@theia/core/lib/browser/widgets';
22
- import { DebugViewModel } from './debug-view-model';
23
- import { DebugState } from '../debug-session';
24
- import { DebugAction } from './debug-action';
25
- import { nls } from '@theia/core/lib/common/nls';
26
-
27
- @injectable()
28
- export class DebugToolBar extends ReactWidget {
29
-
30
- static readonly MENU: MenuPath = ['debug-toolbar-menu'];
31
-
32
- @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
33
- @inject(MenuModelRegistry) protected readonly menuModelRegistry: MenuModelRegistry;
34
- @inject(ContextKeyService) protected readonly contextKeyService: ContextKeyService;
35
- @inject(DebugViewModel) protected readonly model: DebugViewModel;
36
-
37
- protected readonly onRender = new DisposableCollection();
38
-
39
- @postConstruct()
40
- protected init(): void {
41
- this.id = 'debug:toolbar:' + this.model.id;
42
- this.addClass('debug-toolbar');
43
- this.toDispose.push(this.model);
44
- this.toDispose.push(this.model.onDidChange(() => this.update()));
45
- this.scrollOptions = undefined;
46
- this.update();
47
- }
48
-
49
- focus(): void {
50
- if (!this.doFocus()) {
51
- this.onRender.push(Disposable.create(() => this.doFocus()));
52
- this.update();
53
- }
54
- }
55
- protected doFocus(): boolean {
56
- if (!this.stepRef) {
57
- return false;
58
- }
59
- this.stepRef.focus();
60
- return true;
61
- }
62
- protected stepRef: DebugAction | undefined;
63
- protected setStepRef = (stepRef: DebugAction | null) => {
64
- this.stepRef = stepRef || undefined;
65
- this.onRender.dispose();
66
- };
67
-
68
- protected render(): React.ReactNode {
69
- const { state } = this.model;
70
- return <React.Fragment>
71
- {this.renderContributedCommands()}
72
- {this.renderContinue()}
73
- <DebugAction enabled={state === DebugState.Stopped} run={this.stepOver} label={nls.localizeByDefault('Step Over')}
74
- iconClass='debug-step-over' ref={this.setStepRef} />
75
- <DebugAction enabled={state === DebugState.Stopped} run={this.stepIn} label={nls.localizeByDefault('Step Into')}
76
- iconClass='debug-step-into' />
77
- <DebugAction enabled={state === DebugState.Stopped} run={this.stepOut} label={nls.localizeByDefault('Step Out')}
78
- iconClass='debug-step-out' />
79
- <DebugAction enabled={state !== DebugState.Inactive} run={this.restart} label={nls.localizeByDefault('Restart')}
80
- iconClass='debug-restart' />
81
- {this.renderStart()}
82
- </React.Fragment>;
83
- }
84
-
85
- protected renderContributedCommands(): React.ReactNode {
86
- const debugActions: React.ReactNode[] = [];
87
- // first, search for CompoundMenuNodes:
88
- this.menuModelRegistry.getMenu(DebugToolBar.MENU).children.forEach(compoundMenuNode => {
89
- if (CompoundMenuNode.is(compoundMenuNode) && this.matchContext(compoundMenuNode.when)) {
90
- // second, search for nested CommandMenuNodes:
91
- compoundMenuNode.children.forEach(commandMenuNode => {
92
- if (CommandMenuNode.is(commandMenuNode) && this.matchContext(commandMenuNode.when)) {
93
- debugActions.push(this.debugAction(commandMenuNode));
94
- }
95
- });
96
- }
97
- });
98
- return debugActions;
99
- }
100
-
101
- protected matchContext(when?: string): boolean {
102
- return !when || this.contextKeyService.match(when);
103
- }
104
-
105
- protected debugAction(commandMenuNode: CommandMenuNode): React.ReactNode {
106
- const { command, icon = '', label = '' } = commandMenuNode;
107
- if (!label && !icon) {
108
- const { when } = commandMenuNode;
109
- console.warn(`Neither 'label' nor 'icon' properties were defined for the command menu node. (${JSON.stringify({ command, when })}}. Skipping.`);
110
- return;
111
- }
112
- const run = () => this.commandRegistry.executeCommand(command);
113
- return <DebugAction
114
- key={command}
115
- enabled={true}
116
- label={label}
117
- iconClass={icon}
118
- run={run} />;
119
- }
120
-
121
- protected renderStart(): React.ReactNode {
122
- const { state } = this.model;
123
- if (state === DebugState.Inactive && this.model.sessionCount === 1) {
124
- return <DebugAction run={this.start} label={nls.localizeByDefault('Start')} iconClass='debug-start' />;
125
- }
126
- return <DebugAction enabled={state !== DebugState.Inactive} run={this.stop} label={nls.localizeByDefault('Stop')} iconClass='debug-stop' />;
127
- }
128
- protected renderContinue(): React.ReactNode {
129
- const { state } = this.model;
130
- if (state === DebugState.Stopped) {
131
- return <DebugAction run={this.continue} label={nls.localizeByDefault('Continue')} iconClass='debug-continue' />;
132
- }
133
- return <DebugAction enabled={state === DebugState.Running} run={this.pause} label={nls.localizeByDefault('Pause')} iconClass='debug-pause' />;
134
- }
135
-
136
- protected start = () => this.model.start();
137
- protected restart = () => this.model.restart();
138
- protected stop = () => this.model.terminate();
139
- protected continue = () => this.model.currentThread && this.model.currentThread.continue();
140
- protected pause = () => this.model.currentThread && this.model.currentThread.pause();
141
- protected stepOver = () => this.model.currentThread && this.model.currentThread.stepOver();
142
- protected stepIn = () => this.model.currentThread && this.model.currentThread.stepIn();
143
- protected stepOut = () => this.model.currentThread && this.model.currentThread.stepOut();
144
-
145
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 Red Hat, Inc. 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import * as React from '@theia/core/shared/react';
18
+ import { inject, postConstruct, injectable } from '@theia/core/shared/inversify';
19
+ import { CommandMenuNode, CommandRegistry, CompoundMenuNode, Disposable, DisposableCollection, MenuModelRegistry, MenuPath } from '@theia/core';
20
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
21
+ import { ReactWidget } from '@theia/core/lib/browser/widgets';
22
+ import { DebugViewModel } from './debug-view-model';
23
+ import { DebugState } from '../debug-session';
24
+ import { DebugAction } from './debug-action';
25
+ import { nls } from '@theia/core/lib/common/nls';
26
+
27
+ @injectable()
28
+ export class DebugToolBar extends ReactWidget {
29
+
30
+ static readonly MENU: MenuPath = ['debug-toolbar-menu'];
31
+
32
+ @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
33
+ @inject(MenuModelRegistry) protected readonly menuModelRegistry: MenuModelRegistry;
34
+ @inject(ContextKeyService) protected readonly contextKeyService: ContextKeyService;
35
+ @inject(DebugViewModel) protected readonly model: DebugViewModel;
36
+
37
+ protected readonly onRender = new DisposableCollection();
38
+
39
+ @postConstruct()
40
+ protected init(): void {
41
+ this.id = 'debug:toolbar:' + this.model.id;
42
+ this.addClass('debug-toolbar');
43
+ this.toDispose.push(this.model);
44
+ this.toDispose.push(this.model.onDidChange(() => this.update()));
45
+ this.scrollOptions = undefined;
46
+ this.update();
47
+ }
48
+
49
+ focus(): void {
50
+ if (!this.doFocus()) {
51
+ this.onRender.push(Disposable.create(() => this.doFocus()));
52
+ this.update();
53
+ }
54
+ }
55
+ protected doFocus(): boolean {
56
+ if (!this.stepRef) {
57
+ return false;
58
+ }
59
+ this.stepRef.focus();
60
+ return true;
61
+ }
62
+ protected stepRef: DebugAction | undefined;
63
+ protected setStepRef = (stepRef: DebugAction | null) => {
64
+ this.stepRef = stepRef || undefined;
65
+ this.onRender.dispose();
66
+ };
67
+
68
+ protected render(): React.ReactNode {
69
+ const { state } = this.model;
70
+ return <React.Fragment>
71
+ {this.renderContributedCommands()}
72
+ {this.renderContinue()}
73
+ <DebugAction enabled={state === DebugState.Stopped} run={this.stepOver} label={nls.localizeByDefault('Step Over')}
74
+ iconClass='debug-step-over' ref={this.setStepRef} />
75
+ <DebugAction enabled={state === DebugState.Stopped} run={this.stepIn} label={nls.localizeByDefault('Step Into')}
76
+ iconClass='debug-step-into' />
77
+ <DebugAction enabled={state === DebugState.Stopped} run={this.stepOut} label={nls.localizeByDefault('Step Out')}
78
+ iconClass='debug-step-out' />
79
+ <DebugAction enabled={state !== DebugState.Inactive} run={this.restart} label={nls.localizeByDefault('Restart')}
80
+ iconClass='debug-restart' />
81
+ {this.renderStart()}
82
+ </React.Fragment>;
83
+ }
84
+
85
+ protected renderContributedCommands(): React.ReactNode {
86
+ const debugActions: React.ReactNode[] = [];
87
+ // first, search for CompoundMenuNodes:
88
+ this.menuModelRegistry.getMenu(DebugToolBar.MENU).children.forEach(compoundMenuNode => {
89
+ if (CompoundMenuNode.is(compoundMenuNode) && this.matchContext(compoundMenuNode.when)) {
90
+ // second, search for nested CommandMenuNodes:
91
+ compoundMenuNode.children.forEach(commandMenuNode => {
92
+ if (CommandMenuNode.is(commandMenuNode) && this.matchContext(commandMenuNode.when)) {
93
+ debugActions.push(this.debugAction(commandMenuNode));
94
+ }
95
+ });
96
+ }
97
+ });
98
+ return debugActions;
99
+ }
100
+
101
+ protected matchContext(when?: string): boolean {
102
+ return !when || this.contextKeyService.match(when);
103
+ }
104
+
105
+ protected debugAction(commandMenuNode: CommandMenuNode): React.ReactNode {
106
+ const { command, icon = '', label = '' } = commandMenuNode;
107
+ if (!label && !icon) {
108
+ const { when } = commandMenuNode;
109
+ console.warn(`Neither 'label' nor 'icon' properties were defined for the command menu node. (${JSON.stringify({ command, when })}}. Skipping.`);
110
+ return;
111
+ }
112
+ const run = () => this.commandRegistry.executeCommand(command);
113
+ return <DebugAction
114
+ key={command}
115
+ enabled={true}
116
+ label={label}
117
+ iconClass={icon}
118
+ run={run} />;
119
+ }
120
+
121
+ protected renderStart(): React.ReactNode {
122
+ const { state } = this.model;
123
+ if (state === DebugState.Inactive && this.model.sessionCount === 1) {
124
+ return <DebugAction run={this.start} label={nls.localizeByDefault('Start')} iconClass='debug-start' />;
125
+ }
126
+ return <DebugAction enabled={state !== DebugState.Inactive} run={this.stop} label={nls.localizeByDefault('Stop')} iconClass='debug-stop' />;
127
+ }
128
+ protected renderContinue(): React.ReactNode {
129
+ const { state } = this.model;
130
+ if (state === DebugState.Stopped) {
131
+ return <DebugAction run={this.continue} label={nls.localizeByDefault('Continue')} iconClass='debug-continue' />;
132
+ }
133
+ return <DebugAction enabled={state === DebugState.Running} run={this.pause} label={nls.localizeByDefault('Pause')} iconClass='debug-pause' />;
134
+ }
135
+
136
+ protected start = () => this.model.start();
137
+ protected restart = () => this.model.restart();
138
+ protected stop = () => this.model.terminate();
139
+ protected continue = () => this.model.currentThread && this.model.currentThread.continue();
140
+ protected pause = () => this.model.currentThread && this.model.currentThread.pause();
141
+ protected stepOver = () => this.model.currentThread && this.model.currentThread.stepOver();
142
+ protected stepIn = () => this.model.currentThread && this.model.currentThread.stepIn();
143
+ protected stepOut = () => this.model.currentThread && this.model.currentThread.stepOut();
144
+
145
+ }
@@ -1,43 +1,43 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
- import { TreeSource } from '@theia/core/lib/browser/source-tree';
19
- import { DebugScope } from '../console/debug-console-items';
20
- import { DebugViewModel } from './debug-view-model';
21
- import debounce = require('p-debounce');
22
-
23
- @injectable()
24
- export class DebugVariablesSource extends TreeSource {
25
-
26
- @inject(DebugViewModel)
27
- protected readonly model: DebugViewModel;
28
-
29
- @postConstruct()
30
- protected init(): void {
31
- this.refresh();
32
- this.toDispose.push(this.model.onDidChange(() => this.refresh()));
33
- }
34
-
35
- protected readonly refresh = debounce(() => this.fireDidChange(), 400);
36
-
37
- async getElements(): Promise<IterableIterator<DebugScope>> {
38
- const { currentSession } = this.model;
39
- const scopes = currentSession ? await currentSession.getScopes() : [];
40
- return scopes[Symbol.iterator]();
41
- }
42
-
43
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
+ import { TreeSource } from '@theia/core/lib/browser/source-tree';
19
+ import { DebugScope } from '../console/debug-console-items';
20
+ import { DebugViewModel } from './debug-view-model';
21
+ import debounce = require('p-debounce');
22
+
23
+ @injectable()
24
+ export class DebugVariablesSource extends TreeSource {
25
+
26
+ @inject(DebugViewModel)
27
+ protected readonly model: DebugViewModel;
28
+
29
+ @postConstruct()
30
+ protected init(): void {
31
+ this.refresh();
32
+ this.toDispose.push(this.model.onDidChange(() => this.refresh()));
33
+ }
34
+
35
+ protected readonly refresh = debounce(() => this.fireDidChange(), 400);
36
+
37
+ async getElements(): Promise<IterableIterator<DebugScope>> {
38
+ const { currentSession } = this.model;
39
+ const scopes = currentSession ? await currentSession.getScopes() : [];
40
+ return scopes[Symbol.iterator]();
41
+ }
42
+
43
+ }