зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
cad300b928
Коммит
9743602245
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { getFrames, getSymbols, getSource } from "../../selectors";
|
||||
import { getFrames, getSymbols, getLocationSource } from "../../selectors";
|
||||
|
||||
import { findClosestFunction } from "../../utils/ast";
|
||||
|
||||
|
@ -11,7 +11,7 @@ function mapDisplayName(frame, { getState }) {
|
|||
return frame;
|
||||
}
|
||||
|
||||
const source = getSource(getState(), frame.location.sourceId);
|
||||
const source = getLocationSource(getState(), frame.location);
|
||||
|
||||
if (!source) {
|
||||
return frame;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import {
|
||||
getFrames,
|
||||
getBlackBoxRanges,
|
||||
getSource,
|
||||
getLocationSource,
|
||||
getSelectedFrame,
|
||||
} from "../../selectors";
|
||||
|
||||
|
@ -23,7 +23,7 @@ function getSelectedFrameId(state, thread, frames) {
|
|||
selectedFrame &&
|
||||
!isFrameBlackBoxed(
|
||||
selectedFrame,
|
||||
getSource(state, selectedFrame.location.sourceId),
|
||||
getLocationSource(state, selectedFrame.location),
|
||||
blackboxedRanges
|
||||
)
|
||||
) {
|
||||
|
@ -31,7 +31,7 @@ function getSelectedFrameId(state, thread, frames) {
|
|||
}
|
||||
|
||||
selectedFrame = frames.find(frame => {
|
||||
const frameSource = getSource(state, frame.location.sourceId);
|
||||
const frameSource = getLocationSource(state, frame.location);
|
||||
return !isFrameBlackBoxed(frame, frameSource, blackboxedRanges);
|
||||
});
|
||||
return selectedFrame?.id;
|
||||
|
@ -62,9 +62,9 @@ function isWasmOriginalSourceFrame(frame, getState) {
|
|||
if (isGeneratedId(frame.location.sourceId)) {
|
||||
return false;
|
||||
}
|
||||
const generatedSource = getSource(
|
||||
const generatedSource = getLocationSource(
|
||||
getState(),
|
||||
frame.generatedLocation.sourceId
|
||||
frame.generatedLocation
|
||||
);
|
||||
|
||||
return Boolean(generatedSource?.isWasm);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import {
|
||||
getSelectedFrameId,
|
||||
getSource,
|
||||
getLocationSource,
|
||||
getSourceContent,
|
||||
isMapScopesEnabled,
|
||||
getSelectedFrame,
|
||||
|
@ -129,12 +130,12 @@ export function mapScopes(cx, scopes, frame) {
|
|||
export function getMappedScopes(cx, scopes, frame) {
|
||||
return async function(thunkArgs) {
|
||||
const { getState, dispatch } = thunkArgs;
|
||||
const generatedSource = getSource(
|
||||
const generatedSource = getLocationSource(
|
||||
getState(),
|
||||
frame.generatedLocation.sourceId
|
||||
frame.generatedLocation
|
||||
);
|
||||
|
||||
const source = getSource(getState(), frame.location.sourceId);
|
||||
const source = getLocationSource(getState(), frame.location);
|
||||
|
||||
if (
|
||||
!isMapScopesEnabled(getState()) ||
|
||||
|
|
|
@ -32,7 +32,7 @@ import {
|
|||
getSelectedSource,
|
||||
canPrettyPrintSource,
|
||||
getIsCurrentThreadPaused,
|
||||
getSourceFromId,
|
||||
getLocationSource,
|
||||
getSourceTextContent,
|
||||
tabExists,
|
||||
} from "../../selectors";
|
||||
|
@ -127,7 +127,7 @@ export function selectLocation(cx, location, { keepContext = true } = {}) {
|
|||
return;
|
||||
}
|
||||
|
||||
let source = getSource(getState(), location.sourceId);
|
||||
let source = getLocationSource(getState(), location);
|
||||
|
||||
if (!source) {
|
||||
// If there is no source we deselect the current selected source
|
||||
|
@ -156,7 +156,7 @@ export function selectLocation(cx, location, { keepContext = true } = {}) {
|
|||
// getRelatedMapLocation will just convert to the related generated/original location.
|
||||
// i.e if the original location is passed, the related generated location will be returned and vice versa.
|
||||
location = await getRelatedMapLocation(getState(), sourceMaps, location);
|
||||
source = getSourceFromId(getState(), location.sourceId);
|
||||
source = getLocationSource(getState(), location);
|
||||
}
|
||||
|
||||
if (!tabExists(getState(), source.id)) {
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
getCurrentThread,
|
||||
getThreadContext,
|
||||
getPauseReason,
|
||||
getSourceFromId,
|
||||
getLocationSource,
|
||||
getSkipPausing,
|
||||
shouldLogEventBreakpoints,
|
||||
} from "../../selectors";
|
||||
|
@ -466,8 +466,7 @@ const mapStateToProps = state => {
|
|||
workers: getThreads(state),
|
||||
skipPausing: getSkipPausing(state),
|
||||
logEventBreakpoints: shouldLogEventBreakpoints(state),
|
||||
source:
|
||||
selectedFrame && getSourceFromId(state, selectedFrame.location.sourceId),
|
||||
source: selectedFrame && getLocationSource(state, selectedFrame.location),
|
||||
pauseReason: pauseReason?.type ?? "",
|
||||
};
|
||||
};
|
||||
|
|
|
@ -47,6 +47,10 @@ export function getSourceFromId(state, id) {
|
|||
return source;
|
||||
}
|
||||
|
||||
export function getLocationSource(state, location) {
|
||||
return getSource(state, location.sourceId);
|
||||
}
|
||||
|
||||
export function getSourceByActorId(state, actorId) {
|
||||
if (!hasSourceActor(state, actorId)) {
|
||||
return null;
|
||||
|
|
|
@ -6,7 +6,11 @@ import { createSelector } from "reselect";
|
|||
import { shallowEqual } from "../utils/shallow-equal";
|
||||
import { getPrettySourceURL } from "../utils/source";
|
||||
|
||||
import { getSource, getSpecificSourceByURL, getSourcesMap } from "./sources";
|
||||
import {
|
||||
getLocationSource,
|
||||
getSpecificSourceByURL,
|
||||
getSourcesMap,
|
||||
} from "./sources";
|
||||
import { isOriginalId } from "devtools-source-map";
|
||||
import { isSimilarTab } from "../utils/tabs";
|
||||
|
||||
|
@ -48,7 +52,7 @@ export function getNewSelectedSourceId(state, tabList) {
|
|||
return "";
|
||||
}
|
||||
|
||||
const selectedTab = getSource(state, selectedLocation.sourceId);
|
||||
const selectedTab = getLocationSource(state, selectedLocation);
|
||||
if (!selectedTab) {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { getSource, getSourceActorsForSource } from "../../selectors";
|
||||
import { getLocationSource, getSourceActorsForSource } from "../../selectors";
|
||||
import { isGenerated } from "../source";
|
||||
import { sortSelectedLocations } from "../location";
|
||||
import assert from "../assert";
|
||||
|
@ -30,7 +30,7 @@ export function makePendingLocationId(location) {
|
|||
}
|
||||
|
||||
export function makeBreakpointLocation(state, location) {
|
||||
const source = getSource(state, location.sourceId);
|
||||
const source = getLocationSource(state, location);
|
||||
if (!source) {
|
||||
throw new Error("no source");
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { isOriginalId } from "devtools-source-map";
|
||||
import { getSource } from "../selectors";
|
||||
import { getSource, getLocationSource } from "../selectors";
|
||||
|
||||
export async function getGeneratedLocation(
|
||||
state,
|
||||
|
@ -41,7 +41,7 @@ export async function getOriginalLocation(generatedLocation, sourceMaps) {
|
|||
}
|
||||
|
||||
export async function getMappedLocation(state, sourceMaps, location) {
|
||||
const source = getSource(state, location.sourceId);
|
||||
const source = getLocationSource(state, location);
|
||||
|
||||
if (!source) {
|
||||
throw new Error(`no source ${location.sourceId}`);
|
||||
|
@ -74,7 +74,7 @@ export async function getMappedLocation(state, sourceMaps, location) {
|
|||
* related location in the generated source.
|
||||
*/
|
||||
export async function getRelatedMapLocation(state, sourceMaps, location) {
|
||||
const source = getSource(state, location.sourceId);
|
||||
const source = getLocationSource(state, location);
|
||||
|
||||
if (!source) {
|
||||
return location;
|
||||
|
|
|
@ -164,7 +164,7 @@ async function getViewSourceInDebuggerLocation(
|
|||
return generatedLocation;
|
||||
}
|
||||
|
||||
const originalSource = dbg.getSource(originalLocation.sourceId);
|
||||
const originalSource = dbg.getLocationSource(originalLocation);
|
||||
|
||||
if (!originalSource) {
|
||||
return generatedLocation;
|
||||
|
|
Загрузка…
Ссылка в новой задаче