Bug 1747816 - [devtools] Always use reducer's source's `isOriginal` attribute to know if a source is an original one. r=bomsy

"original" here refers to not being generated.
It overlaps with pretty printed sources, which are considered as original sources.

Differential Revision: https://phabricator.services.mozilla.com/D134751
This commit is contained in:
Alexandre Poirot 2022-01-10 13:10:37 +00:00
Родитель b140a2f3d3
Коммит 6cd7bcb3bc
11 изменённых файлов: 16 добавлений и 46 удалений

Просмотреть файл

@ -28,7 +28,6 @@ import { recordEvent } from "../../utils/telemetry";
import { comparePosition } from "../../utils/location";
import { getTextAtPosition } from "../../utils/source";
import { getMappedScopesForLocation } from "../pause/mapScopes";
import { isOriginalSource } from "../../utils/source-maps";
import { validateNavigateContext } from "../../utils/context";
// This file has the primitive operations used to modify individual breakpoints
@ -67,7 +66,7 @@ async function clientSetBreakpoint(
);
const shouldMapBreakpointExpressions =
isMapScopesEnabled(getState()) &&
isOriginalSource(getSource(getState(), breakpoint.location?.sourceId)) &&
getSource(getState(), breakpoint.location?.sourceId).isOriginal &&
(breakpoint.options.logValue || breakpoint.options.condition);
if (shouldMapBreakpointExpressions) {

Просмотреть файл

@ -18,7 +18,6 @@ import {
import { PROMISE } from "./utils/middleware/promise";
import { wrapExpression } from "../utils/expressions";
import { features } from "../utils/prefs";
import { isOriginal } from "../utils/source";
/**
* Add expression for debugger to watch
@ -139,7 +138,7 @@ function evaluateExpression(cx, expression) {
const selectedSource = getSelectedSource(getState());
if (selectedSource && isOriginal(source) && isOriginal(selectedSource)) {
if (selectedSource && source.isOriginal && selectedSource.isOriginal) {
const mapResult = await dispatch(getMappedExpression(input));
if (mapResult) {
input = mapResult.expression;

Просмотреть файл

@ -17,7 +17,7 @@ import { PROMISE } from "../utils/middleware/promise";
import assert from "../../utils/assert";
import { log } from "../../utils/log";
import { isGenerated, isOriginal } from "../../utils/source";
import { isGenerated } from "../../utils/source";
import { buildMappedScopes } from "../../utils/pause/mapScopes";
import { isFulfilled } from "../../utils/async-value";
@ -148,7 +148,7 @@ export function getMappedScopes(cx, scopes, frame) {
}
await dispatch(loadSourceText({ cx, source }));
if (isOriginal(source)) {
if (source.isOriginal) {
await dispatch(loadSourceText({ cx, source: generatedSource }));
}

Просмотреть файл

@ -6,7 +6,6 @@ import { isConsole } from "../utils/preview";
import { findBestMatchExpression } from "../utils/ast";
import { getGrip, getFront } from "../utils/evaluation-result";
import { getExpressionFromCoords } from "../utils/editor/get-expression";
import { isOriginal } from "../utils/source";
import { isNodeTest } from "../utils/environment";
import {
@ -89,7 +88,7 @@ export function setPreview(
const thread = getCurrentThread(getState());
const selectedFrame = getSelectedFrame(getState(), thread);
if (location && isOriginal(source)) {
if (location && source.isOriginal) {
const mapResult = await dispatch(getMappedExpression(expression));
if (mapResult) {
expression = mapResult.expression;

Просмотреть файл

@ -18,7 +18,7 @@ import { addBreakpoint } from "../breakpoints";
import { prettyPrintSource } from "./prettyPrint";
import { isFulfilled, fulfilled } from "../../utils/async-value";
import { isOriginal, isPretty } from "../../utils/source";
import { isPretty } from "../../utils/source";
import { memoizeableAction } from "../../utils/memoizableAction";
const Telemetry = require("devtools/client/shared/telemetry");
@ -28,7 +28,7 @@ const loadSourceHistogram = "DEVTOOLS_DEBUGGER_LOAD_SOURCE_MS";
const telemetry = new Telemetry();
async function loadSource(state, source, { sourceMaps, client, getState }) {
if (isPretty(source) && isOriginal(source)) {
if (isPretty(source) && source.isOriginal) {
const generatedSource = getGeneratedSource(state, source);
if (!generatedSource) {
throw new Error("Unable to find minified original.");
@ -46,7 +46,7 @@ async function loadSource(state, source, { sourceMaps, client, getState }) {
);
}
if (isOriginal(source)) {
if (source.isOriginal) {
const result = await sourceMaps.getOriginalSourceText(source.id);
if (!result) {
// The way we currently try to load and select a pending

Просмотреть файл

@ -13,12 +13,7 @@ import {
getContext,
} from "../../selectors";
import {
isPretty,
getFilename,
isOriginal,
shouldBlackbox,
} from "../../utils/source";
import { isPretty, getFilename, shouldBlackbox } from "../../utils/source";
import {
getGeneratedSource,
canPrettyPrintSource,
@ -172,7 +167,7 @@ class SourceFooter extends PureComponent {
selectedSource,
} = this.props;
if (!mappedSource || !selectedSource || !isOriginal(selectedSource)) {
if (!mappedSource || !selectedSource || !selectedSource.isOriginal) {
return null;
}

Просмотреть файл

@ -21,7 +21,6 @@ import {
import actions from "../../actions";
import {
isOriginal as isOriginalSource,
isUrlExtension,
isExtensionDirectoryPath,
shouldBlackbox,
@ -386,7 +385,7 @@ class SourceTreeItem extends Component {
}
function getHasMatchingGeneratedSource(state, source) {
if (!source || !isOriginalSource(source)) {
if (!source || !source.isOriginal) {
return false;
}

Просмотреть файл

@ -13,7 +13,6 @@ import {
underRoot,
getRelativeUrl,
isGenerated,
isOriginal as isOriginalSource,
getPlainUrl,
isPretty,
isJavaScript,
@ -655,7 +654,7 @@ export function getSpecificSourceByURLInSources(
) {
const foundSources = getSourcesByURLInSources(sources, urls, url);
if (foundSources) {
return foundSources.find(source => isOriginalSource(source) == isOriginal);
return foundSources.find(source => source.isOriginal == isOriginal);
}
return null;
}
@ -953,7 +952,7 @@ export function canPrettyPrintSource(state, id) {
if (
!source ||
isPretty(source) ||
isOriginalSource(source) ||
source.isOriginal ||
(prefs.clientSourceMapsEnabled && isSourceWithMap(state, id))
) {
return false;
@ -1006,7 +1005,7 @@ export function getBreakableLines(state, sourceId) {
return null;
}
if (isOriginalSource(source)) {
if (source.isOriginal) {
return state.sources.breakableLines[sourceId];
}

Просмотреть файл

@ -9,7 +9,6 @@ import {
} from "../reducers/sources";
import { getCurrentThreadFrames } from "../reducers/pause";
import { annotateFrames } from "../utils/pause/frames";
import { isOriginal } from "../utils/source";
import { createSelector } from "reselect";
function getLocation(frame, isGeneratedSource) {
@ -24,7 +23,7 @@ function getSourceForFrame(sources, frame, isGeneratedSource) {
}
function appendSource(sources, frame, selectedSource) {
const isGeneratedSource = selectedSource && !isOriginal(selectedSource);
const isGeneratedSource = selectedSource && !selectedSource.isOriginal;
return {
...frame,
location: getLocation(frame, isGeneratedSource),

Просмотреть файл

@ -78,15 +78,3 @@ export async function mapLocation(state, sourceMaps, location) {
return sourceMaps.getOriginalLocation(location);
}
export function isOriginalSource(source) {
if (!source) {
return false;
}
if (!source.hasOwnProperty("isOriginal")) {
throw new Error("source must have an isOriginal property");
}
return source.isOriginal;
}

Просмотреть файл

@ -9,7 +9,6 @@
const { getUnicodeUrl } = require("devtools/client/shared/unicode-url");
import { isOriginalSource } from "../utils/source-maps";
import { endTruncateStr } from "./utils";
import { truncateMiddleText } from "../utils/text";
import { parse as parseURL } from "../utils/url";
@ -485,14 +484,8 @@ export function underRoot(source, root, threads) {
return !!source.url && source.url.includes(root);
}
export function isOriginal(source) {
// Pretty-printed sources are given original IDs, so no need
// for any additional check
return isOriginalSource(source);
}
export function isGenerated(source) {
return !isOriginal(source);
return !source.isOriginal;
}
export function getSourceQueryString(source) {