Skip to content

Commit 01f3dee

Browse files
committed
Implement context menu for self wing
1 parent 67141fc commit 01f3dee

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

src/components/shared/FunctionListContextMenu.tsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type StateProps = {
5252
readonly threadsKey: ThreadsKey | null;
5353
readonly rightClickedFunctionIndex: IndexIntoFuncTable | null;
5454
readonly callNodeTable: CallNodeTable | null;
55+
readonly selfWingCallNodeTable: CallNodeTable | null;
5556
readonly implementation: ImplementationFilter;
5657
readonly displaySearchfox: boolean;
5758
};
@@ -86,9 +87,15 @@ class FunctionListContextMenuImpl extends PureComponent<Props> {
8687
readonly threadsKey: ThreadsKey;
8788
readonly funcIndex: IndexIntoFuncTable;
8889
readonly callNodeTable: CallNodeTable;
90+
readonly selfWingCallNodeTable: CallNodeTable | null;
8991
} {
90-
const { thread, threadsKey, rightClickedFunctionIndex, callNodeTable } =
91-
this.props;
92+
const {
93+
thread,
94+
threadsKey,
95+
rightClickedFunctionIndex,
96+
callNodeTable,
97+
selfWingCallNodeTable,
98+
} = this.props;
9299
if (
93100
thread !== null &&
94101
threadsKey !== null &&
@@ -100,6 +107,7 @@ class FunctionListContextMenuImpl extends PureComponent<Props> {
100107
threadsKey,
101108
funcIndex: rightClickedFunctionIndex,
102109
callNodeTable,
110+
selfWingCallNodeTable,
103111
};
104112
}
105113
return null;
@@ -312,7 +320,7 @@ class FunctionListContextMenuImpl extends PureComponent<Props> {
312320
return <div />;
313321
}
314322

315-
const { funcIndex, callNodeTable } = info;
323+
const { funcIndex, callNodeTable, selfWingCallNodeTable } = info;
316324
const nameForResource = this.getNameForSelectedResource();
317325

318326
return (
@@ -371,7 +379,9 @@ class FunctionListContextMenuImpl extends PureComponent<Props> {
371379
})
372380
: null}
373381

374-
{funcHasRecursiveCall(callNodeTable, funcIndex)
382+
{funcHasRecursiveCall(callNodeTable, funcIndex) ||
383+
(selfWingCallNodeTable !== null &&
384+
funcHasRecursiveCall(selfWingCallNodeTable, funcIndex))
375385
? this.renderTransformMenuItem({
376386
l10nId: 'CallNodeContextMenu--transform-collapse-recursion',
377387
shortcut: 'r',
@@ -383,7 +393,9 @@ class FunctionListContextMenuImpl extends PureComponent<Props> {
383393
})
384394
: null}
385395

386-
{funcHasDirectRecursiveCall(callNodeTable, funcIndex)
396+
{funcHasDirectRecursiveCall(callNodeTable, funcIndex) ||
397+
(selfWingCallNodeTable !== null &&
398+
funcHasDirectRecursiveCall(selfWingCallNodeTable, funcIndex))
387399
? this.renderTransformMenuItem({
388400
l10nId:
389401
'CallNodeContextMenu--transform-collapse-direct-recursion-only',
@@ -458,6 +470,7 @@ export const FunctionListContextMenu = explicitConnect<
458470
let threadsKey = null;
459471
let rightClickedFunctionIndex = null;
460472
let callNodeTable = null;
473+
let selfWingCallNodeTable = null;
461474

462475
if (rightClickedFunction !== null) {
463476
const selectors = getThreadSelectorsFromThreadsKey(
@@ -468,13 +481,19 @@ export const FunctionListContextMenu = explicitConnect<
468481
rightClickedFunctionIndex = rightClickedFunction.functionIndex;
469482
// Use the non-inverted call node table for recursion detection.
470483
callNodeTable = selectors.getCallNodeInfo(state).getCallNodeTable();
484+
// Also check the self wing's call node table, which may reveal recursion
485+
// not visible in the regular call node table due to the focusSelf filter.
486+
selfWingCallNodeTable = selectors
487+
.getSelfWingCallNodeInfo(state)
488+
.getCallNodeTable();
471489
}
472490

473491
return {
474492
thread,
475493
threadsKey,
476494
rightClickedFunctionIndex,
477495
callNodeTable,
496+
selfWingCallNodeTable,
478497
implementation: getImplementationFilter(state),
479498
displaySearchfox: getShouldDisplaySearchfox(state),
480499
};

0 commit comments

Comments
 (0)