@theia/memory-inspector 1.53.0-next.55 → 1.53.0-next.64

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 (40) hide show
  1. package/README.md +71 -71
  2. package/package.json +4 -4
  3. package/src/browser/diff-widget/memory-diff-options-widget.tsx +152 -152
  4. package/src/browser/diff-widget/memory-diff-select-widget.tsx +163 -163
  5. package/src/browser/diff-widget/memory-diff-table-widget.tsx +366 -366
  6. package/src/browser/diff-widget/memory-diff-widget-types.ts +45 -45
  7. package/src/browser/editable-widget/memory-editable-table-widget.tsx +359 -359
  8. package/src/browser/memory-inspector-frontend-contribution.ts +301 -301
  9. package/src/browser/memory-inspector-frontend-module.ts +118 -118
  10. package/src/browser/memory-provider/cdt-gdb-memory-provider.ts +132 -132
  11. package/src/browser/memory-provider/memory-provider-service.ts +86 -86
  12. package/src/browser/memory-provider/memory-provider.spec.ts +23 -23
  13. package/src/browser/memory-provider/memory-provider.ts +119 -119
  14. package/src/browser/memory-widget/memory-options-widget.tsx +738 -738
  15. package/src/browser/memory-widget/memory-table-widget.tsx +625 -625
  16. package/src/browser/memory-widget/memory-widget.ts +114 -114
  17. package/src/browser/register-widget/register-filter-service.ts +76 -76
  18. package/src/browser/register-widget/register-options-widget.tsx +393 -393
  19. package/src/browser/register-widget/register-table-widget.tsx +276 -276
  20. package/src/browser/register-widget/register-widget-types.ts +45 -45
  21. package/src/browser/register-widget/register-widget.css +34 -34
  22. package/src/browser/style/index.css +746 -746
  23. package/src/browser/style/memory-lock.svg +21 -21
  24. package/src/browser/style/memory-view.svg +20 -20
  25. package/src/browser/style/register-lock.svg +29 -29
  26. package/src/browser/style/register-view.svg +28 -28
  27. package/src/browser/utils/memory-commands.ts +76 -76
  28. package/src/browser/utils/memory-hover-renderer.ts +113 -113
  29. package/src/browser/utils/memory-recents.ts +58 -58
  30. package/src/browser/utils/memory-widget-components.tsx +193 -193
  31. package/src/browser/utils/memory-widget-manager.ts +179 -179
  32. package/src/browser/utils/memory-widget-utils.tsx +132 -132
  33. package/src/browser/utils/memory-widget-variable-utils.ts +170 -170
  34. package/src/browser/utils/multi-select-bar.css +61 -61
  35. package/src/browser/utils/multi-select-bar.tsx +75 -75
  36. package/src/browser/wrapper-widgets/memory-dock-panel.ts +51 -51
  37. package/src/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.tsx +38 -38
  38. package/src/browser/wrapper-widgets/memory-layout-widget.tsx +167 -167
  39. package/src/common/util.ts +28 -28
  40. package/src/common/utils.spec.ts +52 -52
@@ -1,301 +1,301 @@
1
- /********************************************************************************
2
- * Copyright (C) 2019 Ericsson 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 { AbstractViewContribution, FrontendApplicationContribution, Widget } from '@theia/core/lib/browser';
18
- import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
19
- import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
20
- import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
21
- import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
22
- import { Command, CommandRegistry, MenuModelRegistry } from '@theia/core/lib/common';
23
- import { Color } from '@theia/core/lib/common/color';
24
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
25
- import { DebugScope, DebugVariable } from '@theia/debug/lib/browser/console/debug-console-items';
26
- import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
27
- import { DebugVariablesWidget } from '@theia/debug/lib/browser/view/debug-variables-widget';
28
- import * as Long from 'long';
29
- import { MemoryEditableTableWidget } from './editable-widget/memory-editable-table-widget';
30
- import { MemoryProviderService } from './memory-provider/memory-provider-service';
31
- import { MemoryTableWidget } from './memory-widget/memory-table-widget';
32
- import { MemoryWidget } from './memory-widget/memory-widget';
33
- import { RegisterTableWidget } from './register-widget/register-table-widget';
34
- import { RegisterWidget } from './register-widget/register-widget-types';
35
- import {
36
- CreateNewMemoryViewCommand, CreateNewRegisterViewCommand, FollowPointerDebugCommand, FollowPointerTableCommand, MemoryCommand,
37
- RegisterSetVariableCommand, ResetModifiedCellCommand, ToggleDiffSelectWidgetVisibilityCommand, ViewVariableInMemoryCommand, ViewVariableInRegisterViewCommand
38
- } from './utils/memory-commands';
39
- import { MemoryWidgetManager } from './utils/memory-widget-manager';
40
- import { VariableRange } from './utils/memory-widget-variable-utils';
41
- import { MemoryDockPanel } from './wrapper-widgets/memory-dock-panel';
42
- import { MemoryLayoutWidget } from './wrapper-widgets/memory-layout-widget';
43
- import { nls } from '@theia/core/lib/common/nls';
44
-
45
- const ONE_HALF_OPACITY = 0.5;
46
-
47
- @injectable()
48
- export class DebugFrontendContribution extends AbstractViewContribution<MemoryLayoutWidget>
49
- implements FrontendApplicationContribution,
50
- TabBarToolbarContribution,
51
- ColorContribution {
52
- @inject(DebugFrontendApplicationContribution) protected readonly debugContribution: DebugFrontendApplicationContribution;
53
- @inject(MemoryWidgetManager) protected readonly memoryWidgetManager: MemoryWidgetManager;
54
- @inject(FrontendApplicationStateService) protected readonly stateService: FrontendApplicationStateService;
55
- @inject(MemoryProviderService) protected readonly memoryProvider: MemoryProviderService;
56
-
57
- constructor() {
58
- super({
59
- widgetId: MemoryLayoutWidget.ID,
60
- widgetName: MemoryLayoutWidget.LABEL,
61
- defaultWidgetOptions: {
62
- area: 'right',
63
- },
64
- toggleCommandId: MemoryCommand.id,
65
- });
66
- }
67
-
68
- @postConstruct()
69
- init(): void {
70
- this.stateService.reachedState('initialized_layout').then(() => {
71
- // Close leftover widgets from previous sessions.
72
- this.memoryWidgetManager.availableWidgets.forEach(widget => {
73
- if (!(widget.parent instanceof MemoryDockPanel)) {
74
- widget.close();
75
- }
76
- });
77
- });
78
- }
79
-
80
- async initializeLayout(): Promise<void> {
81
- await this.openView({ activate: false });
82
- }
83
-
84
- override registerCommands(registry: CommandRegistry): void {
85
- super.registerCommands(registry);
86
- registry.registerCommand(ViewVariableInMemoryCommand, {
87
- execute: async () => {
88
- const { selectedVariable } = this.debugContribution;
89
- const referenceText = this.memoryProvider.formatVariableReference(selectedVariable);
90
- if (referenceText) {
91
- await this.openMemoryWidgetAt(referenceText);
92
- }
93
- },
94
- isVisible: () => {
95
- const { selectedVariable } = this.debugContribution;
96
- return Boolean(this.memoryProvider.supportsVariableReferenceSyntax(selectedVariable) && this.memoryProvider.formatVariableReference(selectedVariable));
97
- },
98
- });
99
- registry.registerCommand(ViewVariableInRegisterViewCommand, {
100
- execute: async () => {
101
- const name = this.debugContribution.selectedVariable?.name;
102
- if (name) {
103
- await this.openRegisterWidgetWithReg(name);
104
- }
105
- },
106
- isVisible: () => {
107
- let { selectedVariable: currentLevel } = this.debugContribution;
108
- if (!currentLevel) {
109
- return false;
110
- }
111
- // Make sure it looks like it has a numerical value.
112
- try { BigInt(currentLevel.value); } catch { return false; }
113
- while (currentLevel.parent instanceof DebugVariable) {
114
- currentLevel = currentLevel.parent;
115
- }
116
- return currentLevel.parent instanceof DebugScope && currentLevel.parent?.['raw']?.name === 'Registers';
117
- },
118
- });
119
- registry.registerCommand(FollowPointerDebugCommand, {
120
- isVisible: () => !!this.isPointer(this.debugContribution.selectedVariable?.type),
121
- isEnabled: () => !!this.isPointer(this.debugContribution.selectedVariable?.type),
122
- execute: async () => {
123
- const name = this.debugContribution.selectedVariable?.name;
124
- if (name) {
125
- await this.openMemoryWidgetAt(name);
126
- }
127
- },
128
- });
129
- registry.registerCommand(ResetModifiedCellCommand, {
130
- isEnabled: (widgetToActOn, address: Long) => Long.isLong(address) && widgetToActOn instanceof MemoryEditableTableWidget,
131
- isVisible: (widgetToActOn, address: Long) => Long.isLong(address) && widgetToActOn instanceof MemoryEditableTableWidget,
132
- execute: (widgetToActOn: MemoryEditableTableWidget, address: Long) => widgetToActOn.resetModifiedValue(address),
133
- });
134
- registry.registerCommand(FollowPointerTableCommand, {
135
- isEnabled: (widgetToActOn, address, variable?: VariableRange) => widgetToActOn instanceof MemoryTableWidget &&
136
- this.isPointer(variable?.type),
137
- isVisible: (widgetToActOn, address, variable?: VariableRange) => widgetToActOn instanceof MemoryTableWidget &&
138
- this.isPointer(variable?.type),
139
- execute: (widgetToActOn: MemoryTableWidget, address, variable: VariableRange) => {
140
- if (variable?.name) {
141
- widgetToActOn.optionsWidget.setAddressAndGo(variable.name);
142
- }
143
- },
144
- });
145
- registry.registerCommand(CreateNewMemoryViewCommand, {
146
- isEnabled: w => this.withWidget(() => true, w),
147
- isVisible: w => this.withWidget(() => true, w),
148
- execute: () => this.memoryWidgetManager.createNewMemoryWidget(),
149
- });
150
- registry.registerCommand(CreateNewRegisterViewCommand, {
151
- isEnabled: w => this.withWidget(() => true, w),
152
- isVisible: w => this.withWidget(() => true, w),
153
- execute: () => this.memoryWidgetManager.createNewMemoryWidget('register'),
154
- });
155
- registry.registerCommand(RegisterSetVariableCommand, {
156
- isEnabled: (widgetToActOn, dVar: DebugVariable) => widgetToActOn instanceof RegisterTableWidget &&
157
- dVar && dVar.supportSetVariable,
158
- isVisible: (widgetToActOn, dVar: DebugVariable) => widgetToActOn instanceof RegisterTableWidget &&
159
- dVar && dVar.supportSetVariable,
160
- execute: (widgetToActOn: RegisterTableWidget, dVar: DebugVariable) => dVar && widgetToActOn.handleSetValue(dVar),
161
- });
162
- registry.registerCommand(ToggleDiffSelectWidgetVisibilityCommand, {
163
- isVisible: widget => this.withWidget(() => this.memoryWidgetManager.canCompare, widget),
164
- execute: (widget: MemoryLayoutWidget) => {
165
- widget.toggleComparisonVisibility();
166
- },
167
- });
168
- }
169
-
170
- protected isPointer(type?: string): boolean {
171
- return !!type?.includes('*');
172
- }
173
-
174
- /**
175
- * @param {string} addressReference Should be the exact string to be used in the address bar. I.e. it must resolve to an address value.
176
- */
177
- protected async openMemoryWidgetAt(addressReference: string): Promise<MemoryWidget> {
178
- await this.openView({ activate: false });
179
- const newWidget = await this.memoryWidgetManager.createNewMemoryWidget();
180
- await this.shell.activateWidget(newWidget.id);
181
- if (newWidget) {
182
- newWidget.optionsWidget.setAddressAndGo(addressReference);
183
- }
184
- return newWidget;
185
- }
186
-
187
- protected async openRegisterWidgetWithReg(name: string): Promise<MemoryWidget> {
188
- await this.openView({ activate: false });
189
- const newWidget = await this.memoryWidgetManager.createNewMemoryWidget<RegisterWidget>('register');
190
- await this.shell.activateWidget(newWidget.id);
191
- if (newWidget) {
192
- newWidget.optionsWidget.setRegAndUpdate(name);
193
- }
194
- return newWidget;
195
- }
196
-
197
- protected withWidget(fn: (widget: MemoryLayoutWidget) => boolean, widget: Widget | undefined = this.tryGetWidget()): boolean {
198
- if (widget instanceof MemoryLayoutWidget && widget.id === MemoryLayoutWidget.ID) {
199
- return fn(widget);
200
- }
201
- return false;
202
- }
203
-
204
- override registerMenus(registry: MenuModelRegistry): void {
205
- super.registerMenus(registry);
206
- const registerMenuActions = (menuPath: string[], ...commands: Command[]): void => {
207
- for (const [index, command] of commands.entries()) {
208
- registry.registerMenuAction(menuPath, {
209
- commandId: command.id,
210
- label: command.label,
211
- icon: command.iconClass,
212
- order: String.fromCharCode('a'.charCodeAt(0) + index),
213
- });
214
- }
215
- };
216
-
217
- registry.registerMenuAction(
218
- DebugVariablesWidget.WATCH_MENU,
219
- { commandId: ViewVariableInMemoryCommand.id, label: ViewVariableInMemoryCommand.label },
220
- );
221
- registry.registerMenuAction(
222
- DebugVariablesWidget.WATCH_MENU,
223
- { commandId: FollowPointerDebugCommand.id, label: FollowPointerDebugCommand.label },
224
- );
225
- registry.registerMenuAction(
226
- DebugVariablesWidget.WATCH_MENU,
227
- { commandId: ViewVariableInRegisterViewCommand.id, label: ViewVariableInRegisterViewCommand.label },
228
- );
229
- registry.registerMenuAction(
230
- MemoryEditableTableWidget.CONTEXT_MENU,
231
- { commandId: ResetModifiedCellCommand.id, label: ResetModifiedCellCommand.label },
232
- );
233
- registry.registerMenuAction(
234
- MemoryTableWidget.CONTEXT_MENU,
235
- { commandId: FollowPointerTableCommand.id, label: FollowPointerTableCommand.label },
236
- );
237
- registerMenuActions(
238
- RegisterTableWidget.CONTEXT_MENU,
239
- RegisterSetVariableCommand,
240
- );
241
- }
242
-
243
- registerToolbarItems(toolbarRegistry: TabBarToolbarRegistry): void {
244
- toolbarRegistry.registerItem({
245
- id: CreateNewMemoryViewCommand.id,
246
- command: CreateNewMemoryViewCommand.id,
247
- tooltip: CreateNewMemoryViewCommand.label,
248
- priority: -2,
249
- });
250
- toolbarRegistry.registerItem({
251
- id: CreateNewRegisterViewCommand.id,
252
- command: CreateNewRegisterViewCommand.id,
253
- tooltip: CreateNewRegisterViewCommand.label,
254
- priority: -1,
255
- });
256
- toolbarRegistry.registerItem({
257
- id: ToggleDiffSelectWidgetVisibilityCommand.id,
258
- command: ToggleDiffSelectWidgetVisibilityCommand.id,
259
- tooltip: nls.localize('theia/memory-inspector/toggleComparisonWidgetVisibility', 'Toggle Comparison Widget Visibility'),
260
- priority: -3,
261
- onDidChange: this.memoryWidgetManager.onChanged,
262
- });
263
- }
264
-
265
- registerColors(colorRegistry: ColorRegistry): void {
266
- colorRegistry.register(
267
- {
268
- id: 'memoryDiff.removedTextBackground',
269
- defaults: {
270
- dark: Color.transparent('diffEditor.removedTextBackground', ONE_HALF_OPACITY),
271
- light: Color.transparent('diffEditor.removedTextBackground', ONE_HALF_OPACITY),
272
- },
273
- description: 'A less opaque diff color for use in the Memory Inspector where various overlays may me in place at once.',
274
- },
275
- {
276
- id: 'memoryDiff.insertedTextBackground',
277
- defaults: {
278
- dark: Color.transparent('diffEditor.insertedTextBackground', ONE_HALF_OPACITY),
279
- light: Color.transparent('diffEditor.insertedTextBackground', ONE_HALF_OPACITY),
280
- },
281
- description: 'A less opaque diff color for use in the Memory Inspector where various overlays may me in place at once.',
282
- },
283
- {
284
- id: 'memoryInspector.focusBorder',
285
- defaults: {
286
- dark: Color.transparent('focusBorder', ONE_HALF_OPACITY),
287
- light: Color.transparent('focusBorder', ONE_HALF_OPACITY),
288
- },
289
- description: 'A less opaque focus border color for use in the Memory Inspector where several overlays may be in place at once.',
290
- },
291
- {
292
- id: 'memoryInspector.foreground',
293
- defaults: {
294
- dark: Color.transparent('editor.foreground', ONE_HALF_OPACITY),
295
- light: Color.transparent('editor.foreground', ONE_HALF_OPACITY),
296
- },
297
- description: 'A less opaque foreground text style for use in the Memory Inspector',
298
- },
299
- );
300
- }
301
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2019 Ericsson 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 { AbstractViewContribution, FrontendApplicationContribution, Widget } from '@theia/core/lib/browser';
18
+ import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
19
+ import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
20
+ import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
21
+ import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
22
+ import { Command, CommandRegistry, MenuModelRegistry } from '@theia/core/lib/common';
23
+ import { Color } from '@theia/core/lib/common/color';
24
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
25
+ import { DebugScope, DebugVariable } from '@theia/debug/lib/browser/console/debug-console-items';
26
+ import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
27
+ import { DebugVariablesWidget } from '@theia/debug/lib/browser/view/debug-variables-widget';
28
+ import * as Long from 'long';
29
+ import { MemoryEditableTableWidget } from './editable-widget/memory-editable-table-widget';
30
+ import { MemoryProviderService } from './memory-provider/memory-provider-service';
31
+ import { MemoryTableWidget } from './memory-widget/memory-table-widget';
32
+ import { MemoryWidget } from './memory-widget/memory-widget';
33
+ import { RegisterTableWidget } from './register-widget/register-table-widget';
34
+ import { RegisterWidget } from './register-widget/register-widget-types';
35
+ import {
36
+ CreateNewMemoryViewCommand, CreateNewRegisterViewCommand, FollowPointerDebugCommand, FollowPointerTableCommand, MemoryCommand,
37
+ RegisterSetVariableCommand, ResetModifiedCellCommand, ToggleDiffSelectWidgetVisibilityCommand, ViewVariableInMemoryCommand, ViewVariableInRegisterViewCommand
38
+ } from './utils/memory-commands';
39
+ import { MemoryWidgetManager } from './utils/memory-widget-manager';
40
+ import { VariableRange } from './utils/memory-widget-variable-utils';
41
+ import { MemoryDockPanel } from './wrapper-widgets/memory-dock-panel';
42
+ import { MemoryLayoutWidget } from './wrapper-widgets/memory-layout-widget';
43
+ import { nls } from '@theia/core/lib/common/nls';
44
+
45
+ const ONE_HALF_OPACITY = 0.5;
46
+
47
+ @injectable()
48
+ export class DebugFrontendContribution extends AbstractViewContribution<MemoryLayoutWidget>
49
+ implements FrontendApplicationContribution,
50
+ TabBarToolbarContribution,
51
+ ColorContribution {
52
+ @inject(DebugFrontendApplicationContribution) protected readonly debugContribution: DebugFrontendApplicationContribution;
53
+ @inject(MemoryWidgetManager) protected readonly memoryWidgetManager: MemoryWidgetManager;
54
+ @inject(FrontendApplicationStateService) protected readonly stateService: FrontendApplicationStateService;
55
+ @inject(MemoryProviderService) protected readonly memoryProvider: MemoryProviderService;
56
+
57
+ constructor() {
58
+ super({
59
+ widgetId: MemoryLayoutWidget.ID,
60
+ widgetName: MemoryLayoutWidget.LABEL,
61
+ defaultWidgetOptions: {
62
+ area: 'right',
63
+ },
64
+ toggleCommandId: MemoryCommand.id,
65
+ });
66
+ }
67
+
68
+ @postConstruct()
69
+ init(): void {
70
+ this.stateService.reachedState('initialized_layout').then(() => {
71
+ // Close leftover widgets from previous sessions.
72
+ this.memoryWidgetManager.availableWidgets.forEach(widget => {
73
+ if (!(widget.parent instanceof MemoryDockPanel)) {
74
+ widget.close();
75
+ }
76
+ });
77
+ });
78
+ }
79
+
80
+ async initializeLayout(): Promise<void> {
81
+ await this.openView({ activate: false });
82
+ }
83
+
84
+ override registerCommands(registry: CommandRegistry): void {
85
+ super.registerCommands(registry);
86
+ registry.registerCommand(ViewVariableInMemoryCommand, {
87
+ execute: async () => {
88
+ const { selectedVariable } = this.debugContribution;
89
+ const referenceText = this.memoryProvider.formatVariableReference(selectedVariable);
90
+ if (referenceText) {
91
+ await this.openMemoryWidgetAt(referenceText);
92
+ }
93
+ },
94
+ isVisible: () => {
95
+ const { selectedVariable } = this.debugContribution;
96
+ return Boolean(this.memoryProvider.supportsVariableReferenceSyntax(selectedVariable) && this.memoryProvider.formatVariableReference(selectedVariable));
97
+ },
98
+ });
99
+ registry.registerCommand(ViewVariableInRegisterViewCommand, {
100
+ execute: async () => {
101
+ const name = this.debugContribution.selectedVariable?.name;
102
+ if (name) {
103
+ await this.openRegisterWidgetWithReg(name);
104
+ }
105
+ },
106
+ isVisible: () => {
107
+ let { selectedVariable: currentLevel } = this.debugContribution;
108
+ if (!currentLevel) {
109
+ return false;
110
+ }
111
+ // Make sure it looks like it has a numerical value.
112
+ try { BigInt(currentLevel.value); } catch { return false; }
113
+ while (currentLevel.parent instanceof DebugVariable) {
114
+ currentLevel = currentLevel.parent;
115
+ }
116
+ return currentLevel.parent instanceof DebugScope && currentLevel.parent?.['raw']?.name === 'Registers';
117
+ },
118
+ });
119
+ registry.registerCommand(FollowPointerDebugCommand, {
120
+ isVisible: () => !!this.isPointer(this.debugContribution.selectedVariable?.type),
121
+ isEnabled: () => !!this.isPointer(this.debugContribution.selectedVariable?.type),
122
+ execute: async () => {
123
+ const name = this.debugContribution.selectedVariable?.name;
124
+ if (name) {
125
+ await this.openMemoryWidgetAt(name);
126
+ }
127
+ },
128
+ });
129
+ registry.registerCommand(ResetModifiedCellCommand, {
130
+ isEnabled: (widgetToActOn, address: Long) => Long.isLong(address) && widgetToActOn instanceof MemoryEditableTableWidget,
131
+ isVisible: (widgetToActOn, address: Long) => Long.isLong(address) && widgetToActOn instanceof MemoryEditableTableWidget,
132
+ execute: (widgetToActOn: MemoryEditableTableWidget, address: Long) => widgetToActOn.resetModifiedValue(address),
133
+ });
134
+ registry.registerCommand(FollowPointerTableCommand, {
135
+ isEnabled: (widgetToActOn, address, variable?: VariableRange) => widgetToActOn instanceof MemoryTableWidget &&
136
+ this.isPointer(variable?.type),
137
+ isVisible: (widgetToActOn, address, variable?: VariableRange) => widgetToActOn instanceof MemoryTableWidget &&
138
+ this.isPointer(variable?.type),
139
+ execute: (widgetToActOn: MemoryTableWidget, address, variable: VariableRange) => {
140
+ if (variable?.name) {
141
+ widgetToActOn.optionsWidget.setAddressAndGo(variable.name);
142
+ }
143
+ },
144
+ });
145
+ registry.registerCommand(CreateNewMemoryViewCommand, {
146
+ isEnabled: w => this.withWidget(() => true, w),
147
+ isVisible: w => this.withWidget(() => true, w),
148
+ execute: () => this.memoryWidgetManager.createNewMemoryWidget(),
149
+ });
150
+ registry.registerCommand(CreateNewRegisterViewCommand, {
151
+ isEnabled: w => this.withWidget(() => true, w),
152
+ isVisible: w => this.withWidget(() => true, w),
153
+ execute: () => this.memoryWidgetManager.createNewMemoryWidget('register'),
154
+ });
155
+ registry.registerCommand(RegisterSetVariableCommand, {
156
+ isEnabled: (widgetToActOn, dVar: DebugVariable) => widgetToActOn instanceof RegisterTableWidget &&
157
+ dVar && dVar.supportSetVariable,
158
+ isVisible: (widgetToActOn, dVar: DebugVariable) => widgetToActOn instanceof RegisterTableWidget &&
159
+ dVar && dVar.supportSetVariable,
160
+ execute: (widgetToActOn: RegisterTableWidget, dVar: DebugVariable) => dVar && widgetToActOn.handleSetValue(dVar),
161
+ });
162
+ registry.registerCommand(ToggleDiffSelectWidgetVisibilityCommand, {
163
+ isVisible: widget => this.withWidget(() => this.memoryWidgetManager.canCompare, widget),
164
+ execute: (widget: MemoryLayoutWidget) => {
165
+ widget.toggleComparisonVisibility();
166
+ },
167
+ });
168
+ }
169
+
170
+ protected isPointer(type?: string): boolean {
171
+ return !!type?.includes('*');
172
+ }
173
+
174
+ /**
175
+ * @param {string} addressReference Should be the exact string to be used in the address bar. I.e. it must resolve to an address value.
176
+ */
177
+ protected async openMemoryWidgetAt(addressReference: string): Promise<MemoryWidget> {
178
+ await this.openView({ activate: false });
179
+ const newWidget = await this.memoryWidgetManager.createNewMemoryWidget();
180
+ await this.shell.activateWidget(newWidget.id);
181
+ if (newWidget) {
182
+ newWidget.optionsWidget.setAddressAndGo(addressReference);
183
+ }
184
+ return newWidget;
185
+ }
186
+
187
+ protected async openRegisterWidgetWithReg(name: string): Promise<MemoryWidget> {
188
+ await this.openView({ activate: false });
189
+ const newWidget = await this.memoryWidgetManager.createNewMemoryWidget<RegisterWidget>('register');
190
+ await this.shell.activateWidget(newWidget.id);
191
+ if (newWidget) {
192
+ newWidget.optionsWidget.setRegAndUpdate(name);
193
+ }
194
+ return newWidget;
195
+ }
196
+
197
+ protected withWidget(fn: (widget: MemoryLayoutWidget) => boolean, widget: Widget | undefined = this.tryGetWidget()): boolean {
198
+ if (widget instanceof MemoryLayoutWidget && widget.id === MemoryLayoutWidget.ID) {
199
+ return fn(widget);
200
+ }
201
+ return false;
202
+ }
203
+
204
+ override registerMenus(registry: MenuModelRegistry): void {
205
+ super.registerMenus(registry);
206
+ const registerMenuActions = (menuPath: string[], ...commands: Command[]): void => {
207
+ for (const [index, command] of commands.entries()) {
208
+ registry.registerMenuAction(menuPath, {
209
+ commandId: command.id,
210
+ label: command.label,
211
+ icon: command.iconClass,
212
+ order: String.fromCharCode('a'.charCodeAt(0) + index),
213
+ });
214
+ }
215
+ };
216
+
217
+ registry.registerMenuAction(
218
+ DebugVariablesWidget.WATCH_MENU,
219
+ { commandId: ViewVariableInMemoryCommand.id, label: ViewVariableInMemoryCommand.label },
220
+ );
221
+ registry.registerMenuAction(
222
+ DebugVariablesWidget.WATCH_MENU,
223
+ { commandId: FollowPointerDebugCommand.id, label: FollowPointerDebugCommand.label },
224
+ );
225
+ registry.registerMenuAction(
226
+ DebugVariablesWidget.WATCH_MENU,
227
+ { commandId: ViewVariableInRegisterViewCommand.id, label: ViewVariableInRegisterViewCommand.label },
228
+ );
229
+ registry.registerMenuAction(
230
+ MemoryEditableTableWidget.CONTEXT_MENU,
231
+ { commandId: ResetModifiedCellCommand.id, label: ResetModifiedCellCommand.label },
232
+ );
233
+ registry.registerMenuAction(
234
+ MemoryTableWidget.CONTEXT_MENU,
235
+ { commandId: FollowPointerTableCommand.id, label: FollowPointerTableCommand.label },
236
+ );
237
+ registerMenuActions(
238
+ RegisterTableWidget.CONTEXT_MENU,
239
+ RegisterSetVariableCommand,
240
+ );
241
+ }
242
+
243
+ registerToolbarItems(toolbarRegistry: TabBarToolbarRegistry): void {
244
+ toolbarRegistry.registerItem({
245
+ id: CreateNewMemoryViewCommand.id,
246
+ command: CreateNewMemoryViewCommand.id,
247
+ tooltip: CreateNewMemoryViewCommand.label,
248
+ priority: -2,
249
+ });
250
+ toolbarRegistry.registerItem({
251
+ id: CreateNewRegisterViewCommand.id,
252
+ command: CreateNewRegisterViewCommand.id,
253
+ tooltip: CreateNewRegisterViewCommand.label,
254
+ priority: -1,
255
+ });
256
+ toolbarRegistry.registerItem({
257
+ id: ToggleDiffSelectWidgetVisibilityCommand.id,
258
+ command: ToggleDiffSelectWidgetVisibilityCommand.id,
259
+ tooltip: nls.localize('theia/memory-inspector/toggleComparisonWidgetVisibility', 'Toggle Comparison Widget Visibility'),
260
+ priority: -3,
261
+ onDidChange: this.memoryWidgetManager.onChanged,
262
+ });
263
+ }
264
+
265
+ registerColors(colorRegistry: ColorRegistry): void {
266
+ colorRegistry.register(
267
+ {
268
+ id: 'memoryDiff.removedTextBackground',
269
+ defaults: {
270
+ dark: Color.transparent('diffEditor.removedTextBackground', ONE_HALF_OPACITY),
271
+ light: Color.transparent('diffEditor.removedTextBackground', ONE_HALF_OPACITY),
272
+ },
273
+ description: 'A less opaque diff color for use in the Memory Inspector where various overlays may me in place at once.',
274
+ },
275
+ {
276
+ id: 'memoryDiff.insertedTextBackground',
277
+ defaults: {
278
+ dark: Color.transparent('diffEditor.insertedTextBackground', ONE_HALF_OPACITY),
279
+ light: Color.transparent('diffEditor.insertedTextBackground', ONE_HALF_OPACITY),
280
+ },
281
+ description: 'A less opaque diff color for use in the Memory Inspector where various overlays may me in place at once.',
282
+ },
283
+ {
284
+ id: 'memoryInspector.focusBorder',
285
+ defaults: {
286
+ dark: Color.transparent('focusBorder', ONE_HALF_OPACITY),
287
+ light: Color.transparent('focusBorder', ONE_HALF_OPACITY),
288
+ },
289
+ description: 'A less opaque focus border color for use in the Memory Inspector where several overlays may be in place at once.',
290
+ },
291
+ {
292
+ id: 'memoryInspector.foreground',
293
+ defaults: {
294
+ dark: Color.transparent('editor.foreground', ONE_HALF_OPACITY),
295
+ light: Color.transparent('editor.foreground', ONE_HALF_OPACITY),
296
+ },
297
+ description: 'A less opaque foreground text style for use in the Memory Inspector',
298
+ },
299
+ );
300
+ }
301
+ }