Skip to content

Commit ae4e32a

Browse files
types in context; drag-n-drop watch
1 parent 2976886 commit ae4e32a

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { Codicon } from '../../../../base/common/codicons.js';
1515
import { FuzzyScore } from '../../../../base/common/filters.js';
1616
import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';
1717
import { localize } from '../../../../nls.js';
18-
import { getContextMenuActions, /*getFlatContextMenuActions*/ } from '../../../../platform/actions/browser/menuEntryActionViewItem.js';
19-
import { Action2, /*IMenu, */IMenuService, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js';
18+
import { getContextMenuActions, } from '../../../../platform/actions/browser/menuEntryActionViewItem.js';
19+
import { Action2, IMenuService, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js';
2020
import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';
2121
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
2222
import { ContextKeyExpr, IContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
@@ -32,7 +32,7 @@ import { ViewAction, ViewPane } from '../../../browser/parts/views/viewPane.js';
3232
import { IViewletViewOptions } from '../../../browser/parts/views/viewsViewlet.js';
3333
import { FocusedViewContext } from '../../../common/contextkeys.js';
3434
import { IViewDescriptorService } from '../../../common/views.js';
35-
import { CONTEXT_CAN_VIEW_MEMORY, CONTEXT_EXPRESSION_SELECTED, CONTEXT_VARIABLE_IS_READONLY, CONTEXT_WATCH_EXPRESSIONS_EXIST, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_WATCH_ITEM_TYPE, IDebugConfiguration, IDebugService, IDebugViewWithVariables, IExpression, CONTEXT_BREAK_WHEN_VALUE_CHANGES_SUPPORTED, CONTEXT_BREAK_WHEN_VALUE_IS_ACCESSED_SUPPORTED, CONTEXT_BREAK_WHEN_VALUE_IS_READ_SUPPORTED, WATCH_VIEW_ID, CONTEXT_DEBUG_TYPE } from '../common/debug.js';
35+
import { CONTEXT_CAN_VIEW_MEMORY, CONTEXT_EXPRESSION_SELECTED, CONTEXT_VARIABLE_IS_READONLY, CONTEXT_WATCH_EXPRESSIONS_EXIST, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_WATCH_ITEM_TYPE, IDebugConfiguration, IDebugService, IDebugViewWithVariables, IExpression, CONTEXT_BREAK_WHEN_VALUE_CHANGES_SUPPORTED, CONTEXT_BREAK_WHEN_VALUE_IS_ACCESSED_SUPPORTED, CONTEXT_BREAK_WHEN_VALUE_IS_READ_SUPPORTED, CONTEXT_VARIABLE_EVALUATE_NAME_PRESENT, WATCH_VIEW_ID, CONTEXT_DEBUG_TYPE } from '../common/debug.js';
3636
import { Expression, Variable, VisualizedExpression } from '../common/debugModel.js';
3737
import { AbstractExpressionDataSource, AbstractExpressionsRenderer, expressionAndScopeLabelProvider, IExpressionTemplateData, IInputBoxOptions, renderViewTree } from './baseDebugView.js';
3838
import { COPY_WATCH_EXPRESSION_COMMAND_ID, setDataBreakpointInfoResponse } from './debugCommands.js';
@@ -50,8 +50,6 @@ export class WatchExpressionsView extends ViewPane implements IDebugViewWithVari
5050
private needsRefresh = false;
5151
private tree!: WorkbenchAsyncDataTree<IDebugService | IExpression, IExpression, FuzzyScore>;
5252
private watchExpressionsExist: IContextKey<boolean>;
53-
private watchItemType: IContextKey<string | undefined>;
54-
private variableReadonly: IContextKey<boolean>;
5553
private expressionRenderer: DebugExpressionRenderer;
5654

5755
public get treeSelection() {
@@ -79,9 +77,7 @@ export class WatchExpressionsView extends ViewPane implements IDebugViewWithVari
7977
this.tree.updateChildren();
8078
}, 50);
8179
this.watchExpressionsExist = CONTEXT_WATCH_EXPRESSIONS_EXIST.bindTo(contextKeyService);
82-
this.variableReadonly = CONTEXT_VARIABLE_IS_READONLY.bindTo(contextKeyService);
8380
this.watchExpressionsExist.set(this.debugService.getModel().getWatchExpressions().length > 0);
84-
this.watchItemType = CONTEXT_WATCH_ITEM_TYPE.bindTo(contextKeyService);
8581
this.expressionRenderer = instantiationService.createInstance(DebugExpressionRenderer);
8682
}
8783

@@ -225,10 +221,6 @@ export class WatchExpressionsView extends ViewPane implements IDebugViewWithVari
225221

226222
const selection = this.tree.getSelection();
227223

228-
this.watchItemType.set(element instanceof Expression ? 'expression' : element instanceof Variable ? 'variable' : undefined);
229-
const attributes = element instanceof Variable ? element.presentationHint?.attributes : undefined;
230-
this.variableReadonly.set(!!attributes && attributes.indexOf('readOnly') >= 0 || !!element?.presentationHint?.lazy);
231-
232224
const contextKeyService = element && await getContextForWatchExpressionMenuWithDataAccess(this.contextKeyService, element);
233225
const menu = this.menuService.getMenuActions(MenuId.DebugWatchContext, contextKeyService, { arg: element, shouldForwardArgs: false });
234226
const { secondary } = getContextMenuActions(menu, 'inline');
@@ -404,8 +396,8 @@ export class WatchExpressionsRenderer extends AbstractExpressionsRenderer {
404396
function getContextForWatchExpressionMenu(parentContext: IContextKeyService, expression: IExpression, additionalContext: [string, unknown][] = []) {
405397
const session = expression.getSession();
406398
return parentContext.createOverlay([
407-
//[CONTEXT_DEBUG_PROTOCOL_VARIABLE_MENU_CONTEXT.key, expression.variableMenuContext || ''],
408-
//[CONTEXT_VARIABLE_EVALUATE_NAME_PRESENT.key, !!expression.evaluateName],
399+
[CONTEXT_VARIABLE_EVALUATE_NAME_PRESENT.key, 'evaluateName' in expression],
400+
[CONTEXT_WATCH_ITEM_TYPE.key, expression instanceof Expression ? 'expression' : expression instanceof Variable ? 'variable' : undefined],
409401
[CONTEXT_CAN_VIEW_MEMORY.key, !!session?.capabilities.supportsReadMemoryRequest && expression.memoryReference !== undefined],
410402
[CONTEXT_VARIABLE_IS_READONLY.key, !!expression.presentationHint?.attributes?.includes('readOnly') || expression.presentationHint?.lazy],
411403
[CONTEXT_DEBUG_TYPE.key, session?.configuration.type],
@@ -423,7 +415,7 @@ async function getContextForWatchExpressionMenuWithDataAccess(parentContext: ICo
423415
}
424416

425417
const contextKeys: [string, unknown][] = [];
426-
const dataBreakpointInfoResponse = await session.dataBreakpointInfo(expression.name);
418+
const dataBreakpointInfoResponse = await session.dataBreakpointInfo('evaluateName' in expression ? expression.evaluateName as string : expression.name);
427419
const dataBreakpointId = dataBreakpointInfoResponse?.dataId;
428420
const dataBreakpointAccessTypes = dataBreakpointInfoResponse?.accessTypes;
429421
setDataBreakpointInfoResponse(dataBreakpointInfoResponse);
@@ -469,6 +461,11 @@ class WatchExpressionsAccessibilityProvider implements IListAccessibilityProvide
469461
class WatchExpressionsDragAndDrop implements ITreeDragAndDrop<IExpression> {
470462

471463
constructor(private debugService: IDebugService) { }
464+
onDragStart?(data: IDragAndDropData, originalEvent: DragEvent): void {
465+
if (data instanceof ElementsDragAndDropData) {
466+
originalEvent.dataTransfer!.setData('text/plain', data.elements[0].name);
467+
}
468+
}
472469

473470
onDragOver(data: IDragAndDropData, targetElement: IExpression | undefined, targetIndex: number | undefined, targetSector: ListViewTargetSector | undefined, originalEvent: DragEvent): boolean | ITreeDragOverReaction {
474471
if (!(data instanceof ElementsDragAndDropData)) {

src/vs/workbench/contrib/debug/common/debugModel.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ export class Expression extends ExpressionContainer implements IExpression {
344344
variablesReference: this.reference || 0,
345345
memoryReference: this.memoryReference,
346346
value: this.value,
347+
type: this.type,
347348
evaluateName: this.name
348349
};
349350
}
@@ -429,13 +430,7 @@ export class Variable extends ExpressionContainer implements IExpression {
429430
container: this.parent instanceof Expression
430431
? { expression: this.parent.name }
431432
: (this.parent as (Variable | Scope)).toDebugProtocolObject(),
432-
variable: {
433-
name: this.name,
434-
variablesReference: this.reference || 0,
435-
memoryReference: this.memoryReference,
436-
value: this.value,
437-
evaluateName: this.name
438-
}
433+
variable: this.toDebugProtocolObject()
439434
};
440435
}
441436

@@ -449,6 +444,7 @@ export class Variable extends ExpressionContainer implements IExpression {
449444
variablesReference: this.reference || 0,
450445
memoryReference: this.memoryReference,
451446
value: this.value,
447+
type: this.type,
452448
evaluateName: this.evaluateName
453449
};
454450
}

0 commit comments

Comments
 (0)