Bug 1751851 - [devtools] Migrate all ast selectors to a selector module. r=bomsy

Differential Revision: https://phabricator.services.mozilla.com/D136854
This commit is contained in:
Alexandre Poirot 2022-01-27 08:31:39 +00:00
Родитель f92cb088f2
Коммит b44cd5b678
6 изменённых файлов: 44 добавлений и 41 удалений

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

@ -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 { getSymbols } from "../../../reducers/ast";
import { getSymbols } from "../../../selectors/ast";
import {
actions,
selectors,

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

@ -58,42 +58,4 @@ function update(state = initialASTState(), action) {
}
}
// NOTE: we'd like to have the app state fully typed
// https://github.com/firefox-devtools/debugger/blob/master/src/reducers/sources.js#L179-L185
export function getSymbols(state, source) {
if (!source) {
return null;
}
return state.ast.symbols[source.id] || null;
}
export function hasSymbols(state, source) {
const symbols = getSymbols(state, source);
if (!symbols) {
return false;
}
return !symbols.loading;
}
export function isSymbolsLoading(state, source) {
const symbols = getSymbols(state, source);
if (!symbols) {
return false;
}
return symbols.loading;
}
export function getInScopeLines(state, location) {
return state.ast.inScopeLines[makeBreakpointId(location)];
}
export function hasInScopeLines(state, location) {
return !!getInScopeLines(state, location);
}
export default update;

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

@ -0,0 +1,40 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 { makeBreakpointId } from "../utils/breakpoint";
export function getSymbols(state, source) {
if (!source) {
return null;
}
return state.ast.symbols[source.id] || null;
}
export function hasSymbols(state, source) {
const symbols = getSymbols(state, source);
if (!symbols) {
return false;
}
return !symbols.loading;
}
export function isSymbolsLoading(state, source) {
const symbols = getSymbols(state, source);
if (!symbols) {
return false;
}
return symbols.loading;
}
export function getInScopeLines(state, location) {
return state.ast.inScopeLines[makeBreakpointId(location)];
}
export function hasInScopeLines(state, location) {
return !!getInScopeLines(state, location);
}

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

@ -12,7 +12,6 @@ export * from "../reducers/breakpoints";
export * from "../reducers/pending-breakpoints";
export * from "../reducers/ui";
export * from "../reducers/file-search";
export * from "../reducers/ast";
export * from "../reducers/project-text-search";
export * from "../reducers/source-tree";
export * from "../reducers/preview";
@ -31,6 +30,7 @@ export {
getQuickOpenType,
} from "../reducers/quick-open";
export * from "./ast";
export {
getClosestBreakpoint,
getBreakpointAtLocation,

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

@ -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 { getInScopeLines } from "../reducers/ast";
import { getInScopeLines } from "./ast";
import { getVisibleSelectedFrame } from "./pause";
// Checks if a line is considered in scope

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

@ -6,6 +6,7 @@
DIRS += []
CompiledModules(
"ast.js",
"breakpointAtLocation.js",
"breakpoints.js",
"breakpointSources.js",