Commit 97436022 authored by Hubert Boma Manilla's avatar Hubert Boma Manilla
Browse files

Bug 1765817 - [devtools] Add getLocationSource selector to fetch source for a location r=nchevobbe

This cleanup helps support the subsequent work for breakpoints per url.

Depends on D146426

Differential Revision: https://phabricator.services.mozilla.com/D146427
parent cad300b9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -275,6 +275,10 @@ class DebuggerPanel {
    return this._selectors.getSource(this._getState(), sourceId);
  }

  getLocationSource(location) {
    return this._selectors.getLocationSource(this._getState(), location);
  }

  destroy() {
    this.panelWin.Debugger.destroy();
    this.emit("destroyed");
+2 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

import {
  hasInScopeLines,
  getSource,
  getLocationSource,
  getSourceTextContent,
  getVisibleSelectedFrame,
} from "../../selectors";
@@ -29,7 +29,7 @@ function getOutOfScopeLines(outOfScopeLocations) {
}

async function getInScopeLines(cx, location, { dispatch, getState, parser }) {
  const source = getSource(getState(), location.sourceId);
  const source = getLocationSource(getState(), location);
  const sourceTextContent = getSourceTextContent(getState(), source.id);

  let locations = null;
+9 −6
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ import {
  getBreakpoint,
  getBreakpointPositionsForLocation,
  getFirstBreakpointPosition,
  getSource,
  getLocationSource,
  getSourceContent,
  getBreakpointsList,
  getPendingBreakpointList,
@@ -64,7 +64,7 @@ async function clientSetBreakpoint(
  );
  const shouldMapBreakpointExpressions =
    isMapScopesEnabled(getState()) &&
    getSource(getState(), breakpoint.location?.sourceId).isOriginal &&
    getLocationSource(getState(), breakpoint.location).isOriginal &&
    (breakpoint.options.logValue || breakpoint.options.condition);

  if (shouldMapBreakpointExpressions) {
@@ -107,9 +107,12 @@ export function addBreakpoint(
    const { dispatch, getState, client } = thunkArgs;
    recordEvent("add_breakpoint");

    const { sourceId, column, line } = initialLocation;
    const { column, line } = initialLocation;
    const initialSource = getLocationSource(getState(), initialLocation);

    await dispatch(setBreakpointPositions({ cx, sourceId, line }));
    await dispatch(
      setBreakpointPositions({ cx, sourceId: initialSource.id, line })
    );

    const position = column
      ? getBreakpointPositionsForLocation(getState(), initialLocation)
@@ -123,8 +126,8 @@ export function addBreakpoint(

    const { location, generatedLocation } = position;

    const source = getSource(getState(), location.sourceId);
    const generatedSource = getSource(getState(), generatedLocation.sourceId);
    const source = getLocationSource(getState(), location);
    const generatedSource = getLocationSource(getState(), generatedLocation);

    if (!source || !generatedSource) {
      return;
+2 −3
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ import {
  getExpressions,
  getSelectedFrame,
  getSelectedFrameId,
  getSourceFromId,
  getLocationSource,
  getSelectedSource,
  getSelectedScopeMappings,
  getSelectedFrameBindings,
@@ -133,8 +133,7 @@ function evaluateExpression(cx, expression) {
    const frame = getSelectedFrame(getState(), cx.thread);

    if (frame) {
      const { location } = frame;
      const source = getSourceFromId(getState(), location.sourceId);
      const source = getLocationSource(getState(), frame.location);

      const selectedSource = getSelectedSource(getState());

+2 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

import {
  getSymbols,
  getSource,
  getLocationSource,
  getSelectedFrame,
  getCurrentThread,
} from "../../selectors";
@@ -46,7 +46,7 @@ export function highlightCalls(cx) {
      return;
    }

    const source = getSource(getState(), frame.location.sourceId);
    const source = getLocationSource(getState(), frame.location);
    if (!source) {
      return;
    }
Loading