mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1775203 - [devtools] Unify code around getSymbols method. r=bomsy,perftest-reviewers,davehunt
Now that we no longer have the intermediate "loading" object, we can simplify the code checking for loading symbols by checking if symbols are defined. Differential Revision: https://phabricator.services.mozilla.com/D149856
This commit is contained in:
parent
b3ba605c26
commit
5ddda086fa
@ -12,7 +12,7 @@ import {
|
||||
} from "../../utils/test-head";
|
||||
|
||||
import readFixture from "./helpers/readFixture";
|
||||
const { getSymbols, isSymbolsLoading } = selectors;
|
||||
const { getSymbols } = selectors;
|
||||
|
||||
const mockCommandClient = {
|
||||
sourceContents: async ({ source }) => ({
|
||||
@ -52,7 +52,7 @@ describe("ast", () => {
|
||||
|
||||
const loadedSource = selectors.getSourceFromId(getState(), base.id);
|
||||
await dispatch(actions.setSymbols({ cx, source: loadedSource }));
|
||||
await waitForState(store, state => !isSymbolsLoading(state, base));
|
||||
await waitForState(store, state => getSymbols(state, base));
|
||||
|
||||
const baseSymbols = getSymbols(getState(), base);
|
||||
expect(baseSymbols).toMatchSnapshot();
|
||||
|
@ -60,7 +60,7 @@ async function pause(store, client) {
|
||||
);
|
||||
|
||||
await dispatch(actions.selectSource(cx, base.id));
|
||||
await waitForState(store, state => selectors.hasSymbols(state, base));
|
||||
await waitForState(store, state => selectors.getSymbols(state, base));
|
||||
|
||||
const { thread } = cx;
|
||||
const frames = [makeFrame({ id: "frame1", sourceId: base.id, thread })];
|
||||
@ -85,7 +85,7 @@ describe("preview", () => {
|
||||
);
|
||||
|
||||
await dispatch(actions.selectSource(cx, base.id));
|
||||
await waitForState(store, state => selectors.hasSymbols(state, base));
|
||||
await waitForState(store, state => selectors.getSymbols(state, base));
|
||||
const frames = [makeFrame({ id: "f1", sourceId: base.id })];
|
||||
|
||||
await dispatch(
|
||||
|
@ -20,7 +20,6 @@ import {
|
||||
getSourceContent,
|
||||
getSymbols,
|
||||
getTabs,
|
||||
isSymbolsLoading,
|
||||
getContext,
|
||||
} from "../selectors";
|
||||
import { memoizeLast } from "../utils/memoizeLast";
|
||||
@ -442,6 +441,7 @@ function mapStateToProps(state) {
|
||||
const selectedSource = getSelectedSource(state);
|
||||
const displayedSources = getDisplayedSourcesList(state);
|
||||
const tabs = getTabs(state);
|
||||
const symbols = getSymbols(state, selectedSource);
|
||||
|
||||
return {
|
||||
cx: getContext(state),
|
||||
@ -451,8 +451,8 @@ function mapStateToProps(state) {
|
||||
selectedContentLoaded: selectedSource
|
||||
? !!getSourceContent(state, selectedSource.id)
|
||||
: undefined,
|
||||
symbols: formatSymbols(getSymbols(state, selectedSource)),
|
||||
symbolsLoading: isSymbolsLoading(state, selectedSource),
|
||||
symbols: formatSymbols(symbols),
|
||||
symbolsLoading: !symbols,
|
||||
query: getQuickOpenQuery(state),
|
||||
searchType: getQuickOpenType(state),
|
||||
tabs,
|
||||
|
@ -12,14 +12,6 @@ export function getSymbols(state, source) {
|
||||
return state.ast.symbols[source.id] || null;
|
||||
}
|
||||
|
||||
export function hasSymbols(state, source) {
|
||||
return !!getSymbols(state, source);
|
||||
}
|
||||
|
||||
export function isSymbolsLoading(state, source) {
|
||||
return !getSymbols(state, source);
|
||||
}
|
||||
|
||||
export function getInScopeLines(state, location) {
|
||||
return state.ast.inScopeLines[makeBreakpointId(location)];
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ add_task(async function() {
|
||||
dbg.wasmOffsetToLine(binarySource.id, virtualBinaryLine) + 1;
|
||||
|
||||
// We can't use selectSource here because binary source won't have symbols loaded
|
||||
// (hasSymbols(source) selector will be false)
|
||||
// (getSymbols(source) selector will be false)
|
||||
await dbg.actions.selectLocation(
|
||||
getContext(dbg),
|
||||
{ sourceId: binarySource.id },
|
||||
|
@ -199,7 +199,7 @@ function waitForSelectedSource(dbg, sourceOrUrl) {
|
||||
const {
|
||||
getSelectedSource,
|
||||
getSelectedSourceTextContent,
|
||||
hasSymbols,
|
||||
getSymbols,
|
||||
getBreakableLines,
|
||||
} = dbg.selectors;
|
||||
|
||||
@ -224,7 +224,7 @@ function waitForSelectedSource(dbg, sourceOrUrl) {
|
||||
}
|
||||
}
|
||||
|
||||
return hasSymbols(source) && getBreakableLines(source.id);
|
||||
return getSymbols(source) && getBreakableLines(source.id);
|
||||
},
|
||||
"selected source"
|
||||
);
|
||||
|
@ -105,7 +105,7 @@ function waitForSymbols(dbg) {
|
||||
return waitUntil(() => {
|
||||
const state = dbg.store.getState();
|
||||
const source = dbg.selectors.getSelectedSource(state);
|
||||
return dbg.selectors.hasSymbols(state, source);
|
||||
return dbg.selectors.getSymbols(state, source);
|
||||
}, "has file metadata");
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ function selectSource(dbg, url) {
|
||||
|
||||
// wait for symbols -- a flat map of all named variables in a file -- to be calculated.
|
||||
// this is a slow process and becomes slower the larger the file is
|
||||
return dbg.selectors.hasSymbols(state, source);
|
||||
return dbg.selectors.getSymbols(state, source);
|
||||
},
|
||||
"selected source"
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user