Created
March 14, 2022 16:35
-
-
Save jasonLaster/955b6eef959948f29f38359cf7257c96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/devtools/client/debugger/src/actions/source-actors.js b/src/devtools/client/debugger/src/actions/source-actors.js | |
index 3ebf949ff..a15dcfe4a 100644 | |
--- a/src/devtools/client/debugger/src/actions/source-actors.js | |
+++ b/src/devtools/client/debugger/src/actions/source-actors.js | |
@@ -33,6 +33,29 @@ export function removeSourceActors(items) { | |
}; | |
} | |
+export const loadSourceActorBreakpointHits = memoizeableAction("loadSourceActorBreakpointHits", { | |
+ createKey: ({ id, line }) => `${id}:${line}`, | |
+ getValue: ({ id, line }, { getState }) => getSourceActorBreakpointColumns(getState(), id, line), | |
+ action: async ({ id, line }, { dispatch, getState, client }) => { | |
+ await dispatch({ | |
+ type: "SET_SOURCE_ACTOR_BREAKPOINT_HITS", | |
+ sourceId: id, | |
+ line, | |
+ [PROMISE]: (async () => { | |
+ const positions = await client.getSourceActorBreakpointPositions( | |
+ getSourceActor(getState(), id), | |
+ { | |
+ start: { line, column: 0 }, | |
+ end: { line: line + 1, column: 0 }, | |
+ } | |
+ ); | |
+ | |
+ return positions[line] || []; | |
+ })(), | |
+ }); | |
+ }, | |
+}); | |
+ | |
export const loadSourceActorBreakpointColumns = memoizeableAction( | |
"loadSourceActorBreakpointColumns", | |
{ | |
diff --git a/src/devtools/client/debugger/src/actions/sources/select.js b/src/devtools/client/debugger/src/actions/sources/select.js | |
index 8ed977700..2855a410f 100644 | |
--- a/src/devtools/client/debugger/src/actions/sources/select.js | |
+++ b/src/devtools/client/debugger/src/actions/sources/select.js | |
@@ -131,6 +131,9 @@ export function selectLocation(cx, location, { keepContext = true } = {}) { | |
await dispatch(loadSourceText({ source })); | |
await dispatch(setBreakableLines(cx, source.id)); | |
+ // TODO: implement loading breakpoint hits | |
+ await dispatch(setBreakpointHits(cx, source.id)); | |
+ | |
// Set shownSource to null first, then the actual source to trigger | |
// a proper re-render in the SourcesTree component | |
dispatch({ type: "SHOW_SOURCE", source: null }); | |
diff --git a/src/devtools/client/debugger/src/client/commands.js b/src/devtools/client/debugger/src/client/commands.js | |
index 7ae3c31be..f00285f23 100644 | |
--- a/src/devtools/client/debugger/src/client/commands.js | |
+++ b/src/devtools/client/debugger/src/client/commands.js | |
@@ -320,6 +320,10 @@ function getMainThread() { | |
return currentThreadFront.actor; | |
} | |
+async function getSourceActorBreakpointHits({ actor }, range) { | |
+ return await ThreadFront.getBreakpointHits(actor, range); | |
+} | |
+ | |
async function getSourceActorBreakpointPositions({ actor }, range) { | |
const linePositions = await ThreadFront.getBreakpointPositionsCompressed(actor, range); | |
const rv = {}; | |
@@ -358,6 +362,7 @@ const clientCommands = { | |
reverseStepOver, | |
sourceContents, | |
getSourceForActor, | |
+ getSourceActorBreakpointHits, | |
getSourceActorBreakpointPositions, | |
getSourceActorBreakableLines, | |
hasBreakpoint, | |
diff --git a/src/devtools/client/debugger/src/components/Editor/LineNumberTooltip.tsx b/src/devtools/client/debugger/src/components/Editor/LineNumberTooltip.tsx | |
index f0b637b62..9d7753a98 100644 | |
--- a/src/devtools/client/debugger/src/components/Editor/LineNumberTooltip.tsx | |
+++ b/src/devtools/client/debugger/src/components/Editor/LineNumberTooltip.tsx | |
@@ -73,38 +73,41 @@ export default function LineNumberTooltip({ | |
}) { | |
const dispatch = useDispatch(); | |
const [targetNode, setTargetNode] = useState<HTMLElement | null>(null); | |
+ const [hoveredLine, setHoveredLine] = useState<null | number>(null); | |
const lastHoveredLineNumber = useRef<number | null>(null); | |
const isMetaActive = keyModifiers.meta; | |
const indexed = useSelector(selectors.getIndexed); | |
- const analysisPoints = useSelector(selectors.getPointsForHoveredLineNumber); | |
- | |
- const setHoveredLineNumber = ({ | |
- lineNumber, | |
- lineNode, | |
- }: { | |
- lineNumber: number; | |
- lineNode: HTMLElement; | |
- }) => { | |
- // The gutter re-renders when we click the line number to add | |
- // a breakpoint. That triggers a second gutterLineEnter event | |
- // for the same line number. In that case, we shouldn't run | |
- // the analysis again. | |
- if (lineNumber !== lastHoveredLineNumber.current) { | |
- lastHoveredLineNumber.current = lineNumber; | |
- setTimeout(() => { | |
- if (lineNumber === lastHoveredLineNumber.current) { | |
- dispatch(runAnalysisOnLine(lineNumber)); | |
- } | |
- }, 200); | |
- } | |
- | |
- dispatch(updateHoveredLineNumber(lineNumber)); | |
- setTargetNode(lineNode); | |
- }; | |
+ // const analysisPoints = useSelector(selectors.getPointsForHoveredLineNumber); | |
+ const hitCounts = useSelector(selectors.getCurrenthitCounts); | |
+ | |
+ // const setHoveredLineNumber = ({ | |
+ // lineNumber, | |
+ // lineNode, | |
+ // }: { | |
+ // lineNumber: number; | |
+ // lineNode: HTMLElement; | |
+ // }) => { | |
+ // // The gutter re-renders when we click the line number to add | |
+ // // a breakpoint. That triggers a second gutterLineEnter event | |
+ // // for the same line number. In that case, we shouldn't run | |
+ // // the analysis again. | |
+ // if (lineNumber !== lastHoveredLineNumber.current) { | |
+ // lastHoveredLineNumber.current = lineNumber; | |
+ // setHoveredLine(lineNumber); | |
+ // // setTimeout(() => { | |
+ // // if (lineNumber === lastHoveredLineNumber.current) { | |
+ // // dispatch(runAnalysisOnLine(lineNumber)); | |
+ // // } | |
+ // // }, 200); | |
+ // } | |
+ | |
+ // // dispatch(updateHoveredLineNumber(lineNumber)); | |
+ // setTargetNode(lineNode); | |
+ // }; | |
const clearHoveredLineNumber = () => { | |
setTargetNode(null); | |
- dispatch(setHoveredLineNumberLocation(null)); | |
+ // dispatch(setHoveredLineNumberLocation(null)); | |
}; | |
useEffect(() => { | |
@@ -116,20 +119,20 @@ export default function LineNumberTooltip({ | |
}; | |
}, []); | |
- useEffect(() => { | |
- if (analysisPoints) { | |
- trackEvent( | |
- analysisPoints.length ? "breakpoint.preview_has_hits" : "breakpoint.preview_no_hits" | |
- ); | |
- trackEvent("breakpoint.preview_hits", { hitsCount: analysisPoints?.length || null }); | |
- } | |
- }, [analysisPoints]); | |
+ // useEffect(() => { | |
+ // if (analysisPoints) { | |
+ // trackEvent( | |
+ // analysisPoints.length ? "breakpoint.preview_has_hits" : "breakpoint.preview_no_hits" | |
+ // ); | |
+ trackEvent("breakpoint.preview_hits", { hitsCount }); | |
+ // } | |
+ // }, [analysisPoints]); | |
if (!targetNode || isMetaActive) { | |
return null; | |
} | |
- if (!indexed || !analysisPoints) { | |
+ if (!indexed || !indexed) { | |
return ( | |
<StaticTooltip targetNode={targetNode}> | |
<Wrapper loading>{!indexed ? "Indexing…" : "Loading…"}</Wrapper> | |
@@ -137,7 +140,7 @@ export default function LineNumberTooltip({ | |
); | |
} | |
- const { text, showWarning } = getTextAndWarning(analysisPoints); | |
+ const { text, showWarning } = getTextAndWarning(hitCounts); | |
return ( | |
<StaticTooltip targetNode={targetNode}> | |
<Wrapper showWarning={showWarning}>{text}</Wrapper> | |
diff --git a/src/devtools/client/debugger/src/reducers/source-actors.js b/src/devtools/client/debugger/src/reducers/source-actors.js | |
index 031e0382f..59f0c5f9e 100644 | |
--- a/src/devtools/client/debugger/src/reducers/source-actors.js | |
+++ b/src/devtools/client/debugger/src/reducers/source-actors.js | |
@@ -47,6 +47,10 @@ export default function update(state = initial, action) { | |
break; | |
} | |
+ case "SET_SOURCE_ACTOR_BREAKPOINT_HITS": | |
+ state = updateBreakpointHits(state, action); | |
+ break; | |
+ | |
case "SET_SOURCE_ACTOR_BREAKPOINT_COLUMNS": | |
state = updateBreakpointColumns(state, action); | |
break; | |
@@ -76,6 +80,7 @@ function clearSourceActorMapURL(state, id) { | |
]); | |
} | |
+// YO | |
function updateBreakpointColumns(state, action) { | |
const { sourceId, line } = action; | |
const value = asyncActionAsValue(action); | |
@@ -179,6 +184,12 @@ export function getSourceActorBreakpointColumns(state, id, line) { | |
return asSettled(breakpointPositions.get(line) || null); | |
} | |
+export function getSourceActorBreakpointHits(state, id, line) { | |
+ const { breakpointPositions } = getResource(state.sourceActors, id); | |
+ | |
+ return asSettled(breakpointPositions.get(line) || null); | |
+} | |
+ | |
export const getBreakableLinesForSourceActors = makeWeakQuery({ | |
filter: (state, ids) => ids, | |
map: ({ breakableLines }) => breakableLines, | |
diff --git a/src/protocol/thread/thread.ts b/src/protocol/thread/thread.ts | |
index 80d091317..ea1e7b1e4 100644 | |
--- a/src/protocol/thread/thread.ts | |
+++ b/src/protocol/thread/thread.ts | |
@@ -464,6 +464,16 @@ class _ThreadFront { | |
return { contents, contentType }; | |
} | |
+ async getBreakpointHits( | |
+ sourceId: SourceId, | |
+ range?: { start: SourceLocation; end: SourceLocation } | |
+ ) { | |
+ const begin = range ? range.start : undefined; | |
+ const end = range ? range.end : undefined; | |
+ | |
+ return client.Debugger.getBreakpointHits({ sourceId, begin, end }, this.sessionId); | |
+ } | |
+ | |
getBreakpointPositionsCompressed( | |
sourceId: SourceId, | |
range?: { start: SourceLocation; end: SourceLocation } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment