forked from microsoft/pxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebuggerCallStack.tsx
More file actions
54 lines (42 loc) · 1.86 KB
/
debuggerCallStack.tsx
File metadata and controls
54 lines (42 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as React from "react";
import { DebuggerTable, DebuggerTableRow } from "./debuggerTable";
export interface DebuggerCallStackProps {
stackframes: pxsim.StackFrameInfo[];
activeFrame?: number;
openLocation?: (breakpoint: number, frameIndex: number) => void;
}
export interface DebuggerCallStackState {
}
export class DebuggerCallStack extends React.Component<DebuggerCallStackProps, DebuggerCallStackState> {
constructor(props: DebuggerCallStackProps) {
super(props);
}
render() {
return (
<DebuggerTable header={lf("Call Stack")}>
{this.props.stackframes.map((sf, index) => {
if (!sf.breakpointId) return null;
const key = sf.breakpointId + "_" + index
let fileName = sf.funcInfo.fileName as string;
if (fileName.indexOf("pxt_modules/") === 0) fileName = fileName.slice(12);
return <DebuggerTableRow key={key}
refID={key}
onClick={this.handleRowClick}
leftText={sf.funcInfo.functionName}
rightText={`${fileName}:${sf.funcInfo.line}`}
icon={index === this.props.activeFrame ? "arrow right" : undefined}
rowClass="callstack-row" />
}
)}
</DebuggerTable>
);
}
protected handleRowClick = (e: React.SyntheticEvent<HTMLDivElement>, component: DebuggerTableRow) => {
if (!this.props.openLocation) return;
const [id, index] = (component.props.refID as string).split("_").map(n => parseInt(n));
const stackFrame = this.props.stackframes[index];
if (stackFrame && stackFrame.breakpointId === id) {
this.props.openLocation(stackFrame.breakpointId, index);
}
}
}