mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Backed out 2 changesets (bug 1535362) for causing merge conflicts. a=backout
Backed out changeset 52636fd2ce17 (bug 1535362) Backed out changeset d363668ebdaa (bug 1535362)
This commit is contained in:
parent
695a2fc374
commit
4f5ccd379e
@ -134,13 +134,11 @@ DebuggerPanel.prototype = {
|
||||
},
|
||||
|
||||
selectSourceURL(url, line, column) {
|
||||
const cx = this._selectors.getContext(this._getState());
|
||||
return this._actions.selectSourceURL(cx, url, { line, column });
|
||||
return this._actions.selectSourceURL(url, { line, column });
|
||||
},
|
||||
|
||||
selectSource(sourceId, line, column) {
|
||||
const cx = this._selectors.getContext(this._getState());
|
||||
return this._actions.selectSource(cx, sourceId, { line, column });
|
||||
return this._actions.selectSource(sourceId, { line, column });
|
||||
},
|
||||
|
||||
getSourceByActorId(sourceId) {
|
||||
|
@ -12,10 +12,9 @@ import * as parser from "../workers/parser";
|
||||
|
||||
import { isLoaded } from "../utils/source";
|
||||
|
||||
import type { Context } from "../types";
|
||||
import type { ThunkArgs, Action } from "./types";
|
||||
|
||||
export function setOutOfScopeLocations(cx: Context) {
|
||||
export function setOutOfScopeLocations() {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
const location = getSelectedLocation(getState());
|
||||
if (!location) {
|
||||
@ -39,10 +38,9 @@ export function setOutOfScopeLocations(cx: Context) {
|
||||
dispatch(
|
||||
({
|
||||
type: "OUT_OF_SCOPE_LOCATIONS",
|
||||
cx,
|
||||
locations
|
||||
}: Action)
|
||||
);
|
||||
dispatch(setInScopeLines(cx));
|
||||
dispatch(setInScopeLines());
|
||||
};
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import { range, flatMap, uniq, without } from "lodash";
|
||||
|
||||
import type { AstLocation } from "../../workers/parser";
|
||||
import type { ThunkArgs } from "../types";
|
||||
import type { Context } from "../../types";
|
||||
|
||||
function getOutOfScopeLines(outOfScopeLocations: ?(AstLocation[])) {
|
||||
if (!outOfScopeLocations) {
|
||||
@ -25,7 +24,7 @@ function getOutOfScopeLines(outOfScopeLocations: ?(AstLocation[])) {
|
||||
);
|
||||
}
|
||||
|
||||
export function setInScopeLines(cx: Context) {
|
||||
export function setInScopeLines() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
const source = getSelectedSource(getState());
|
||||
const outOfScopeLocations = getOutOfScopeLocations(getState());
|
||||
@ -45,7 +44,6 @@ export function setInScopeLines(cx: Context) {
|
||||
|
||||
dispatch({
|
||||
type: "IN_SCOPE_LINES",
|
||||
cx,
|
||||
lines: inScopeLines
|
||||
});
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
getBreakpointPositionsForSource
|
||||
} from "../../selectors";
|
||||
|
||||
import type { MappedLocation, SourceLocation, Context } from "../../types";
|
||||
import type { MappedLocation, SourceLocation } from "../../types";
|
||||
import type { ThunkArgs } from "../../actions/types";
|
||||
import { makeBreakpointId } from "../../utils/breakpoint";
|
||||
import typeof SourceMaps from "../../../packages/devtools-source-map/src";
|
||||
@ -64,7 +64,7 @@ function convertToList(results, source) {
|
||||
return positions;
|
||||
}
|
||||
|
||||
async function _setBreakpointPositions(cx, sourceId, thunkArgs) {
|
||||
async function _setBreakpointPositions(sourceId, thunkArgs) {
|
||||
const { client, dispatch, getState, sourceMaps } = thunkArgs;
|
||||
let generatedSource = getSource(getState(), sourceId);
|
||||
if (!generatedSource) {
|
||||
@ -115,7 +115,6 @@ async function _setBreakpointPositions(cx, sourceId, thunkArgs) {
|
||||
}
|
||||
dispatch({
|
||||
type: "ADD_BREAKPOINT_POSITIONS",
|
||||
cx,
|
||||
source: source,
|
||||
positions
|
||||
});
|
||||
@ -137,7 +136,7 @@ function buildCacheKey(sourceId: string, thunkArgs: ThunkArgs): string {
|
||||
return key;
|
||||
}
|
||||
|
||||
export function setBreakpointPositions(cx: Context, sourceId: string) {
|
||||
export function setBreakpointPositions(sourceId: string) {
|
||||
return async (thunkArgs: ThunkArgs) => {
|
||||
const { getState } = thunkArgs;
|
||||
if (hasBreakpointPositions(getState(), sourceId)) {
|
||||
@ -151,7 +150,7 @@ export function setBreakpointPositions(cx: Context, sourceId: string) {
|
||||
cacheKey,
|
||||
(async () => {
|
||||
try {
|
||||
await _setBreakpointPositions(cx, sourceId, thunkArgs);
|
||||
await _setBreakpointPositions(sourceId, thunkArgs);
|
||||
} catch (e) {
|
||||
// TODO: Address exceptions originating from 1536618
|
||||
// `Debugger.Source belongs to a different Debugger`
|
||||
|
@ -37,17 +37,16 @@ import type {
|
||||
Breakpoint,
|
||||
Source,
|
||||
SourceLocation,
|
||||
XHRBreakpoint,
|
||||
Context
|
||||
XHRBreakpoint
|
||||
} from "../../types";
|
||||
|
||||
export * from "./breakpointPositions";
|
||||
export * from "./modify";
|
||||
export * from "./syncBreakpoint";
|
||||
|
||||
export function addHiddenBreakpoint(cx: Context, location: SourceLocation) {
|
||||
export function addHiddenBreakpoint(location: SourceLocation) {
|
||||
return ({ dispatch }: ThunkArgs) => {
|
||||
return dispatch(addBreakpoint(cx, location, { hidden: true }));
|
||||
return dispatch(addBreakpoint(location, { hidden: true }));
|
||||
};
|
||||
}
|
||||
|
||||
@ -57,12 +56,12 @@ export function addHiddenBreakpoint(cx: Context, location: SourceLocation) {
|
||||
* @memberof actions/breakpoints
|
||||
* @static
|
||||
*/
|
||||
export function disableBreakpointsInSource(cx: Context, source: Source) {
|
||||
export function disableBreakpointsInSource(source: Source) {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const breakpoints = getBreakpointsForSource(getState(), source.id);
|
||||
for (const breakpoint of breakpoints) {
|
||||
if (!breakpoint.disabled) {
|
||||
dispatch(disableBreakpoint(cx, breakpoint));
|
||||
dispatch(disableBreakpoint(breakpoint));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -74,12 +73,12 @@ export function disableBreakpointsInSource(cx: Context, source: Source) {
|
||||
* @memberof actions/breakpoints
|
||||
* @static
|
||||
*/
|
||||
export function enableBreakpointsInSource(cx: Context, source: Source) {
|
||||
export function enableBreakpointsInSource(source: Source) {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const breakpoints = getBreakpointsForSource(getState(), source.id);
|
||||
for (const breakpoint of breakpoints) {
|
||||
if (breakpoint.disabled) {
|
||||
dispatch(enableBreakpoint(cx, breakpoint));
|
||||
dispatch(enableBreakpoint(breakpoint));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -91,18 +90,15 @@ export function enableBreakpointsInSource(cx: Context, source: Source) {
|
||||
* @memberof actions/breakpoints
|
||||
* @static
|
||||
*/
|
||||
export function toggleAllBreakpoints(
|
||||
cx: Context,
|
||||
shouldDisableBreakpoints: boolean
|
||||
) {
|
||||
export function toggleAllBreakpoints(shouldDisableBreakpoints: boolean) {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const breakpoints = getBreakpointsList(getState());
|
||||
|
||||
for (const breakpoint of breakpoints) {
|
||||
if (shouldDisableBreakpoints) {
|
||||
dispatch(disableBreakpoint(cx, breakpoint));
|
||||
dispatch(disableBreakpoint(breakpoint));
|
||||
} else {
|
||||
dispatch(enableBreakpoint(cx, breakpoint));
|
||||
dispatch(enableBreakpoint(breakpoint));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -115,7 +111,6 @@ export function toggleAllBreakpoints(
|
||||
* @static
|
||||
*/
|
||||
export function toggleBreakpoints(
|
||||
cx: Context,
|
||||
shouldDisableBreakpoints: boolean,
|
||||
breakpoints: Breakpoint[]
|
||||
) {
|
||||
@ -123,8 +118,8 @@ export function toggleBreakpoints(
|
||||
const promises = breakpoints.map(
|
||||
breakpoint =>
|
||||
shouldDisableBreakpoints
|
||||
? dispatch(disableBreakpoint(cx, breakpoint))
|
||||
: dispatch(enableBreakpoint(cx, breakpoint))
|
||||
? dispatch(disableBreakpoint(breakpoint))
|
||||
: dispatch(enableBreakpoint(breakpoint))
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
@ -132,15 +127,12 @@ export function toggleBreakpoints(
|
||||
}
|
||||
|
||||
export function toggleBreakpointsAtLine(
|
||||
cx: Context,
|
||||
shouldDisableBreakpoints: boolean,
|
||||
line: number
|
||||
) {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
const breakpoints = getBreakpointsAtLine(getState(), line);
|
||||
return dispatch(
|
||||
toggleBreakpoints(cx, shouldDisableBreakpoints, breakpoints)
|
||||
);
|
||||
const breakpoints = await getBreakpointsAtLine(getState(), line);
|
||||
return dispatch(toggleBreakpoints(shouldDisableBreakpoints, breakpoints));
|
||||
};
|
||||
}
|
||||
|
||||
@ -150,11 +142,11 @@ export function toggleBreakpointsAtLine(
|
||||
* @memberof actions/breakpoints
|
||||
* @static
|
||||
*/
|
||||
export function removeAllBreakpoints(cx: Context) {
|
||||
export function removeAllBreakpoints() {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
const breakpointList = getBreakpointsList(getState());
|
||||
return Promise.all(
|
||||
breakpointList.map(bp => dispatch(removeBreakpoint(cx, bp)))
|
||||
breakpointList.map(bp => dispatch(removeBreakpoint(bp)))
|
||||
);
|
||||
};
|
||||
}
|
||||
@ -165,11 +157,9 @@ export function removeAllBreakpoints(cx: Context) {
|
||||
* @memberof actions/breakpoints
|
||||
* @static
|
||||
*/
|
||||
export function removeBreakpoints(cx: Context, breakpoints: Breakpoint[]) {
|
||||
export function removeBreakpoints(breakpoints: Breakpoint[]) {
|
||||
return async ({ dispatch }: ThunkArgs) => {
|
||||
return Promise.all(
|
||||
breakpoints.map(bp => dispatch(removeBreakpoint(cx, bp)))
|
||||
);
|
||||
return Promise.all(breakpoints.map(bp => dispatch(removeBreakpoint(bp))));
|
||||
};
|
||||
}
|
||||
|
||||
@ -179,16 +169,16 @@ export function removeBreakpoints(cx: Context, breakpoints: Breakpoint[]) {
|
||||
* @memberof actions/breakpoints
|
||||
* @static
|
||||
*/
|
||||
export function removeBreakpointsInSource(cx: Context, source: Source) {
|
||||
export function removeBreakpointsInSource(source: Source) {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const breakpoints = getBreakpointsForSource(getState(), source.id);
|
||||
for (const breakpoint of breakpoints) {
|
||||
dispatch(removeBreakpoint(cx, breakpoint));
|
||||
dispatch(removeBreakpoint(breakpoint));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function remapBreakpoints(cx: Context, sourceId: string) {
|
||||
export function remapBreakpoints(sourceId: string) {
|
||||
return async ({ dispatch, getState, sourceMaps }: ThunkArgs) => {
|
||||
const breakpoints = getBreakpointsList(getState());
|
||||
const newBreakpoints = await remapLocations(
|
||||
@ -198,12 +188,12 @@ export function remapBreakpoints(cx: Context, sourceId: string) {
|
||||
);
|
||||
|
||||
for (const bp of newBreakpoints) {
|
||||
await dispatch(addBreakpoint(cx, bp.location, bp.options, bp.disabled));
|
||||
await dispatch(addBreakpoint(bp.location, bp.options, bp.disabled));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function toggleBreakpointAtLine(cx: Context, line: number) {
|
||||
export function toggleBreakpointAtLine(line: number) {
|
||||
return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
const state = getState();
|
||||
const selectedSource = getSelectedSource(state);
|
||||
@ -224,10 +214,10 @@ export function toggleBreakpointAtLine(cx: Context, line: number) {
|
||||
}
|
||||
|
||||
if (bp) {
|
||||
return dispatch(removeBreakpoint(cx, bp));
|
||||
return dispatch(removeBreakpoint(bp));
|
||||
}
|
||||
return dispatch(
|
||||
addBreakpoint(cx, {
|
||||
addBreakpoint({
|
||||
sourceId: selectedSource.id,
|
||||
sourceUrl: selectedSource.url,
|
||||
line: line
|
||||
@ -236,7 +226,7 @@ export function toggleBreakpointAtLine(cx: Context, line: number) {
|
||||
};
|
||||
}
|
||||
|
||||
export function addBreakpointAtLine(cx: Context, line: number) {
|
||||
export function addBreakpointAtLine(line: number) {
|
||||
return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
const state = getState();
|
||||
const source = getSelectedSource(state);
|
||||
@ -246,7 +236,7 @@ export function addBreakpointAtLine(cx: Context, line: number) {
|
||||
}
|
||||
|
||||
return dispatch(
|
||||
addBreakpoint(cx, {
|
||||
addBreakpoint({
|
||||
sourceId: source.id,
|
||||
sourceUrl: source.url,
|
||||
column: undefined,
|
||||
@ -256,57 +246,45 @@ export function addBreakpointAtLine(cx: Context, line: number) {
|
||||
};
|
||||
}
|
||||
|
||||
export function removeBreakpointsAtLine(
|
||||
cx: Context,
|
||||
sourceId: string,
|
||||
line: number
|
||||
) {
|
||||
export function removeBreakpointsAtLine(sourceId: string, line: number) {
|
||||
return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
const breakpointsAtLine = getBreakpointsForSource(
|
||||
getState(),
|
||||
sourceId,
|
||||
line
|
||||
);
|
||||
return dispatch(removeBreakpoints(cx, breakpointsAtLine));
|
||||
return dispatch(removeBreakpoints(breakpointsAtLine));
|
||||
};
|
||||
}
|
||||
|
||||
export function disableBreakpointsAtLine(
|
||||
cx: Context,
|
||||
sourceId: string,
|
||||
line: number
|
||||
) {
|
||||
export function disableBreakpointsAtLine(sourceId: string, line: number) {
|
||||
return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
const breakpointsAtLine = getBreakpointsForSource(
|
||||
getState(),
|
||||
sourceId,
|
||||
line
|
||||
);
|
||||
return dispatch(toggleBreakpoints(cx, true, breakpointsAtLine));
|
||||
return dispatch(toggleBreakpoints(true, breakpointsAtLine));
|
||||
};
|
||||
}
|
||||
|
||||
export function enableBreakpointsAtLine(
|
||||
cx: Context,
|
||||
sourceId: string,
|
||||
line: number
|
||||
) {
|
||||
export function enableBreakpointsAtLine(sourceId: string, line: number) {
|
||||
return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
const breakpointsAtLine = getBreakpointsForSource(
|
||||
getState(),
|
||||
sourceId,
|
||||
line
|
||||
);
|
||||
return dispatch(toggleBreakpoints(cx, false, breakpointsAtLine));
|
||||
return dispatch(toggleBreakpoints(false, breakpointsAtLine));
|
||||
};
|
||||
}
|
||||
|
||||
export function toggleDisabledBreakpoint(cx: Context, breakpoint: Breakpoint) {
|
||||
export function toggleDisabledBreakpoint(breakpoint: Breakpoint) {
|
||||
return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
if (!breakpoint.disabled) {
|
||||
return dispatch(disableBreakpoint(cx, breakpoint));
|
||||
return dispatch(disableBreakpoint(breakpoint));
|
||||
}
|
||||
return dispatch(enableBreakpoint(cx, breakpoint));
|
||||
return dispatch(enableBreakpoint(breakpoint));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,7 @@ import type { ThunkArgs } from "../types";
|
||||
import type {
|
||||
Breakpoint,
|
||||
BreakpointOptions,
|
||||
SourceLocation,
|
||||
Context
|
||||
SourceLocation
|
||||
} from "../../types";
|
||||
|
||||
import {
|
||||
@ -77,7 +76,7 @@ function clientRemoveBreakpoint(breakpoint: Breakpoint) {
|
||||
};
|
||||
}
|
||||
|
||||
export function enableBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
export function enableBreakpoint(initialBreakpoint: Breakpoint) {
|
||||
return async ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
const breakpoint = getBreakpoint(getState(), initialBreakpoint.location);
|
||||
if (!breakpoint || !breakpoint.disabled) {
|
||||
@ -86,7 +85,6 @@ export function enableBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
|
||||
dispatch({
|
||||
type: "SET_BREAKPOINT",
|
||||
cx,
|
||||
breakpoint: { ...breakpoint, disabled: false }
|
||||
});
|
||||
|
||||
@ -95,7 +93,6 @@ export function enableBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
}
|
||||
|
||||
export function addBreakpoint(
|
||||
cx: Context,
|
||||
initialLocation: SourceLocation,
|
||||
options: BreakpointOptions = {},
|
||||
disabled: boolean = false
|
||||
@ -105,7 +102,7 @@ export function addBreakpoint(
|
||||
|
||||
const { sourceId, column } = initialLocation;
|
||||
|
||||
await dispatch(setBreakpointPositions(cx, sourceId));
|
||||
await dispatch(setBreakpointPositions(sourceId));
|
||||
|
||||
const position = column
|
||||
? getBreakpointPositionsForLocation(getState(), initialLocation)
|
||||
@ -120,13 +117,10 @@ export function addBreakpoint(
|
||||
// Both the original and generated sources must be loaded to get the
|
||||
// breakpoint's text.
|
||||
await dispatch(
|
||||
loadSourceText(cx, getSourceFromId(getState(), location.sourceId))
|
||||
loadSourceText(getSourceFromId(getState(), location.sourceId))
|
||||
);
|
||||
await dispatch(
|
||||
loadSourceText(
|
||||
cx,
|
||||
getSourceFromId(getState(), generatedLocation.sourceId)
|
||||
)
|
||||
loadSourceText(getSourceFromId(getState(), generatedLocation.sourceId))
|
||||
);
|
||||
|
||||
const source = getSourceFromId(getState(), location.sourceId);
|
||||
@ -164,14 +158,12 @@ export function addBreakpoint(
|
||||
if (id != generatedId && getBreakpoint(getState(), generatedLocation)) {
|
||||
dispatch({
|
||||
type: "REMOVE_BREAKPOINT",
|
||||
cx,
|
||||
location: generatedLocation
|
||||
});
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: "SET_BREAKPOINT",
|
||||
cx,
|
||||
breakpoint
|
||||
});
|
||||
|
||||
@ -191,7 +183,7 @@ export function addBreakpoint(
|
||||
* @memberof actions/breakpoints
|
||||
* @static
|
||||
*/
|
||||
export function removeBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
export function removeBreakpoint(initialBreakpoint: Breakpoint) {
|
||||
return ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
recordEvent("remove_breakpoint");
|
||||
|
||||
@ -202,7 +194,6 @@ export function removeBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
|
||||
dispatch({
|
||||
type: "REMOVE_BREAKPOINT",
|
||||
cx,
|
||||
location: breakpoint.location
|
||||
});
|
||||
|
||||
@ -221,7 +212,7 @@ export function removeBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
* @memberof actions/breakpoints
|
||||
* @static
|
||||
*/
|
||||
export function disableBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
export function disableBreakpoint(initialBreakpoint: Breakpoint) {
|
||||
return ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const breakpoint = getBreakpoint(getState(), initialBreakpoint.location);
|
||||
if (!breakpoint || breakpoint.disabled) {
|
||||
@ -230,7 +221,6 @@ export function disableBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
|
||||
dispatch({
|
||||
type: "SET_BREAKPOINT",
|
||||
cx,
|
||||
breakpoint: { ...breakpoint, disabled: true }
|
||||
});
|
||||
|
||||
@ -250,14 +240,13 @@ export function disableBreakpoint(cx: Context, initialBreakpoint: Breakpoint) {
|
||||
* Any options to set on the breakpoint
|
||||
*/
|
||||
export function setBreakpointOptions(
|
||||
cx: Context,
|
||||
location: SourceLocation,
|
||||
options: BreakpointOptions = {}
|
||||
) {
|
||||
return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
let breakpoint = getBreakpoint(getState(), location);
|
||||
if (!breakpoint) {
|
||||
return dispatch(addBreakpoint(cx, location, options));
|
||||
return dispatch(addBreakpoint(location, options));
|
||||
}
|
||||
|
||||
// Note: setting a breakpoint's options implicitly enables it.
|
||||
@ -265,7 +254,6 @@ export function setBreakpointOptions(
|
||||
|
||||
dispatch({
|
||||
type: "SET_BREAKPOINT",
|
||||
cx,
|
||||
breakpoint
|
||||
});
|
||||
|
||||
|
@ -24,18 +24,14 @@ import type {
|
||||
SourceLocation,
|
||||
ASTLocation,
|
||||
PendingBreakpoint,
|
||||
SourceId,
|
||||
Context
|
||||
SourceId
|
||||
} from "../../types";
|
||||
|
||||
async function findBreakpointPosition(
|
||||
cx: Context,
|
||||
{ getState, dispatch },
|
||||
location: SourceLocation
|
||||
) {
|
||||
const positions = await dispatch(
|
||||
setBreakpointPositions(cx, location.sourceId)
|
||||
);
|
||||
const positions = await dispatch(setBreakpointPositions(location.sourceId));
|
||||
const position = findPosition(positions, location);
|
||||
return position && position.generatedLocation;
|
||||
}
|
||||
@ -79,7 +75,6 @@ async function findNewLocation(
|
||||
// to the reducer for the new location corresponding to the original location
|
||||
// in the pending breakpoint.
|
||||
export function syncBreakpoint(
|
||||
cx: Context,
|
||||
sourceId: SourceId,
|
||||
pendingBreakpoint: PendingBreakpoint
|
||||
) {
|
||||
@ -126,7 +121,6 @@ export function syncBreakpoint(
|
||||
}
|
||||
return dispatch(
|
||||
addBreakpoint(
|
||||
cx,
|
||||
sourceGeneratedLocation,
|
||||
pendingBreakpoint.options,
|
||||
pendingBreakpoint.disabled
|
||||
@ -143,7 +137,6 @@ export function syncBreakpoint(
|
||||
);
|
||||
|
||||
const newGeneratedLocation = await findBreakpointPosition(
|
||||
cx,
|
||||
thunkArgs,
|
||||
newLocation
|
||||
);
|
||||
@ -165,7 +158,7 @@ export function syncBreakpoint(
|
||||
if (!isSameLocation) {
|
||||
const bp = getBreakpoint(getState(), sourceGeneratedLocation);
|
||||
if (bp) {
|
||||
dispatch(removeBreakpoint(cx, bp));
|
||||
dispatch(removeBreakpoint(bp));
|
||||
} else {
|
||||
const breakpointLocation = makeBreakpointLocation(
|
||||
getState(),
|
||||
@ -177,7 +170,6 @@ export function syncBreakpoint(
|
||||
|
||||
return dispatch(
|
||||
addBreakpoint(
|
||||
cx,
|
||||
newLocation,
|
||||
pendingBreakpoint.options,
|
||||
pendingBreakpoint.disabled
|
||||
|
@ -18,10 +18,10 @@ describe("breakpointPositions", () => {
|
||||
getBreakpointPositions: async () => ({ "9": [1] })
|
||||
});
|
||||
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
await dispatch(actions.newSource(makeSource("foo")));
|
||||
|
||||
dispatch(actions.setBreakpointPositions(cx, "foo"));
|
||||
dispatch(actions.setBreakpointPositions("foo"));
|
||||
|
||||
await waitForState(store, state =>
|
||||
selectors.hasBreakpointPositions(state, "foo")
|
||||
@ -58,11 +58,11 @@ describe("breakpointPositions", () => {
|
||||
})
|
||||
});
|
||||
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
await dispatch(actions.newSource(makeSource("foo")));
|
||||
|
||||
dispatch(actions.setBreakpointPositions(cx, "foo"));
|
||||
dispatch(actions.setBreakpointPositions(cx, "foo"));
|
||||
dispatch(actions.setBreakpointPositions("foo"));
|
||||
dispatch(actions.setBreakpointPositions("foo"));
|
||||
|
||||
resolve({ "9": [1] });
|
||||
await waitForState(store, state =>
|
||||
|
@ -23,7 +23,7 @@ function mockClient(positionsResponse = {}) {
|
||||
|
||||
describe("breakpoints", () => {
|
||||
it("should add a breakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "2": [1] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "2": [1] }));
|
||||
const loc1 = {
|
||||
sourceId: "a",
|
||||
line: 2,
|
||||
@ -33,16 +33,16 @@ describe("breakpoints", () => {
|
||||
|
||||
const source = makeSource("a");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
await dispatch(
|
||||
actions.setSelectedLocation(cx, source, {
|
||||
actions.setSelectedLocation(source, {
|
||||
line: 1,
|
||||
column: 1,
|
||||
sourceId: source.id
|
||||
})
|
||||
);
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc1));
|
||||
await dispatch(actions.addBreakpoint(loc1));
|
||||
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(1);
|
||||
const bp = selectors.getBreakpoint(getState(), loc1);
|
||||
@ -54,7 +54,7 @@ describe("breakpoints", () => {
|
||||
});
|
||||
|
||||
it("should not show a breakpoint that does not have text", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "5": [1] }));
|
||||
const loc1 = {
|
||||
sourceId: "a",
|
||||
line: 5,
|
||||
@ -63,16 +63,16 @@ describe("breakpoints", () => {
|
||||
};
|
||||
const source = makeSource("a");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
await dispatch(
|
||||
actions.setSelectedLocation(cx, source, {
|
||||
actions.setSelectedLocation(source, {
|
||||
line: 1,
|
||||
column: 1,
|
||||
sourceId: source.id
|
||||
})
|
||||
);
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc1));
|
||||
await dispatch(actions.addBreakpoint(loc1));
|
||||
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(1);
|
||||
const bp = selectors.getBreakpoint(getState(), loc1);
|
||||
@ -81,7 +81,7 @@ describe("breakpoints", () => {
|
||||
});
|
||||
|
||||
it("should show a disabled breakpoint that does not have text", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "5": [1] }));
|
||||
const loc1 = {
|
||||
sourceId: "a",
|
||||
line: 5,
|
||||
@ -90,22 +90,22 @@ describe("breakpoints", () => {
|
||||
};
|
||||
const source = makeSource("a");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
await dispatch(
|
||||
actions.setSelectedLocation(cx, source, {
|
||||
actions.setSelectedLocation(source, {
|
||||
line: 1,
|
||||
column: 1,
|
||||
sourceId: source.id
|
||||
})
|
||||
);
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc1));
|
||||
await dispatch(actions.addBreakpoint(loc1));
|
||||
const breakpoint = selectors.getBreakpoint(getState(), loc1);
|
||||
if (!breakpoint) {
|
||||
throw new Error("no breakpoint");
|
||||
}
|
||||
|
||||
await dispatch(actions.disableBreakpoint(cx, breakpoint));
|
||||
await dispatch(actions.disableBreakpoint(breakpoint));
|
||||
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(1);
|
||||
const bp = selectors.getBreakpoint(getState(), loc1);
|
||||
@ -114,7 +114,7 @@ describe("breakpoints", () => {
|
||||
});
|
||||
|
||||
it("should not re-add a breakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "5": [1] }));
|
||||
const loc1 = {
|
||||
sourceId: "a",
|
||||
line: 5,
|
||||
@ -124,26 +124,26 @@ describe("breakpoints", () => {
|
||||
|
||||
const source = makeSource("a");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
await dispatch(
|
||||
actions.setSelectedLocation(cx, source, {
|
||||
actions.setSelectedLocation(source, {
|
||||
line: 1,
|
||||
column: 1,
|
||||
sourceId: source.id
|
||||
})
|
||||
);
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc1));
|
||||
await dispatch(actions.addBreakpoint(loc1));
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(1);
|
||||
const bp = selectors.getBreakpoint(getState(), loc1);
|
||||
expect(bp && bp.location).toEqual(loc1);
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc1));
|
||||
await dispatch(actions.addBreakpoint(loc1));
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(1);
|
||||
});
|
||||
|
||||
it("should remove a breakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [1], "6": [2] })
|
||||
);
|
||||
|
||||
@ -163,34 +163,34 @@ describe("breakpoints", () => {
|
||||
|
||||
const aSource = makeSource("a");
|
||||
await dispatch(actions.newSource(aSource));
|
||||
await dispatch(actions.loadSourceText(cx, aSource));
|
||||
await dispatch(actions.loadSourceText(aSource));
|
||||
|
||||
const bSource = makeSource("b");
|
||||
await dispatch(actions.newSource(bSource));
|
||||
await dispatch(actions.loadSourceText(cx, bSource));
|
||||
await dispatch(actions.loadSourceText(bSource));
|
||||
|
||||
await dispatch(
|
||||
actions.setSelectedLocation(cx, aSource, {
|
||||
actions.setSelectedLocation(aSource, {
|
||||
line: 1,
|
||||
column: 1,
|
||||
sourceId: aSource.id
|
||||
})
|
||||
);
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc1));
|
||||
await dispatch(actions.addBreakpoint(cx, loc2));
|
||||
await dispatch(actions.addBreakpoint(loc1));
|
||||
await dispatch(actions.addBreakpoint(loc2));
|
||||
|
||||
const bp = selectors.getBreakpoint(getState(), loc1);
|
||||
if (!bp) {
|
||||
throw new Error("no bp");
|
||||
}
|
||||
await dispatch(actions.removeBreakpoint(cx, bp));
|
||||
await dispatch(actions.removeBreakpoint(bp));
|
||||
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(1);
|
||||
});
|
||||
|
||||
it("should disable a breakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [1], "6": [2] })
|
||||
);
|
||||
|
||||
@ -210,28 +210,28 @@ describe("breakpoints", () => {
|
||||
|
||||
const aSource = makeSource("a");
|
||||
await dispatch(actions.newSource(aSource));
|
||||
await dispatch(actions.loadSourceText(cx, aSource));
|
||||
await dispatch(actions.loadSourceText(aSource));
|
||||
|
||||
const bSource = makeSource("b");
|
||||
await dispatch(actions.newSource(bSource));
|
||||
await dispatch(actions.loadSourceText(cx, bSource));
|
||||
await dispatch(actions.loadSourceText(bSource));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc1));
|
||||
await dispatch(actions.addBreakpoint(cx, loc2));
|
||||
await dispatch(actions.addBreakpoint(loc1));
|
||||
await dispatch(actions.addBreakpoint(loc2));
|
||||
|
||||
const breakpoint = selectors.getBreakpoint(getState(), loc1);
|
||||
if (!breakpoint) {
|
||||
throw new Error("no breakpoint");
|
||||
}
|
||||
|
||||
await dispatch(actions.disableBreakpoint(cx, breakpoint));
|
||||
await dispatch(actions.disableBreakpoint(breakpoint));
|
||||
|
||||
const bp = selectors.getBreakpoint(getState(), loc1);
|
||||
expect(bp && bp.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it("should enable breakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [1], "6": [2] })
|
||||
);
|
||||
const loc = {
|
||||
@ -243,15 +243,15 @@ describe("breakpoints", () => {
|
||||
|
||||
const aSource = makeSource("a");
|
||||
await dispatch(actions.newSource(aSource));
|
||||
await dispatch(actions.loadSourceText(cx, aSource));
|
||||
await dispatch(actions.loadSourceText(aSource));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc));
|
||||
await dispatch(actions.addBreakpoint(loc));
|
||||
let bp = selectors.getBreakpoint(getState(), loc);
|
||||
if (!bp) {
|
||||
throw new Error("no breakpoint");
|
||||
}
|
||||
|
||||
await dispatch(actions.disableBreakpoint(cx, bp));
|
||||
await dispatch(actions.disableBreakpoint(bp));
|
||||
|
||||
bp = selectors.getBreakpoint(getState(), loc);
|
||||
if (!bp) {
|
||||
@ -260,14 +260,14 @@ describe("breakpoints", () => {
|
||||
|
||||
expect(bp && bp.disabled).toBe(true);
|
||||
|
||||
await dispatch(actions.enableBreakpoint(cx, bp));
|
||||
await dispatch(actions.enableBreakpoint(bp));
|
||||
|
||||
bp = selectors.getBreakpoint(getState(), loc);
|
||||
expect(bp && !bp.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it("should toggle all the breakpoints", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [1], "6": [2] })
|
||||
);
|
||||
|
||||
@ -287,16 +287,16 @@ describe("breakpoints", () => {
|
||||
|
||||
const aSource = makeSource("a");
|
||||
await dispatch(actions.newSource(aSource));
|
||||
await dispatch(actions.loadSourceText(cx, aSource));
|
||||
await dispatch(actions.loadSourceText(aSource));
|
||||
|
||||
const bSource = makeSource("b");
|
||||
await dispatch(actions.newSource(bSource));
|
||||
await dispatch(actions.loadSourceText(cx, bSource));
|
||||
await dispatch(actions.loadSourceText(bSource));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc1));
|
||||
await dispatch(actions.addBreakpoint(cx, loc2));
|
||||
await dispatch(actions.addBreakpoint(loc1));
|
||||
await dispatch(actions.addBreakpoint(loc2));
|
||||
|
||||
await dispatch(actions.toggleAllBreakpoints(cx, true));
|
||||
await dispatch(actions.toggleAllBreakpoints(true));
|
||||
|
||||
let bp1 = selectors.getBreakpoint(getState(), loc1);
|
||||
let bp2 = selectors.getBreakpoint(getState(), loc2);
|
||||
@ -304,7 +304,7 @@ describe("breakpoints", () => {
|
||||
expect(bp1 && bp1.disabled).toBe(true);
|
||||
expect(bp2 && bp2.disabled).toBe(true);
|
||||
|
||||
await dispatch(actions.toggleAllBreakpoints(cx, false));
|
||||
await dispatch(actions.toggleAllBreakpoints(false));
|
||||
|
||||
bp1 = selectors.getBreakpoint(getState(), loc1);
|
||||
bp2 = selectors.getBreakpoint(getState(), loc2);
|
||||
@ -316,19 +316,19 @@ describe("breakpoints", () => {
|
||||
const loc = { sourceId: "foo1", line: 5, column: 1 };
|
||||
const getBp = () => selectors.getBreakpoint(getState(), loc);
|
||||
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "5": [1] }));
|
||||
|
||||
const source = makeSource("foo1");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.selectLocation(cx, loc));
|
||||
await dispatch(actions.selectLocation(loc));
|
||||
|
||||
await dispatch(actions.toggleBreakpointAtLine(cx, 5));
|
||||
await dispatch(actions.toggleBreakpointAtLine(5));
|
||||
const bp = getBp();
|
||||
expect(bp && !bp.disabled).toBe(true);
|
||||
|
||||
await dispatch(actions.toggleBreakpointAtLine(cx, 5));
|
||||
await dispatch(actions.toggleBreakpointAtLine(5));
|
||||
expect(getBp()).toBe(undefined);
|
||||
});
|
||||
|
||||
@ -336,28 +336,28 @@ describe("breakpoints", () => {
|
||||
const location = { sourceId: "foo1", line: 5, column: 1 };
|
||||
const getBp = () => selectors.getBreakpoint(getState(), location);
|
||||
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "5": [1] }));
|
||||
|
||||
const source = makeSource("foo1");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo1", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "foo1", line: 1 }));
|
||||
|
||||
await dispatch(actions.toggleBreakpointAtLine(cx, 5));
|
||||
await dispatch(actions.toggleBreakpointAtLine(5));
|
||||
let bp = getBp();
|
||||
expect(bp && !bp.disabled).toBe(true);
|
||||
bp = getBp();
|
||||
if (!bp) {
|
||||
throw new Error("no bp");
|
||||
}
|
||||
await dispatch(actions.toggleDisabledBreakpoint(cx, bp));
|
||||
await dispatch(actions.toggleDisabledBreakpoint(bp));
|
||||
bp = getBp();
|
||||
expect(bp && bp.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it("should set the breakpoint condition", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "5": [1] }));
|
||||
|
||||
const loc = {
|
||||
sourceId: "a",
|
||||
@ -368,15 +368,15 @@ describe("breakpoints", () => {
|
||||
|
||||
const source = makeSource("a");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc));
|
||||
await dispatch(actions.addBreakpoint(loc));
|
||||
|
||||
let bp = selectors.getBreakpoint(getState(), loc);
|
||||
expect(bp && bp.options.condition).toBe(undefined);
|
||||
|
||||
await dispatch(
|
||||
actions.setBreakpointOptions(cx, loc, {
|
||||
actions.setBreakpointOptions(loc, {
|
||||
condition: "const foo = 0",
|
||||
getTextForLine: () => {}
|
||||
})
|
||||
@ -387,7 +387,7 @@ describe("breakpoints", () => {
|
||||
});
|
||||
|
||||
it("should set the condition and enable a breakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "5": [1] }));
|
||||
|
||||
const loc = {
|
||||
sourceId: "a",
|
||||
@ -398,21 +398,21 @@ describe("breakpoints", () => {
|
||||
|
||||
const source = makeSource("a");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc));
|
||||
await dispatch(actions.addBreakpoint(loc));
|
||||
let bp = selectors.getBreakpoint(getState(), loc);
|
||||
if (!bp) {
|
||||
throw new Error("no breakpoint");
|
||||
}
|
||||
|
||||
await dispatch(actions.disableBreakpoint(cx, bp));
|
||||
await dispatch(actions.disableBreakpoint(bp));
|
||||
|
||||
bp = selectors.getBreakpoint(getState(), loc);
|
||||
expect(bp && bp.options.condition).toBe(undefined);
|
||||
|
||||
await dispatch(
|
||||
actions.setBreakpointOptions(cx, loc, {
|
||||
actions.setBreakpointOptions(loc, {
|
||||
condition: "const foo = 0",
|
||||
getTextForLine: () => {}
|
||||
})
|
||||
@ -425,7 +425,7 @@ describe("breakpoints", () => {
|
||||
});
|
||||
|
||||
it("should remap breakpoints on pretty print", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockClient({ "1": [0] }));
|
||||
const { dispatch, getState } = createStore(mockClient({ "1": [0] }));
|
||||
|
||||
const loc = {
|
||||
sourceId: "a.js",
|
||||
@ -436,10 +436,10 @@ describe("breakpoints", () => {
|
||||
|
||||
const source = makeSource("a.js");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, loc));
|
||||
await dispatch(actions.togglePrettyPrint(cx, "a.js"));
|
||||
await dispatch(actions.addBreakpoint(loc));
|
||||
await dispatch(actions.togglePrettyPrint("a.js"));
|
||||
|
||||
const breakpoint = selectors.getBreakpointsList(getState())[0];
|
||||
|
||||
|
@ -6,13 +6,10 @@
|
||||
|
||||
import type { Action, ThunkArgs } from "./types";
|
||||
|
||||
import { getContext } from "../selectors";
|
||||
|
||||
export function updateWorkers() {
|
||||
return async function({ dispatch, getState, client }: ThunkArgs) {
|
||||
const cx = getContext(getState());
|
||||
const workers = await client.fetchWorkers();
|
||||
const mainThread = client.getMainThread();
|
||||
dispatch(({ type: "SET_WORKERS", cx, workers, mainThread }: Action));
|
||||
dispatch(({ type: "SET_WORKERS", workers, mainThread }: Action));
|
||||
};
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import { features } from "../utils/prefs";
|
||||
import { isOriginal } from "../utils/source";
|
||||
|
||||
import * as parser from "../workers/parser";
|
||||
import type { Expression, ThreadContext } from "../types";
|
||||
import type { Expression } from "../types";
|
||||
import type { ThunkArgs } from "./types";
|
||||
|
||||
/**
|
||||
@ -33,7 +33,7 @@ import type { ThunkArgs } from "./types";
|
||||
* @memberof actions/pause
|
||||
* @static
|
||||
*/
|
||||
export function addExpression(cx: ThreadContext, input: string) {
|
||||
export function addExpression(input: string) {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (!input) {
|
||||
return;
|
||||
@ -43,26 +43,27 @@ export function addExpression(cx: ThreadContext, input: string) {
|
||||
|
||||
const expression = getExpression(getState(), input);
|
||||
if (expression) {
|
||||
return dispatch(evaluateExpression(cx, expression));
|
||||
return dispatch(evaluateExpression(expression));
|
||||
}
|
||||
|
||||
dispatch({ type: "ADD_EXPRESSION", cx, input, expressionError });
|
||||
dispatch({ type: "ADD_EXPRESSION", input, expressionError });
|
||||
|
||||
const newExpression = getExpression(getState(), input);
|
||||
if (newExpression) {
|
||||
return dispatch(evaluateExpression(cx, newExpression));
|
||||
return dispatch(evaluateExpression(newExpression));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function autocomplete(cx: ThreadContext, input: string, cursor: number) {
|
||||
export function autocomplete(input: string, cursor: number) {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
if (!input) {
|
||||
return;
|
||||
}
|
||||
const frameId = getSelectedFrameId(getState(), cx.thread);
|
||||
const thread = getCurrentThread(getState());
|
||||
const frameId = getSelectedFrameId(getState(), thread);
|
||||
const result = await client.autocomplete(input, cursor, frameId);
|
||||
await dispatch({ type: "AUTOCOMPLETE", cx, input, result });
|
||||
await dispatch({ type: "AUTOCOMPLETE", input, result });
|
||||
};
|
||||
}
|
||||
|
||||
@ -74,11 +75,7 @@ export function clearExpressionError() {
|
||||
return { type: "CLEAR_EXPRESSION_ERROR" };
|
||||
}
|
||||
|
||||
export function updateExpression(
|
||||
cx: ThreadContext,
|
||||
input: string,
|
||||
expression: Expression
|
||||
) {
|
||||
export function updateExpression(input: string, expression: Expression) {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (!input) {
|
||||
return;
|
||||
@ -87,13 +84,12 @@ export function updateExpression(
|
||||
const expressionError = await parser.hasSyntaxError(input);
|
||||
dispatch({
|
||||
type: "UPDATE_EXPRESSION",
|
||||
cx,
|
||||
expression,
|
||||
input: expressionError ? expression.input : input,
|
||||
expressionError
|
||||
});
|
||||
|
||||
dispatch(evaluateExpressions(cx));
|
||||
dispatch(evaluateExpressions());
|
||||
};
|
||||
}
|
||||
|
||||
@ -119,20 +115,21 @@ export function deleteExpression(expression: Expression) {
|
||||
* @param {number} selectedFrameId
|
||||
* @static
|
||||
*/
|
||||
export function evaluateExpressions(cx: ThreadContext) {
|
||||
export function evaluateExpressions() {
|
||||
return async function({ dispatch, getState, client }: ThunkArgs) {
|
||||
const expressions = getExpressions(getState()).toJS();
|
||||
const inputs = expressions.map(({ input }) => input);
|
||||
const frameId = getSelectedFrameId(getState(), cx.thread);
|
||||
const thread = getCurrentThread(getState());
|
||||
const frameId = getSelectedFrameId(getState(), thread);
|
||||
const results = await client.evaluateExpressions(inputs, {
|
||||
frameId,
|
||||
thread: cx.thread
|
||||
thread
|
||||
});
|
||||
dispatch({ type: "EVALUATE_EXPRESSIONS", cx, inputs, results });
|
||||
dispatch({ type: "EVALUATE_EXPRESSIONS", inputs, results });
|
||||
};
|
||||
}
|
||||
|
||||
function evaluateExpression(cx: ThreadContext, expression: Expression) {
|
||||
function evaluateExpression(expression: Expression) {
|
||||
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
|
||||
if (!expression.input) {
|
||||
console.warn("Expressions should not be empty");
|
||||
@ -140,7 +137,8 @@ function evaluateExpression(cx: ThreadContext, expression: Expression) {
|
||||
}
|
||||
|
||||
let input = expression.input;
|
||||
const frame = getSelectedFrame(getState(), cx.thread);
|
||||
const thread = getCurrentThread(getState());
|
||||
const frame = getSelectedFrame(getState(), thread);
|
||||
|
||||
if (frame) {
|
||||
const { location } = frame;
|
||||
@ -156,16 +154,15 @@ function evaluateExpression(cx: ThreadContext, expression: Expression) {
|
||||
}
|
||||
}
|
||||
|
||||
const frameId = getSelectedFrameId(getState(), cx.thread);
|
||||
const frameId = getSelectedFrameId(getState(), thread);
|
||||
|
||||
return dispatch({
|
||||
type: "EVALUATE_EXPRESSION",
|
||||
cx,
|
||||
thread: cx.thread,
|
||||
thread,
|
||||
input: expression.input,
|
||||
[PROMISE]: client.evaluateInFrame(wrapExpression(input), {
|
||||
frameId,
|
||||
thread: cx.thread
|
||||
thread
|
||||
})
|
||||
});
|
||||
};
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
import { isWasm, renderWasmText } from "../utils/wasm";
|
||||
import { getMatches } from "../workers/search";
|
||||
import type { Action, FileTextSearchModifier, ThunkArgs } from "./types";
|
||||
import type { WasmSource, Context } from "../types";
|
||||
import type { WasmSource } from "../types";
|
||||
|
||||
import {
|
||||
getSelectedSource,
|
||||
@ -32,15 +32,15 @@ import {
|
||||
type Editor = Object;
|
||||
type Match = Object;
|
||||
|
||||
export function doSearch(cx: Context, query: string, editor: Editor) {
|
||||
export function doSearch(query: string, editor: Editor) {
|
||||
return ({ getState, dispatch }: ThunkArgs) => {
|
||||
const selectedSource = getSelectedSource(getState());
|
||||
if (!selectedSource || !selectedSource.text) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(setFileSearchQuery(cx, query));
|
||||
dispatch(searchContents(cx, query, editor));
|
||||
dispatch(setFileSearchQuery(query));
|
||||
dispatch(searchContents(query, editor));
|
||||
};
|
||||
}
|
||||
|
||||
@ -59,23 +59,20 @@ export function doSearchForHighlight(
|
||||
};
|
||||
}
|
||||
|
||||
export function setFileSearchQuery(cx: Context, query: string): Action {
|
||||
export function setFileSearchQuery(query: string): Action {
|
||||
return {
|
||||
type: "UPDATE_FILE_SEARCH_QUERY",
|
||||
cx,
|
||||
query
|
||||
};
|
||||
}
|
||||
|
||||
export function toggleFileSearchModifier(
|
||||
cx: Context,
|
||||
modifier: FileTextSearchModifier
|
||||
): Action {
|
||||
return { type: "TOGGLE_FILE_SEARCH_MODIFIER", cx, modifier };
|
||||
return { type: "TOGGLE_FILE_SEARCH_MODIFIER", modifier };
|
||||
}
|
||||
|
||||
export function updateSearchResults(
|
||||
cx: Context,
|
||||
characterIndex: number,
|
||||
line: number,
|
||||
matches: Match[]
|
||||
@ -86,7 +83,6 @@ export function updateSearchResults(
|
||||
|
||||
return {
|
||||
type: "UPDATE_SEARCH_RESULTS",
|
||||
cx,
|
||||
results: {
|
||||
matches,
|
||||
matchIndex,
|
||||
@ -96,7 +92,7 @@ export function updateSearchResults(
|
||||
};
|
||||
}
|
||||
|
||||
export function searchContents(cx: Context, query: string, editor: Object) {
|
||||
export function searchContents(query: string, editor: Object) {
|
||||
return async ({ getState, dispatch }: ThunkArgs) => {
|
||||
const modifiers = getFileSearchModifiers(getState());
|
||||
const selectedSource = getSelectedSource(getState());
|
||||
@ -128,7 +124,7 @@ export function searchContents(cx: Context, query: string, editor: Object) {
|
||||
|
||||
const { ch, line } = res;
|
||||
|
||||
dispatch(updateSearchResults(cx, ch, line, matches));
|
||||
dispatch(updateSearchResults(ch, line, matches));
|
||||
};
|
||||
}
|
||||
|
||||
@ -159,7 +155,7 @@ export function searchContentsForHighlight(
|
||||
};
|
||||
}
|
||||
|
||||
export function traverseResults(cx: Context, rev: boolean, editor: Editor) {
|
||||
export function traverseResults(rev: boolean, editor: Editor) {
|
||||
return async ({ getState, dispatch }: ThunkArgs) => {
|
||||
if (!editor) {
|
||||
return;
|
||||
@ -184,12 +180,12 @@ export function traverseResults(cx: Context, rev: boolean, editor: Editor) {
|
||||
return;
|
||||
}
|
||||
const { ch, line } = results;
|
||||
dispatch(updateSearchResults(cx, ch, line, matchedLocations));
|
||||
dispatch(updateSearchResults(ch, line, matchedLocations));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function closeFileSearch(cx: Context, editor: Editor) {
|
||||
export function closeFileSearch(editor: Editor) {
|
||||
return ({ getState, dispatch }: ThunkArgs) => {
|
||||
if (editor) {
|
||||
const query = getFileSearchQuery(getState());
|
||||
@ -197,7 +193,7 @@ export function closeFileSearch(cx: Context, editor: Editor) {
|
||||
removeOverlay(ctx, query);
|
||||
}
|
||||
|
||||
dispatch(setFileSearchQuery(cx, ""));
|
||||
dispatch(setFileSearchQuery(""));
|
||||
dispatch(closeActiveSearch());
|
||||
dispatch(clearHighlightLineRange());
|
||||
};
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
// @flow
|
||||
|
||||
import { getCurrentThread } from "../../selectors";
|
||||
import type { ThunkArgs } from "../types";
|
||||
import type { ThreadContext } from "../../types";
|
||||
|
||||
/**
|
||||
* Debugger breakOnNext command.
|
||||
@ -15,9 +15,10 @@ import type { ThreadContext } from "../../types";
|
||||
* @memberof actions/pause
|
||||
* @static
|
||||
*/
|
||||
export function breakOnNext(cx: ThreadContext) {
|
||||
export function breakOnNext() {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
await client.breakOnNext(cx.thread);
|
||||
return dispatch({ type: "BREAK_ON_NEXT", thread: cx.thread });
|
||||
const thread = getCurrentThread(getState());
|
||||
await client.breakOnNext(thread);
|
||||
return dispatch({ type: "BREAK_ON_NEXT", thread });
|
||||
};
|
||||
}
|
||||
|
@ -6,39 +6,32 @@
|
||||
// @flow
|
||||
|
||||
import {
|
||||
getIsPaused,
|
||||
getCurrentThread,
|
||||
getSource,
|
||||
getTopFrame,
|
||||
getSelectedFrame,
|
||||
getThreadContext
|
||||
getSelectedFrame
|
||||
} from "../../selectors";
|
||||
import { PROMISE } from "../utils/middleware/promise";
|
||||
import { getNextStep } from "../../workers/parser";
|
||||
import { addHiddenBreakpoint } from "../breakpoints";
|
||||
import { evaluateExpressions } from "../expressions";
|
||||
import { selectLocation } from "../sources";
|
||||
import { fetchScopes } from "./fetchScopes";
|
||||
import { features } from "../../utils/prefs";
|
||||
import { recordEvent } from "../../utils/telemetry";
|
||||
import assert from "../../utils/assert";
|
||||
|
||||
import type { Source, ThreadId, Context, ThreadContext } from "../../types";
|
||||
import type { Source, ThreadId } from "../../types";
|
||||
import type { ThunkArgs } from "../types";
|
||||
import type { Command } from "../../reducers/types";
|
||||
|
||||
export function selectThread(cx: Context, thread: ThreadId) {
|
||||
export function selectThread(thread: ThreadId) {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
await dispatch({ cx, type: "SELECT_THREAD", thread });
|
||||
|
||||
// Get a new context now that the current thread has changed.
|
||||
const threadcx = getThreadContext(getState());
|
||||
assert(threadcx.thread == thread, "Thread mismatch");
|
||||
|
||||
dispatch(evaluateExpressions(threadcx));
|
||||
await dispatch({ type: "SELECT_THREAD", thread });
|
||||
dispatch(evaluateExpressions());
|
||||
|
||||
const frame = getSelectedFrame(getState(), thread);
|
||||
if (frame) {
|
||||
dispatch(selectLocation(threadcx, frame.location));
|
||||
dispatch(fetchScopes(threadcx));
|
||||
dispatch(selectLocation(frame.location));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -50,15 +43,14 @@ export function selectThread(cx: Context, thread: ThreadId) {
|
||||
* @memberof actions/pause
|
||||
* @static
|
||||
*/
|
||||
export function command(cx: ThreadContext, type: Command) {
|
||||
export function command(thread: ThreadId, type: Command) {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
if (type) {
|
||||
return dispatch({
|
||||
type: "COMMAND",
|
||||
command: type,
|
||||
cx,
|
||||
thread: cx.thread,
|
||||
[PROMISE]: client[type](cx.thread)
|
||||
thread,
|
||||
[PROMISE]: client[type](thread)
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -70,10 +62,11 @@ export function command(cx: ThreadContext, type: Command) {
|
||||
* @static
|
||||
* @returns {Function} {@link command}
|
||||
*/
|
||||
export function stepIn(cx: ThreadContext) {
|
||||
export function stepIn() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (cx.isPaused) {
|
||||
return dispatch(command(cx, "stepIn"));
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getIsPaused(getState(), thread)) {
|
||||
return dispatch(command(thread, "stepIn"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -84,10 +77,11 @@ export function stepIn(cx: ThreadContext) {
|
||||
* @static
|
||||
* @returns {Function} {@link command}
|
||||
*/
|
||||
export function stepOver(cx: ThreadContext) {
|
||||
export function stepOver() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (cx.isPaused) {
|
||||
return dispatch(astCommand(cx, "stepOver"));
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getIsPaused(getState(), thread)) {
|
||||
return dispatch(astCommand(thread, "stepOver"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -98,10 +92,11 @@ export function stepOver(cx: ThreadContext) {
|
||||
* @static
|
||||
* @returns {Function} {@link command}
|
||||
*/
|
||||
export function stepOut(cx: ThreadContext) {
|
||||
export function stepOut() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (cx.isPaused) {
|
||||
return dispatch(command(cx, "stepOut"));
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getIsPaused(getState(), thread)) {
|
||||
return dispatch(command(thread, "stepOut"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -112,11 +107,12 @@ export function stepOut(cx: ThreadContext) {
|
||||
* @static
|
||||
* @returns {Function} {@link command}
|
||||
*/
|
||||
export function resume(cx: ThreadContext) {
|
||||
export function resume() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (cx.isPaused) {
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getIsPaused(getState(), thread)) {
|
||||
recordEvent("continue");
|
||||
return dispatch(command(cx, "resume"));
|
||||
return dispatch(command(thread, "resume"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -127,10 +123,11 @@ export function resume(cx: ThreadContext) {
|
||||
* @static
|
||||
* @returns {Function} {@link command}
|
||||
*/
|
||||
export function rewind(cx: ThreadContext) {
|
||||
export function rewind() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (cx.isPaused) {
|
||||
return dispatch(command(cx, "rewind"));
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getIsPaused(getState(), thread)) {
|
||||
return dispatch(command(thread, "rewind"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -141,10 +138,11 @@ export function rewind(cx: ThreadContext) {
|
||||
* @static
|
||||
* @returns {Function} {@link command}
|
||||
*/
|
||||
export function reverseStepIn(cx: ThreadContext) {
|
||||
export function reverseStepIn() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (cx.isPaused) {
|
||||
return dispatch(command(cx, "reverseStepIn"));
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getIsPaused(getState(), thread)) {
|
||||
return dispatch(command(thread, "reverseStepIn"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -155,10 +153,11 @@ export function reverseStepIn(cx: ThreadContext) {
|
||||
* @static
|
||||
* @returns {Function} {@link command}
|
||||
*/
|
||||
export function reverseStepOver(cx: ThreadContext) {
|
||||
export function reverseStepOver() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (cx.isPaused) {
|
||||
return dispatch(astCommand(cx, "reverseStepOver"));
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getIsPaused(getState(), thread)) {
|
||||
return dispatch(astCommand(thread, "reverseStepOver"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -169,10 +168,11 @@ export function reverseStepOver(cx: ThreadContext) {
|
||||
* @static
|
||||
* @returns {Function} {@link command}
|
||||
*/
|
||||
export function reverseStepOut(cx: ThreadContext) {
|
||||
export function reverseStepOut() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
if (cx.isPaused) {
|
||||
return dispatch(command(cx, "reverseStepOut"));
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getIsPaused(getState(), thread)) {
|
||||
return dispatch(command(thread, "reverseStepOut"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -205,26 +205,26 @@ function hasAwait(source: Source, pauseLocation) {
|
||||
* @param stepType
|
||||
* @returns {function(ThunkArgs)}
|
||||
*/
|
||||
export function astCommand(cx: ThreadContext, stepType: Command) {
|
||||
export function astCommand(thread: ThreadId, stepType: Command) {
|
||||
return async ({ dispatch, getState, sourceMaps }: ThunkArgs) => {
|
||||
if (!features.asyncStepping) {
|
||||
return dispatch(command(cx, stepType));
|
||||
return dispatch(command(thread, stepType));
|
||||
}
|
||||
|
||||
if (stepType == "stepOver") {
|
||||
// This type definition is ambiguous:
|
||||
const frame: any = getTopFrame(getState(), cx.thread);
|
||||
const frame: any = getTopFrame(getState(), thread);
|
||||
const source = getSource(getState(), frame.location.sourceId);
|
||||
|
||||
if (source && hasAwait(source, frame.location)) {
|
||||
const nextLocation = await getNextStep(source.id, frame.location);
|
||||
if (nextLocation) {
|
||||
await dispatch(addHiddenBreakpoint(cx, nextLocation));
|
||||
return dispatch(command(cx, "resume"));
|
||||
await dispatch(addHiddenBreakpoint(nextLocation));
|
||||
return dispatch(command(thread, "resume"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dispatch(command(cx, stepType));
|
||||
return dispatch(command(thread, stepType));
|
||||
};
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
// @flow
|
||||
|
||||
import {
|
||||
getCurrentThread,
|
||||
getSelectedSource,
|
||||
getSelectedFrame,
|
||||
getCanRewind
|
||||
@ -13,16 +14,12 @@ import { addHiddenBreakpoint } from "../breakpoints";
|
||||
import { resume, rewind } from "./commands";
|
||||
|
||||
import type { ThunkArgs } from "../types";
|
||||
import type { ThreadContext } from "../../types";
|
||||
|
||||
export function continueToHere(
|
||||
cx: ThreadContext,
|
||||
line: number,
|
||||
column?: number
|
||||
) {
|
||||
export function continueToHere(line: number, column?: number) {
|
||||
return async function({ dispatch, getState }: ThunkArgs) {
|
||||
const thread = getCurrentThread(getState());
|
||||
const selectedSource = getSelectedSource(getState());
|
||||
const selectedFrame = getSelectedFrame(getState(), cx.thread);
|
||||
const selectedFrame = getSelectedFrame(getState(), thread);
|
||||
|
||||
if (!selectedFrame || !selectedSource) {
|
||||
return;
|
||||
@ -37,13 +34,13 @@ export function continueToHere(
|
||||
getCanRewind(getState()) && line < debugLine ? rewind : resume;
|
||||
|
||||
await dispatch(
|
||||
addHiddenBreakpoint(cx, {
|
||||
addHiddenBreakpoint({
|
||||
line,
|
||||
column: column,
|
||||
sourceId: selectedSource.id
|
||||
})
|
||||
);
|
||||
|
||||
dispatch(action(cx));
|
||||
dispatch(action());
|
||||
};
|
||||
}
|
||||
|
@ -7,24 +7,23 @@
|
||||
import { getSelectedFrame, getGeneratedFrameScope } from "../../selectors";
|
||||
import { mapScopes } from "./mapScopes";
|
||||
import { PROMISE } from "../utils/middleware/promise";
|
||||
import type { ThreadContext } from "../../types";
|
||||
import type { ThreadId } from "../../types";
|
||||
import type { ThunkArgs } from "../types";
|
||||
|
||||
export function fetchScopes(cx: ThreadContext) {
|
||||
export function fetchScopes(thread: ThreadId) {
|
||||
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
|
||||
const frame = getSelectedFrame(getState(), cx.thread);
|
||||
const frame = getSelectedFrame(getState(), thread);
|
||||
if (!frame || getGeneratedFrameScope(getState(), frame.id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scopes = dispatch({
|
||||
type: "ADD_SCOPES",
|
||||
cx,
|
||||
thread: cx.thread,
|
||||
thread,
|
||||
frame,
|
||||
[PROMISE]: client.getFrameScopes(frame)
|
||||
});
|
||||
|
||||
await dispatch(mapScopes(cx, scopes, frame));
|
||||
await dispatch(mapScopes(scopes, frame));
|
||||
};
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
import assert from "../../utils/assert";
|
||||
import { findClosestFunction } from "../../utils/ast";
|
||||
|
||||
import type { Frame, ThreadContext } from "../../types";
|
||||
import type { Frame, ThreadId } from "../../types";
|
||||
import type { State } from "../../reducers/types";
|
||||
import type { ThunkArgs } from "../types";
|
||||
|
||||
@ -161,9 +161,9 @@ async function expandFrames(
|
||||
* @memberof actions/pause
|
||||
* @static
|
||||
*/
|
||||
export function mapFrames(cx: ThreadContext) {
|
||||
export function mapFrames(thread: ThreadId) {
|
||||
return async function({ dispatch, getState, sourceMaps }: ThunkArgs) {
|
||||
const frames = getFrames(getState(), cx.thread);
|
||||
const frames = getFrames(getState(), thread);
|
||||
if (!frames) {
|
||||
return;
|
||||
}
|
||||
@ -174,13 +174,12 @@ export function mapFrames(cx: ThreadContext) {
|
||||
|
||||
const selectedFrameId = getSelectedFrameId(
|
||||
getState(),
|
||||
cx.thread,
|
||||
thread,
|
||||
mappedFrames
|
||||
);
|
||||
dispatch({
|
||||
type: "MAP_FRAMES",
|
||||
cx,
|
||||
thread: cx.thread,
|
||||
thread,
|
||||
frames: mappedFrames,
|
||||
selectedFrameId
|
||||
});
|
||||
|
@ -10,16 +10,15 @@ import {
|
||||
getSelectedFrame,
|
||||
getSelectedGeneratedScope,
|
||||
getSelectedOriginalScope,
|
||||
getThreadContext
|
||||
getCurrentThread
|
||||
} from "../../selectors";
|
||||
import { loadSourceText } from "../sources/loadSourceText";
|
||||
import { PROMISE } from "../utils/middleware/promise";
|
||||
import assert from "../../utils/assert";
|
||||
|
||||
import { features } from "../../utils/prefs";
|
||||
import { log } from "../../utils/log";
|
||||
import { isGenerated, isOriginal } from "../../utils/source";
|
||||
import type { Frame, Scope, ThreadContext } from "../../types";
|
||||
import type { Frame, Scope } from "../../types";
|
||||
|
||||
import type { ThunkArgs } from "../types";
|
||||
|
||||
@ -33,30 +32,23 @@ export function toggleMapScopes() {
|
||||
|
||||
dispatch({ type: "TOGGLE_MAP_SCOPES", mapScopes: true });
|
||||
|
||||
const cx = getThreadContext(getState());
|
||||
|
||||
if (getSelectedOriginalScope(getState(), cx.thread)) {
|
||||
const thread = getCurrentThread(getState());
|
||||
if (getSelectedOriginalScope(getState(), thread)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scopes = getSelectedGeneratedScope(getState(), cx.thread);
|
||||
const frame = getSelectedFrame(getState(), cx.thread);
|
||||
const scopes = getSelectedGeneratedScope(getState(), thread);
|
||||
const frame = getSelectedFrame(getState(), thread);
|
||||
if (!scopes || !frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(mapScopes(cx, Promise.resolve(scopes.scope), frame));
|
||||
dispatch(mapScopes(Promise.resolve(scopes.scope), frame));
|
||||
};
|
||||
}
|
||||
|
||||
export function mapScopes(
|
||||
cx: ThreadContext,
|
||||
scopes: Promise<Scope>,
|
||||
frame: Frame
|
||||
) {
|
||||
export function mapScopes(scopes: Promise<Scope>, frame: Frame) {
|
||||
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
|
||||
assert(cx.thread == frame.thread, "Thread mismatch");
|
||||
|
||||
const generatedSource = getSource(
|
||||
getState(),
|
||||
frame.generatedLocation.sourceId
|
||||
@ -66,8 +58,7 @@ export function mapScopes(
|
||||
|
||||
await dispatch({
|
||||
type: "MAP_SCOPES",
|
||||
cx,
|
||||
thread: cx.thread,
|
||||
thread: frame.thread,
|
||||
frame,
|
||||
[PROMISE]: (async function() {
|
||||
if (
|
||||
@ -81,9 +72,9 @@ export function mapScopes(
|
||||
return null;
|
||||
}
|
||||
|
||||
await dispatch(loadSourceText(cx, source));
|
||||
await dispatch(loadSourceText(source));
|
||||
if (isOriginal(source)) {
|
||||
await dispatch(loadSourceText(cx, generatedSource));
|
||||
await dispatch(loadSourceText(generatedSource));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -7,8 +7,7 @@ import {
|
||||
getHiddenBreakpoint,
|
||||
isEvaluatingExpression,
|
||||
getSelectedFrame,
|
||||
wasStepping,
|
||||
getThreadContext
|
||||
wasStepping
|
||||
} from "../../selectors";
|
||||
|
||||
import { mapFrames } from ".";
|
||||
@ -16,7 +15,6 @@ import { removeBreakpoint } from "../breakpoints";
|
||||
import { evaluateExpressions } from "../expressions";
|
||||
import { selectLocation } from "../sources";
|
||||
import { togglePaneCollapse } from "../ui";
|
||||
import assert from "../../utils/assert";
|
||||
|
||||
import { fetchScopes } from "./fetchScopes";
|
||||
|
||||
@ -44,33 +42,29 @@ export function paused(pauseInfo: Pause) {
|
||||
loadedObjects: loadedObjects || []
|
||||
});
|
||||
|
||||
// Get a context capturing the newly paused and selected thread.
|
||||
const cx = getThreadContext(getState());
|
||||
assert(cx.thread == thread, "Thread mismatch");
|
||||
|
||||
const hiddenBreakpoint = getHiddenBreakpoint(getState());
|
||||
if (hiddenBreakpoint) {
|
||||
dispatch(removeBreakpoint(cx, hiddenBreakpoint));
|
||||
dispatch(removeBreakpoint(hiddenBreakpoint));
|
||||
}
|
||||
|
||||
await dispatch(mapFrames(cx));
|
||||
await dispatch(mapFrames(thread));
|
||||
|
||||
const selectedFrame = getSelectedFrame(getState(), thread);
|
||||
if (selectedFrame) {
|
||||
await dispatch(selectLocation(cx, selectedFrame.location));
|
||||
await dispatch(selectLocation(selectedFrame.location));
|
||||
}
|
||||
|
||||
if (!wasStepping(getState(), thread)) {
|
||||
dispatch(togglePaneCollapse("end", false));
|
||||
}
|
||||
|
||||
await dispatch(fetchScopes(cx));
|
||||
await dispatch(fetchScopes(thread));
|
||||
|
||||
// Run after fetching scoping data so that it may make use of the sourcemap
|
||||
// expression mappings for local variables.
|
||||
const atException = why.type == "exception";
|
||||
if (!atException || !isEvaluatingExpression(getState(), thread)) {
|
||||
await dispatch(evaluateExpressions(cx));
|
||||
await dispatch(evaluateExpressions());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// @flow
|
||||
|
||||
import { isStepping, getPauseReason, getThreadContext } from "../../selectors";
|
||||
import { isStepping, getPauseReason } from "../../selectors";
|
||||
import { evaluateExpressions } from "../expressions";
|
||||
import { inDebuggerEval } from "../../utils/pause";
|
||||
|
||||
@ -26,9 +26,8 @@ export function resumed(packet: ResumedPacket) {
|
||||
|
||||
dispatch({ type: "RESUME", thread, wasStepping });
|
||||
|
||||
const cx = getThreadContext(getState());
|
||||
if (!wasStepping && !wasPausedInEval && cx.thread == thread) {
|
||||
await dispatch(evaluateExpressions(cx));
|
||||
if (!wasStepping && !wasPausedInEval) {
|
||||
await dispatch(evaluateExpressions());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -7,29 +7,25 @@
|
||||
import { selectLocation } from "../sources";
|
||||
import { evaluateExpressions } from "../expressions";
|
||||
import { fetchScopes } from "./fetchScopes";
|
||||
import assert from "../../utils/assert";
|
||||
|
||||
import type { Frame, ThreadContext } from "../../types";
|
||||
import type { Frame } from "../../types";
|
||||
import type { ThunkArgs } from "../types";
|
||||
|
||||
/**
|
||||
* @memberof actions/pause
|
||||
* @static
|
||||
*/
|
||||
export function selectFrame(cx: ThreadContext, frame: Frame) {
|
||||
export function selectFrame(frame: Frame) {
|
||||
return async ({ dispatch, client, getState, sourceMaps }: ThunkArgs) => {
|
||||
assert(cx.thread == frame.thread, "Thread mismatch");
|
||||
|
||||
dispatch({
|
||||
type: "SELECT_FRAME",
|
||||
cx,
|
||||
thread: cx.thread,
|
||||
thread: frame.thread,
|
||||
frame
|
||||
});
|
||||
|
||||
dispatch(selectLocation(cx, frame.location));
|
||||
dispatch(selectLocation(frame.location));
|
||||
|
||||
dispatch(evaluateExpressions(cx));
|
||||
dispatch(fetchScopes(cx));
|
||||
dispatch(evaluateExpressions());
|
||||
dispatch(fetchScopes(frame.thread));
|
||||
};
|
||||
}
|
||||
|
@ -4,30 +4,25 @@
|
||||
|
||||
// @flow
|
||||
|
||||
import { getPopupObjectProperties } from "../../selectors";
|
||||
import { getPopupObjectProperties, getCurrentThread } from "../../selectors";
|
||||
import type { ThunkArgs } from "../types";
|
||||
import type { ThreadContext } from "../../types";
|
||||
|
||||
/**
|
||||
* @memberof actions/pause
|
||||
* @static
|
||||
*/
|
||||
export function setPopupObjectProperties(
|
||||
cx: ThreadContext,
|
||||
object: any,
|
||||
properties: Object
|
||||
) {
|
||||
export function setPopupObjectProperties(object: any, properties: Object) {
|
||||
return ({ dispatch, client, getState }: ThunkArgs) => {
|
||||
const objectId = object.actor || object.objectId;
|
||||
const thread = getCurrentThread(getState());
|
||||
|
||||
if (getPopupObjectProperties(getState(), cx.thread, object.actor)) {
|
||||
if (getPopupObjectProperties(getState(), thread, object.actor)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: "SET_POPUP_OBJECT_PROPERTIES",
|
||||
cx,
|
||||
thread: cx.thread,
|
||||
thread,
|
||||
objectId,
|
||||
properties
|
||||
});
|
||||
|
@ -109,8 +109,7 @@ describe("pause", () => {
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo1")));
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
const cx = selectors.getThreadContext(getState());
|
||||
const stepped = dispatch(actions.stepIn(cx));
|
||||
const stepped = dispatch(actions.stepIn());
|
||||
expect(isStepping(getState(), "FakeThread")).toBeTruthy();
|
||||
if (!stepInResolve) {
|
||||
throw new Error("no stepInResolve");
|
||||
@ -122,9 +121,9 @@ describe("pause", () => {
|
||||
|
||||
it("should only step when paused", async () => {
|
||||
const client = { stepIn: jest.fn() };
|
||||
const { dispatch, cx } = createStore(client);
|
||||
const { dispatch } = createStore(client);
|
||||
|
||||
dispatch(actions.stepIn(cx));
|
||||
dispatch(actions.stepIn());
|
||||
expect(client.stepIn.mock.calls).toHaveLength(0);
|
||||
});
|
||||
|
||||
@ -134,8 +133,7 @@ describe("pause", () => {
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo1")));
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
const cx = selectors.getThreadContext(getState());
|
||||
dispatch(actions.stepIn(cx));
|
||||
dispatch(actions.stepIn());
|
||||
expect(isStepping(getState(), "FakeThread")).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -146,16 +144,15 @@ describe("pause", () => {
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo1")));
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
const cx = selectors.getThreadContext(getState());
|
||||
const getNextStepSpy = jest.spyOn(parser, "getNextStep");
|
||||
dispatch(actions.stepOver(cx));
|
||||
dispatch(actions.stepOver());
|
||||
expect(getNextStepSpy).not.toBeCalled();
|
||||
expect(isStepping(getState(), "FakeThread")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should step over when paused before an await", async () => {
|
||||
const store = createStore(mockThreadClient);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch } = store;
|
||||
const mockPauseInfo = createPauseInfo({
|
||||
sourceId: "await",
|
||||
line: 2,
|
||||
@ -164,19 +161,18 @@ describe("pause", () => {
|
||||
|
||||
const source = makeSource("await");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
const ncx = selectors.getThreadContext(getState());
|
||||
const getNextStepSpy = jest.spyOn(parser, "getNextStep");
|
||||
dispatch(actions.stepOver(ncx));
|
||||
dispatch(actions.stepOver());
|
||||
expect(getNextStepSpy).toBeCalled();
|
||||
getNextStepSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("should step over when paused after an await", async () => {
|
||||
const store = createStore(mockThreadClient);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch } = store;
|
||||
const mockPauseInfo = createPauseInfo({
|
||||
sourceId: "await",
|
||||
line: 2,
|
||||
@ -185,12 +181,11 @@ describe("pause", () => {
|
||||
|
||||
const source = makeSource("await");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
const ncx = selectors.getThreadContext(getState());
|
||||
const getNextStepSpy = jest.spyOn(parser, "getNextStep");
|
||||
dispatch(actions.stepOver(ncx));
|
||||
dispatch(actions.stepOver());
|
||||
expect(getNextStepSpy).toBeCalled();
|
||||
getNextStepSpy.mockRestore();
|
||||
});
|
||||
@ -203,7 +198,7 @@ describe("pause", () => {
|
||||
};
|
||||
|
||||
const store = createStore(mockThreadClient, {});
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const mockPauseInfo = createPauseInfo(generatedLocation, {
|
||||
scope: {
|
||||
bindings: { variables: { b: {} }, arguments: [{ a: {} }] }
|
||||
@ -213,7 +208,7 @@ describe("pause", () => {
|
||||
const source = makeSource("foo");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.newSource(makeOriginalSource("foo")));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
expect(selectors.getFrames(getState(), "FakeThread")).toEqual([
|
||||
@ -270,16 +265,16 @@ describe("pause", () => {
|
||||
};
|
||||
|
||||
const store = createStore(mockThreadClient, {}, sourceMapsMock);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const mockPauseInfo = createPauseInfo(generatedLocation);
|
||||
|
||||
const fooSource = makeSource("foo");
|
||||
const fooOriginalSource = makeSource("foo-original");
|
||||
await dispatch(actions.newSource(fooSource));
|
||||
await dispatch(actions.newSource(fooOriginalSource));
|
||||
await dispatch(actions.loadSourceText(cx, fooSource));
|
||||
await dispatch(actions.loadSourceText(cx, fooOriginalSource));
|
||||
await dispatch(actions.setSymbols(cx, "foo-original"));
|
||||
await dispatch(actions.loadSourceText(fooSource));
|
||||
await dispatch(actions.loadSourceText(fooOriginalSource));
|
||||
await dispatch(actions.setSymbols("foo-original"));
|
||||
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
expect(selectors.getFrames(getState(), "FakeThread")).toEqual([
|
||||
@ -336,7 +331,7 @@ describe("pause", () => {
|
||||
};
|
||||
|
||||
const store = createStore(mockThreadClient, {}, sourceMapsMock);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const mockPauseInfo = createPauseInfo(generatedLocation);
|
||||
|
||||
const source = makeSource("foo-wasm", { isWasm: true });
|
||||
@ -344,8 +339,8 @@ describe("pause", () => {
|
||||
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.newSource(originalSource));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(cx, originalSource));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
await dispatch(actions.loadSourceText(originalSource));
|
||||
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
expect(selectors.getFrames(getState(), "FakeThread")).toEqual([
|
||||
@ -379,26 +374,22 @@ describe("pause", () => {
|
||||
|
||||
describe("resumed", () => {
|
||||
it("should not evaluate expression while stepping", async () => {
|
||||
const client = { ...mockThreadClient, evaluateExpressions: jest.fn() };
|
||||
const { dispatch, getState } = createStore(client);
|
||||
const mockPauseInfo = createPauseInfo();
|
||||
const client = { evaluateExpressions: jest.fn() };
|
||||
const { dispatch } = createStore(client);
|
||||
|
||||
await dispatch(actions.paused(mockPauseInfo));
|
||||
|
||||
const cx = selectors.getThreadContext(getState());
|
||||
dispatch(actions.stepIn(cx));
|
||||
dispatch(actions.stepIn());
|
||||
await dispatch(actions.resumed(resumedPacket()));
|
||||
expect(client.evaluateExpressions.mock.calls).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("resuming - will re-evaluate watch expressions", async () => {
|
||||
const store = createStore(mockThreadClient);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const mockPauseInfo = createPauseInfo();
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo1")));
|
||||
await dispatch(actions.newSource(makeSource("foo")));
|
||||
await dispatch(actions.addExpression(cx, "foo"));
|
||||
dispatch(actions.addExpression("foo"));
|
||||
await waitForState(store, state => selectors.getExpression(state, "foo"));
|
||||
|
||||
mockThreadClient.evaluateExpressions = () => new Promise(r => r(["YAY"]));
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
import { getMappedExpression } from "./expressions";
|
||||
|
||||
import type { Action, ThunkArgs } from "./types";
|
||||
import type { Position, Context } from "../types";
|
||||
import type { Position } from "../types";
|
||||
import type { AstLocation } from "../workers/parser";
|
||||
|
||||
function findExpressionMatch(state, codeMirror, tokenPos) {
|
||||
@ -43,7 +43,6 @@ function findExpressionMatch(state, codeMirror, tokenPos) {
|
||||
}
|
||||
|
||||
export function updatePreview(
|
||||
cx: Context,
|
||||
target: HTMLElement,
|
||||
tokenPos: Object,
|
||||
codeMirror: any
|
||||
@ -69,12 +68,11 @@ export function updatePreview(
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(setPreview(cx, expression, location, tokenPos, cursorPos));
|
||||
dispatch(setPreview(expression, location, tokenPos, cursorPos));
|
||||
};
|
||||
}
|
||||
|
||||
export function setPreview(
|
||||
cx: Context,
|
||||
expression: string,
|
||||
location: AstLocation,
|
||||
tokenPos: Position,
|
||||
@ -83,7 +81,6 @@ export function setPreview(
|
||||
return async ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
await dispatch({
|
||||
type: "SET_PREVIEW",
|
||||
cx,
|
||||
[PROMISE]: (async function() {
|
||||
const source = getSelectedSource(getState());
|
||||
if (!source) {
|
||||
@ -129,7 +126,7 @@ export function setPreview(
|
||||
};
|
||||
}
|
||||
|
||||
export function clearPreview(cx: Context) {
|
||||
export function clearPreview() {
|
||||
return ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const currentSelection = getPreview(getState());
|
||||
if (!currentSelection) {
|
||||
@ -138,8 +135,7 @@ export function clearPreview(cx: Context) {
|
||||
|
||||
return dispatch(
|
||||
({
|
||||
type: "CLEAR_SELECTION",
|
||||
cx
|
||||
type: "CLEAR_SELECTION"
|
||||
}: Action)
|
||||
);
|
||||
};
|
||||
|
@ -20,73 +20,67 @@ import {
|
||||
} from "../reducers/project-text-search";
|
||||
|
||||
import type { Action, ThunkArgs } from "./types";
|
||||
import type { Context } from "../types";
|
||||
import type { SearchOperation } from "../reducers/project-text-search";
|
||||
|
||||
export function addSearchQuery(cx: Context, query: string): Action {
|
||||
return { type: "ADD_QUERY", cx, query };
|
||||
export function addSearchQuery(query: string): Action {
|
||||
return { type: "ADD_QUERY", query };
|
||||
}
|
||||
|
||||
export function addOngoingSearch(
|
||||
cx: Context,
|
||||
ongoingSearch: SearchOperation
|
||||
): Action {
|
||||
return { type: "ADD_ONGOING_SEARCH", cx, ongoingSearch };
|
||||
export function addOngoingSearch(ongoingSearch: SearchOperation): Action {
|
||||
return { type: "ADD_ONGOING_SEARCH", ongoingSearch };
|
||||
}
|
||||
|
||||
export function addSearchResult(
|
||||
cx: Context,
|
||||
sourceId: string,
|
||||
filepath: string,
|
||||
matches: Object[]
|
||||
): Action {
|
||||
return {
|
||||
type: "ADD_SEARCH_RESULT",
|
||||
cx,
|
||||
result: { sourceId, filepath, matches }
|
||||
};
|
||||
}
|
||||
|
||||
export function clearSearchResults(cx: Context): Action {
|
||||
return { type: "CLEAR_SEARCH_RESULTS", cx };
|
||||
export function clearSearchResults(): Action {
|
||||
return { type: "CLEAR_SEARCH_RESULTS" };
|
||||
}
|
||||
|
||||
export function clearSearch(cx: Context): Action {
|
||||
return { type: "CLEAR_SEARCH", cx };
|
||||
export function clearSearch(): Action {
|
||||
return { type: "CLEAR_SEARCH" };
|
||||
}
|
||||
|
||||
export function updateSearchStatus(cx: Context, status: string): Action {
|
||||
return { type: "UPDATE_STATUS", cx, status };
|
||||
export function updateSearchStatus(status: string): Action {
|
||||
return { type: "UPDATE_STATUS", status };
|
||||
}
|
||||
|
||||
export function closeProjectSearch(cx: Context) {
|
||||
export function closeProjectSearch() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
dispatch(stopOngoingSearch(cx));
|
||||
dispatch(stopOngoingSearch());
|
||||
dispatch({ type: "CLOSE_PROJECT_SEARCH" });
|
||||
};
|
||||
}
|
||||
|
||||
export function stopOngoingSearch(cx: Context) {
|
||||
export function stopOngoingSearch() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
const state = getState();
|
||||
const ongoingSearch = getTextSearchOperation(state);
|
||||
const status = getTextSearchStatus(state);
|
||||
if (ongoingSearch && status !== statusType.done) {
|
||||
ongoingSearch.cancel();
|
||||
dispatch(updateSearchStatus(cx, statusType.cancelled));
|
||||
dispatch(updateSearchStatus(statusType.cancelled));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function searchSources(cx: Context, query: string) {
|
||||
export function searchSources(query: string) {
|
||||
let cancelled = false;
|
||||
|
||||
const search = async ({ dispatch, getState }: ThunkArgs) => {
|
||||
dispatch(stopOngoingSearch(cx));
|
||||
await dispatch(addOngoingSearch(cx, search));
|
||||
await dispatch(clearSearchResults(cx));
|
||||
await dispatch(addSearchQuery(cx, query));
|
||||
dispatch(updateSearchStatus(cx, statusType.fetching));
|
||||
dispatch(stopOngoingSearch());
|
||||
await dispatch(addOngoingSearch(search));
|
||||
await dispatch(clearSearchResults());
|
||||
await dispatch(addSearchQuery(query));
|
||||
dispatch(updateSearchStatus(statusType.fetching));
|
||||
const validSources = getSourceList(getState()).filter(
|
||||
source => !hasPrettySource(getState(), source.id) && !isThirdParty(source)
|
||||
);
|
||||
@ -94,10 +88,10 @@ export function searchSources(cx: Context, query: string) {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
await dispatch(loadSourceText(cx, source));
|
||||
await dispatch(searchSource(cx, source.id, query));
|
||||
await dispatch(loadSourceText(source));
|
||||
await dispatch(searchSource(source.id, query));
|
||||
}
|
||||
dispatch(updateSearchStatus(cx, statusType.done));
|
||||
dispatch(updateSearchStatus(statusType.done));
|
||||
};
|
||||
|
||||
search.cancel = () => {
|
||||
@ -107,7 +101,7 @@ export function searchSources(cx: Context, query: string) {
|
||||
return search;
|
||||
}
|
||||
|
||||
export function searchSource(cx: Context, sourceId: string, query: string) {
|
||||
export function searchSource(sourceId: string, query: string) {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
const source = getSource(getState(), sourceId);
|
||||
if (!source) {
|
||||
@ -118,6 +112,6 @@ export function searchSource(cx: Context, sourceId: string, query: string) {
|
||||
if (!matches.length) {
|
||||
return;
|
||||
}
|
||||
dispatch(addSearchResult(cx, source.id, source.url, matches));
|
||||
dispatch(addSearchResult(source.id, source.url, matches));
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
// @flow
|
||||
|
||||
import type { Action, FocusItem, ThunkArgs } from "./types";
|
||||
import type { Context } from "../types";
|
||||
|
||||
export function setExpandedState(thread: string, expanded: Set<string>) {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
@ -18,11 +17,10 @@ export function setExpandedState(thread: string, expanded: Set<string>) {
|
||||
};
|
||||
}
|
||||
|
||||
export function focusItem(cx: Context, item: FocusItem) {
|
||||
export function focusItem(item: FocusItem) {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
dispatch({
|
||||
type: "SET_FOCUSED_SOURCE_ITEM",
|
||||
cx,
|
||||
item
|
||||
});
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ import { getSourceFromId } from "../../selectors";
|
||||
|
||||
import { PROMISE } from "../utils/middleware/promise";
|
||||
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
import type { ThunkArgs } from "../types";
|
||||
|
||||
async function blackboxActors(state, client, sourceId, isBlackBoxed, range?) {
|
||||
@ -27,7 +27,7 @@ async function blackboxActors(state, client, sourceId, isBlackBoxed, range?) {
|
||||
return { isBlackBoxed: !isBlackBoxed };
|
||||
}
|
||||
|
||||
export function toggleBlackBox(cx: Context, source: Source) {
|
||||
export function toggleBlackBox(source: Source) {
|
||||
return async ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
const { isBlackBoxed } = source;
|
||||
|
||||
@ -45,7 +45,6 @@ export function toggleBlackBox(cx: Context, source: Source) {
|
||||
|
||||
return dispatch({
|
||||
type: "BLACKBOX",
|
||||
cx,
|
||||
source,
|
||||
[PROMISE]: blackboxActors(
|
||||
getState(),
|
||||
|
@ -20,7 +20,7 @@ import { Telemetry } from "devtools-modules";
|
||||
|
||||
import type { ThunkArgs } from "../types";
|
||||
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
|
||||
const requests = new Map();
|
||||
|
||||
@ -68,7 +68,6 @@ async function loadSource(
|
||||
}
|
||||
|
||||
async function loadSourceTextPromise(
|
||||
cx: Context,
|
||||
source: Source,
|
||||
epoch: number,
|
||||
{ dispatch, getState, client, sourceMaps }: ThunkArgs
|
||||
@ -91,7 +90,7 @@ async function loadSourceTextPromise(
|
||||
|
||||
if (!newSource.isWasm && isLoaded(newSource)) {
|
||||
parser.setSource(newSource);
|
||||
dispatch(setBreakpointPositions(cx, newSource.id));
|
||||
dispatch(setBreakpointPositions(newSource.id));
|
||||
}
|
||||
|
||||
return newSource;
|
||||
@ -101,7 +100,7 @@ async function loadSourceTextPromise(
|
||||
* @memberof actions/sources
|
||||
* @static
|
||||
*/
|
||||
export function loadSourceText(cx: Context, inputSource: ?Source) {
|
||||
export function loadSourceText(inputSource: ?Source) {
|
||||
return async (thunkArgs: ThunkArgs) => {
|
||||
if (!inputSource) {
|
||||
return;
|
||||
@ -118,7 +117,7 @@ export function loadSourceText(cx: Context, inputSource: ?Source) {
|
||||
if (!promise) {
|
||||
promise = (async () => {
|
||||
try {
|
||||
return await loadSourceTextPromise(cx, source, epoch, thunkArgs);
|
||||
return await loadSourceTextPromise(source, epoch, thunkArgs);
|
||||
} catch (e) {
|
||||
// TODO: This swallows errors for now. Ideally we would get rid of
|
||||
// this once we have a better handle on our async state management.
|
||||
|
@ -28,14 +28,13 @@ import {
|
||||
getSource,
|
||||
getPendingSelectedLocation,
|
||||
getPendingBreakpointsForSource,
|
||||
hasBreakpointPositions,
|
||||
getContext
|
||||
hasBreakpointPositions
|
||||
} from "../../selectors";
|
||||
|
||||
import { prefs } from "../../utils/prefs";
|
||||
import sourceQueue from "../../utils/source-queue";
|
||||
|
||||
import type { Source, SourceId, Context } from "../../types";
|
||||
import type { Source, SourceId } from "../../types";
|
||||
import type { Action, ThunkArgs } from "../types";
|
||||
|
||||
function createOriginalSource(
|
||||
@ -58,14 +57,14 @@ function createOriginalSource(
|
||||
};
|
||||
}
|
||||
|
||||
function loadSourceMaps(cx: Context, sources: Source[]) {
|
||||
function loadSourceMaps(sources: Source[]) {
|
||||
return async function({
|
||||
dispatch,
|
||||
sourceMaps
|
||||
}: ThunkArgs): Promise<Promise<Source>[]> {
|
||||
const sourceList = await Promise.all(
|
||||
sources.map(async ({ id }) => {
|
||||
const originalSources = await dispatch(loadSourceMap(cx, id));
|
||||
const originalSources = await dispatch(loadSourceMap(id));
|
||||
sourceQueue.queueSources(originalSources);
|
||||
return originalSources;
|
||||
})
|
||||
@ -77,7 +76,7 @@ function loadSourceMaps(cx: Context, sources: Source[]) {
|
||||
// loading source maps as sometimes generated and original
|
||||
// files share the same paths.
|
||||
for (const source of sources) {
|
||||
dispatch(checkPendingBreakpoints(cx, source.id));
|
||||
dispatch(checkPendingBreakpoints(source.id));
|
||||
}
|
||||
|
||||
return flatten(sourceList);
|
||||
@ -88,7 +87,7 @@ function loadSourceMaps(cx: Context, sources: Source[]) {
|
||||
* @memberof actions/sources
|
||||
* @static
|
||||
*/
|
||||
function loadSourceMap(cx: Context, sourceId: SourceId) {
|
||||
function loadSourceMap(sourceId: SourceId) {
|
||||
return async function({
|
||||
dispatch,
|
||||
getState,
|
||||
@ -132,7 +131,6 @@ function loadSourceMap(cx: Context, sourceId: SourceId) {
|
||||
dispatch(
|
||||
({
|
||||
type: "UPDATE_SOURCE",
|
||||
cx,
|
||||
// NOTE: Flow https://github.com/facebook/flow/issues/6342 issue
|
||||
source: (({ ...currentSource, sourceMapURL: "" }: any): Source)
|
||||
}: Action)
|
||||
@ -146,7 +144,7 @@ function loadSourceMap(cx: Context, sourceId: SourceId) {
|
||||
|
||||
// If a request has been made to show this source, go ahead and
|
||||
// select it.
|
||||
function checkSelectedSource(cx: Context, sourceId: string) {
|
||||
function checkSelectedSource(sourceId: string) {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
const source = getSource(getState(), sourceId);
|
||||
const pendingLocation = getPendingSelectedLocation(getState());
|
||||
@ -160,12 +158,12 @@ function checkSelectedSource(cx: Context, sourceId: string) {
|
||||
|
||||
if (rawPendingUrl === source.url) {
|
||||
if (isPrettyURL(pendingUrl)) {
|
||||
const prettySource = await dispatch(togglePrettyPrint(cx, source.id));
|
||||
return dispatch(checkPendingBreakpoints(cx, prettySource.id));
|
||||
const prettySource = await dispatch(togglePrettyPrint(source.id));
|
||||
return dispatch(checkPendingBreakpoints(prettySource.id));
|
||||
}
|
||||
|
||||
await dispatch(
|
||||
selectLocation(cx, {
|
||||
selectLocation({
|
||||
sourceId: source.id,
|
||||
line:
|
||||
typeof pendingLocation.line === "number" ? pendingLocation.line : 0,
|
||||
@ -176,7 +174,7 @@ function checkSelectedSource(cx: Context, sourceId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
function checkPendingBreakpoints(cx: Context, sourceId: string) {
|
||||
function checkPendingBreakpoints(sourceId: string) {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
// source may have been modified by selectLocation
|
||||
const source = getSource(getState(), sourceId);
|
||||
@ -194,17 +192,17 @@ function checkPendingBreakpoints(cx: Context, sourceId: string) {
|
||||
}
|
||||
|
||||
// load the source text if there is a pending breakpoint for it
|
||||
await dispatch(loadSourceText(cx, source));
|
||||
await dispatch(loadSourceText(source));
|
||||
|
||||
await Promise.all(
|
||||
pendingBreakpoints.map(bp => {
|
||||
return dispatch(syncBreakpoint(cx, sourceId, bp));
|
||||
return dispatch(syncBreakpoint(sourceId, bp));
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function restoreBlackBoxedSources(cx: Context, sources: Source[]) {
|
||||
function restoreBlackBoxedSources(sources: Source[]) {
|
||||
return async ({ dispatch }: ThunkArgs) => {
|
||||
const tabs = getBlackBoxList();
|
||||
if (tabs.length == 0) {
|
||||
@ -212,7 +210,7 @@ function restoreBlackBoxedSources(cx: Context, sources: Source[]) {
|
||||
}
|
||||
for (const source of sources) {
|
||||
if (tabs.includes(source.url) && !source.isBlackBoxed) {
|
||||
dispatch(toggleBlackBox(cx, source));
|
||||
dispatch(toggleBlackBox(source));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -231,8 +229,6 @@ export function newSource(source: Source) {
|
||||
|
||||
export function newSources(sources: Source[]) {
|
||||
return async ({ dispatch, getState }: ThunkArgs) => {
|
||||
const cx = getContext(getState());
|
||||
|
||||
const _newSources = sources.filter(
|
||||
source => !getSource(getState(), source.id) || isInlineScript(source)
|
||||
);
|
||||
@ -241,10 +237,10 @@ export function newSources(sources: Source[]) {
|
||||
hasBreakpointPositions(getState(), source.id)
|
||||
);
|
||||
|
||||
dispatch({ type: "ADD_SOURCES", cx, sources });
|
||||
dispatch({ type: "ADD_SOURCES", sources });
|
||||
|
||||
for (const source of _newSources) {
|
||||
dispatch(checkSelectedSource(cx, source.id));
|
||||
dispatch(checkSelectedSource(source.id));
|
||||
}
|
||||
|
||||
// Adding new sources may have cleared this file's breakpoint positions
|
||||
@ -252,11 +248,11 @@ export function newSources(sources: Source[]) {
|
||||
// re-request new breakpoint positions.
|
||||
for (const source of sourcesNeedingPositions) {
|
||||
if (!hasBreakpointPositions(getState(), source.id)) {
|
||||
dispatch(setBreakpointPositions(cx, source.id));
|
||||
dispatch(setBreakpointPositions(source.id));
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(restoreBlackBoxedSources(cx, _newSources));
|
||||
dispatch(loadSourceMaps(cx, _newSources));
|
||||
dispatch(restoreBlackBoxedSources(_newSources));
|
||||
dispatch(loadSourceMaps(_newSources));
|
||||
};
|
||||
}
|
||||
|
@ -18,14 +18,14 @@ import { selectSpecificLocation } from "../sources";
|
||||
import {
|
||||
getSource,
|
||||
getSourceFromId,
|
||||
getSourceThreads,
|
||||
getSourceByURL,
|
||||
getSelectedLocation,
|
||||
getThreadContext
|
||||
getSelectedLocation
|
||||
} from "../../selectors";
|
||||
|
||||
import type { Action, ThunkArgs } from "../types";
|
||||
import { selectSource } from "./select";
|
||||
import type { JsSource, Source, Context } from "../../types";
|
||||
import type { JsSource, Source } from "../../types";
|
||||
|
||||
export async function prettyPrintSource(
|
||||
sourceMaps: any,
|
||||
@ -51,7 +51,7 @@ export async function prettyPrintSource(
|
||||
};
|
||||
}
|
||||
|
||||
export function createPrettySource(cx: Context, sourceId: string) {
|
||||
export function createPrettySource(sourceId: string) {
|
||||
return async ({ dispatch, getState, sourceMaps }: ThunkArgs) => {
|
||||
const source = getSourceFromId(getState(), sourceId);
|
||||
const url = getPrettySourceURL(source.url);
|
||||
@ -72,8 +72,8 @@ export function createPrettySource(cx: Context, sourceId: string) {
|
||||
actors: []
|
||||
};
|
||||
|
||||
dispatch(({ type: "ADD_SOURCE", cx, source: prettySource }: Action));
|
||||
await dispatch(selectSource(cx, prettySource.id));
|
||||
dispatch(({ type: "ADD_SOURCE", source: prettySource }: Action));
|
||||
await dispatch(selectSource(prettySource.id));
|
||||
|
||||
return prettySource;
|
||||
};
|
||||
@ -91,7 +91,7 @@ export function createPrettySource(cx: Context, sourceId: string) {
|
||||
* A promise that resolves to [aSource, prettyText] or rejects to
|
||||
* [aSource, error].
|
||||
*/
|
||||
export function togglePrettyPrint(cx: Context, sourceId: string) {
|
||||
export function togglePrettyPrint(sourceId: string) {
|
||||
return async ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
|
||||
const source = getSource(getState(), sourceId);
|
||||
if (!source) {
|
||||
@ -103,7 +103,7 @@ export function togglePrettyPrint(cx: Context, sourceId: string) {
|
||||
}
|
||||
|
||||
if (!isLoaded(source)) {
|
||||
await dispatch(loadSourceText(cx, source));
|
||||
await dispatch(loadSourceText(source));
|
||||
}
|
||||
|
||||
assert(
|
||||
@ -123,21 +123,21 @@ export function togglePrettyPrint(cx: Context, sourceId: string) {
|
||||
if (prettySource) {
|
||||
const _sourceId = prettySource.id;
|
||||
return dispatch(
|
||||
selectSpecificLocation(cx, { ...options.location, sourceId: _sourceId })
|
||||
selectSpecificLocation({ ...options.location, sourceId: _sourceId })
|
||||
);
|
||||
}
|
||||
|
||||
const newPrettySource = await dispatch(createPrettySource(cx, sourceId));
|
||||
const newPrettySource = await dispatch(createPrettySource(sourceId));
|
||||
|
||||
await dispatch(remapBreakpoints(cx, sourceId));
|
||||
await dispatch(remapBreakpoints(sourceId));
|
||||
|
||||
const threadcx = getThreadContext(getState());
|
||||
await dispatch(mapFrames(threadcx));
|
||||
const threads = getSourceThreads(getState(), source);
|
||||
await Promise.all(threads.map(thread => dispatch(mapFrames(thread))));
|
||||
|
||||
await dispatch(setSymbols(cx, newPrettySource.id));
|
||||
await dispatch(setSymbols(newPrettySource.id));
|
||||
|
||||
dispatch(
|
||||
selectSpecificLocation(cx, {
|
||||
selectSpecificLocation({
|
||||
...options.location,
|
||||
sourceId: newPrettySource.id
|
||||
})
|
||||
|
@ -35,39 +35,26 @@ import {
|
||||
getSelectedSource
|
||||
} from "../../selectors";
|
||||
|
||||
import type {
|
||||
SourceLocation,
|
||||
PartialPosition,
|
||||
Source,
|
||||
Context
|
||||
} from "../../types";
|
||||
import type { SourceLocation, PartialPosition, Source } from "../../types";
|
||||
import type { ThunkArgs } from "../types";
|
||||
|
||||
export const setSelectedLocation = (
|
||||
cx: Context,
|
||||
source: Source,
|
||||
location: SourceLocation
|
||||
) => ({
|
||||
type: "SET_SELECTED_LOCATION",
|
||||
cx,
|
||||
source,
|
||||
location
|
||||
});
|
||||
|
||||
export const setPendingSelectedLocation = (
|
||||
cx: Context,
|
||||
url: string,
|
||||
options: Object
|
||||
) => ({
|
||||
export const setPendingSelectedLocation = (url: string, options: Object) => ({
|
||||
type: "SET_PENDING_SELECTED_LOCATION",
|
||||
cx,
|
||||
url: url,
|
||||
line: options.location ? options.location.line : null
|
||||
});
|
||||
|
||||
export const clearSelectedLocation = (cx: Context) => ({
|
||||
type: "CLEAR_SELECTED_LOCATION",
|
||||
cx
|
||||
export const clearSelectedLocation = () => ({
|
||||
type: "CLEAR_SELECTED_LOCATION"
|
||||
});
|
||||
|
||||
/**
|
||||
@ -82,19 +69,18 @@ export const clearSelectedLocation = (cx: Context) => ({
|
||||
* @static
|
||||
*/
|
||||
export function selectSourceURL(
|
||||
cx: Context,
|
||||
url: string,
|
||||
options: PartialPosition = { line: 1 }
|
||||
) {
|
||||
return async ({ dispatch, getState, sourceMaps }: ThunkArgs) => {
|
||||
const source = getSourceByURL(getState(), url);
|
||||
if (!source) {
|
||||
return dispatch(setPendingSelectedLocation(cx, url, options));
|
||||
return dispatch(setPendingSelectedLocation(url, options));
|
||||
}
|
||||
|
||||
const sourceId = source.id;
|
||||
const location = createLocation({ ...options, sourceId });
|
||||
return dispatch(selectLocation(cx, location));
|
||||
return dispatch(selectLocation(location));
|
||||
};
|
||||
}
|
||||
|
||||
@ -103,13 +89,12 @@ export function selectSourceURL(
|
||||
* @static
|
||||
*/
|
||||
export function selectSource(
|
||||
cx: Context,
|
||||
sourceId: string,
|
||||
options: PartialPosition = { line: 1 }
|
||||
) {
|
||||
return async ({ dispatch }: ThunkArgs) => {
|
||||
const location = createLocation({ ...options, sourceId });
|
||||
return dispatch(selectSpecificLocation(cx, location));
|
||||
return dispatch(selectSpecificLocation(location));
|
||||
};
|
||||
}
|
||||
|
||||
@ -118,7 +103,6 @@ export function selectSource(
|
||||
* @static
|
||||
*/
|
||||
export function selectLocation(
|
||||
cx: Context,
|
||||
location: SourceLocation,
|
||||
{ keepContext = true }: Object = {}
|
||||
) {
|
||||
@ -134,7 +118,7 @@ export function selectLocation(
|
||||
let source = getSource(getState(), location.sourceId);
|
||||
if (!source) {
|
||||
// If there is no source we deselect the current selected source
|
||||
return dispatch(clearSelectedLocation(cx));
|
||||
return dispatch(clearSelectedLocation());
|
||||
}
|
||||
|
||||
const activeSearch = getActiveSearch(getState());
|
||||
@ -159,9 +143,9 @@ export function selectLocation(
|
||||
dispatch(addTab(source));
|
||||
}
|
||||
|
||||
dispatch(setSelectedLocation(cx, source, location));
|
||||
dispatch(setSelectedLocation(source, location));
|
||||
|
||||
await dispatch(loadSourceText(cx, source));
|
||||
await dispatch(loadSourceText(source));
|
||||
const loadedSource = getSource(getState(), source.id);
|
||||
|
||||
if (!loadedSource) {
|
||||
@ -176,17 +160,17 @@ export function selectLocation(
|
||||
shouldPrettyPrint(loadedSource) &&
|
||||
isMinified(loadedSource)
|
||||
) {
|
||||
await dispatch(togglePrettyPrint(cx, loadedSource.id));
|
||||
dispatch(closeTab(cx, loadedSource));
|
||||
await dispatch(togglePrettyPrint(loadedSource.id));
|
||||
dispatch(closeTab(loadedSource));
|
||||
}
|
||||
|
||||
dispatch(setSymbols(cx, loadedSource.id));
|
||||
dispatch(setOutOfScopeLocations(cx));
|
||||
dispatch(setSymbols(loadedSource.id));
|
||||
dispatch(setOutOfScopeLocations());
|
||||
|
||||
// If a new source is selected update the file search results
|
||||
const newSource = getSelectedSource(getState());
|
||||
if (currentSource && currentSource !== newSource) {
|
||||
dispatch(updateActiveFileSearch(cx));
|
||||
dispatch(updateActiveFileSearch());
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -195,15 +179,15 @@ export function selectLocation(
|
||||
* @memberof actions/sources
|
||||
* @static
|
||||
*/
|
||||
export function selectSpecificLocation(cx: Context, location: SourceLocation) {
|
||||
return selectLocation(cx, location, { keepContext: false });
|
||||
export function selectSpecificLocation(location: SourceLocation) {
|
||||
return selectLocation(location, { keepContext: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof actions/sources
|
||||
* @static
|
||||
*/
|
||||
export function jumpToMappedLocation(cx: Context, location: SourceLocation) {
|
||||
export function jumpToMappedLocation(location: SourceLocation) {
|
||||
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
|
||||
if (!client) {
|
||||
return;
|
||||
@ -211,17 +195,17 @@ export function jumpToMappedLocation(cx: Context, location: SourceLocation) {
|
||||
|
||||
const pairedLocation = await mapLocation(getState(), sourceMaps, location);
|
||||
|
||||
return dispatch(selectSpecificLocation(cx, { ...pairedLocation }));
|
||||
return dispatch(selectSpecificLocation({ ...pairedLocation }));
|
||||
};
|
||||
}
|
||||
|
||||
export function jumpToMappedSelectedLocation(cx: Context) {
|
||||
export function jumpToMappedSelectedLocation() {
|
||||
return async function({ dispatch, getState }: ThunkArgs) {
|
||||
const location = getSelectedLocation(getState());
|
||||
if (!location) {
|
||||
return;
|
||||
}
|
||||
|
||||
await dispatch(jumpToMappedLocation(cx, location));
|
||||
await dispatch(jumpToMappedLocation(location));
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* 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 { getSourceFromId, getSymbols, getThreadContext } from "../../selectors";
|
||||
import { getSourceFromId, getSourceThreads, getSymbols } from "../../selectors";
|
||||
|
||||
import { PROMISE } from "../utils/middleware/promise";
|
||||
import { mapFrames } from "../pause";
|
||||
@ -14,7 +14,7 @@ import { isLoaded } from "../../utils/source";
|
||||
import type { SourceId } from "../../types";
|
||||
import type { ThunkArgs } from "../types";
|
||||
|
||||
export function setSymbols(cx: Context, sourceId: SourceId) {
|
||||
export function setSymbols(sourceId: SourceId) {
|
||||
return async ({ dispatch, getState, sourceMaps }: ThunkArgs) => {
|
||||
const source = getSourceFromId(getState(), sourceId);
|
||||
|
||||
@ -24,13 +24,12 @@ export function setSymbols(cx: Context, sourceId: SourceId) {
|
||||
|
||||
await dispatch({
|
||||
type: "SET_SYMBOLS",
|
||||
cx,
|
||||
sourceId,
|
||||
[PROMISE]: parser.getSymbols(sourceId)
|
||||
});
|
||||
|
||||
const threadcx = getThreadContext(getState());
|
||||
await dispatch(mapFrames(threadcx));
|
||||
const threads = getSourceThreads(getState(), source);
|
||||
await Promise.all(threads.map(thread => dispatch(mapFrames(thread))));
|
||||
|
||||
const symbols = getSymbols(getState(), source);
|
||||
if (symbols.framework) {
|
||||
|
@ -14,11 +14,11 @@ import {
|
||||
describe("blackbox", () => {
|
||||
it("should blackbox a source", async () => {
|
||||
const store = createStore({ blackBox: async () => true });
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
|
||||
const foo1Source = makeSource("foo1");
|
||||
await dispatch(actions.newSource(foo1Source));
|
||||
await dispatch(actions.toggleBlackBox(cx, foo1Source));
|
||||
await dispatch(actions.toggleBlackBox(foo1Source));
|
||||
|
||||
const fooSource = selectors.getSource(getState(), "foo1");
|
||||
|
||||
|
@ -21,11 +21,11 @@ import { getBreakpointsList } from "../../../selectors";
|
||||
describe("loadSourceText", () => {
|
||||
it("should load source text", async () => {
|
||||
const store = createStore(sourceThreadClient);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
|
||||
const foo1Source = makeSource("foo1");
|
||||
await dispatch(actions.newSource(foo1Source));
|
||||
await dispatch(actions.loadSourceText(cx, foo1Source));
|
||||
await dispatch(actions.loadSourceText(foo1Source));
|
||||
const fooSource = selectors.getSource(getState(), "foo1");
|
||||
|
||||
if (!fooSource || typeof fooSource.text != "string") {
|
||||
@ -35,7 +35,7 @@ describe("loadSourceText", () => {
|
||||
|
||||
const baseFoo2Source = makeSource("foo2");
|
||||
await dispatch(actions.newSource(baseFoo2Source));
|
||||
await dispatch(actions.loadSourceText(cx, baseFoo2Source));
|
||||
await dispatch(actions.loadSourceText(baseFoo2Source));
|
||||
const foo2Source = selectors.getSource(getState(), "foo2");
|
||||
|
||||
if (!foo2Source || typeof foo2Source.text != "string") {
|
||||
@ -73,7 +73,7 @@ describe("loadSourceText", () => {
|
||||
})
|
||||
}
|
||||
);
|
||||
const { cx, dispatch, getState } = store;
|
||||
const { dispatch, getState } = store;
|
||||
|
||||
await dispatch(actions.newSource(fooOrigSource));
|
||||
await dispatch(actions.newSource(fooGenSource));
|
||||
@ -83,7 +83,7 @@ describe("loadSourceText", () => {
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
await dispatch(actions.addBreakpoint(cx, location, {}));
|
||||
await dispatch(actions.addBreakpoint(location, {}));
|
||||
const breakpoint = selectors.getBreakpoint(getState(), location);
|
||||
if (!breakpoint) {
|
||||
throw new Error("no breakpoint");
|
||||
@ -92,13 +92,13 @@ describe("loadSourceText", () => {
|
||||
expect(breakpoint.text).toBe("var fooGen = 42;");
|
||||
expect(breakpoint.originalText).toBe("var fooOrig = 42;");
|
||||
|
||||
await dispatch(actions.loadSourceText(cx, fooOrigSource));
|
||||
await dispatch(actions.loadSourceText(fooOrigSource));
|
||||
|
||||
const breakpoint1 = getBreakpointsList(getState())[0];
|
||||
expect(breakpoint1.text).toBe("var fooGen = 42;");
|
||||
expect(breakpoint1.originalText).toBe("var fooOrig = 42;");
|
||||
|
||||
await dispatch(actions.loadSourceText(cx, fooGenSource));
|
||||
await dispatch(actions.loadSourceText(fooGenSource));
|
||||
|
||||
const breakpoint2 = getBreakpointsList(getState())[0];
|
||||
expect(breakpoint2.text).toBe("var fooGen = 42;");
|
||||
@ -108,7 +108,7 @@ describe("loadSourceText", () => {
|
||||
it("loads two sources w/ one request", async () => {
|
||||
let resolve;
|
||||
let count = 0;
|
||||
const { dispatch, getState, cx } = createStore({
|
||||
const { dispatch, getState } = createStore({
|
||||
sourceContents: () =>
|
||||
new Promise(r => {
|
||||
count++;
|
||||
@ -122,10 +122,10 @@ describe("loadSourceText", () => {
|
||||
await dispatch(actions.newSource(baseSource));
|
||||
|
||||
let source = selectors.getSource(getState(), id);
|
||||
dispatch(actions.loadSourceText(cx, source));
|
||||
dispatch(actions.loadSourceText(source));
|
||||
|
||||
source = selectors.getSource(getState(), id);
|
||||
const loading = dispatch(actions.loadSourceText(cx, source));
|
||||
const loading = dispatch(actions.loadSourceText(source));
|
||||
|
||||
if (!resolve) {
|
||||
throw new Error("no resolve");
|
||||
@ -141,7 +141,7 @@ describe("loadSourceText", () => {
|
||||
it("doesn't re-load loaded sources", async () => {
|
||||
let resolve;
|
||||
let count = 0;
|
||||
const { dispatch, getState, cx } = createStore({
|
||||
const { dispatch, getState } = createStore({
|
||||
sourceContents: () =>
|
||||
new Promise(r => {
|
||||
count++;
|
||||
@ -154,7 +154,7 @@ describe("loadSourceText", () => {
|
||||
|
||||
await dispatch(actions.newSource(baseSource));
|
||||
let source = selectors.getSource(getState(), id);
|
||||
const loading = dispatch(actions.loadSourceText(cx, source));
|
||||
const loading = dispatch(actions.loadSourceText(source));
|
||||
|
||||
if (!resolve) {
|
||||
throw new Error("no resolve");
|
||||
@ -163,7 +163,7 @@ describe("loadSourceText", () => {
|
||||
await loading;
|
||||
|
||||
source = selectors.getSource(getState(), id);
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
expect(count).toEqual(1);
|
||||
|
||||
source = selectors.getSource(getState(), id);
|
||||
@ -171,13 +171,13 @@ describe("loadSourceText", () => {
|
||||
});
|
||||
|
||||
it("should cache subsequent source text loads", async () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
|
||||
const source = makeSource("foo1");
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
const prevSource = selectors.getSource(getState(), "foo1");
|
||||
|
||||
await dispatch(actions.loadSourceText(cx, prevSource));
|
||||
await dispatch(actions.loadSourceText(prevSource));
|
||||
const curSource = selectors.getSource(getState(), "foo1");
|
||||
|
||||
expect(prevSource === curSource).toBeTruthy();
|
||||
@ -185,7 +185,7 @@ describe("loadSourceText", () => {
|
||||
|
||||
it("should indicate a loading source", async () => {
|
||||
const store = createStore(sourceThreadClient);
|
||||
const { dispatch, cx } = store;
|
||||
const { dispatch } = store;
|
||||
|
||||
const source = makeSource("foo2");
|
||||
await dispatch(actions.newSource(source));
|
||||
@ -195,17 +195,17 @@ describe("loadSourceText", () => {
|
||||
return fooSource && fooSource.loadedState === "loading";
|
||||
});
|
||||
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
expect(wasLoading()).toBe(true);
|
||||
});
|
||||
|
||||
it("should indicate an errored source text", async () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
|
||||
const source = makeSource("bad-id");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
const badSource = selectors.getSource(getState(), "bad-id");
|
||||
|
||||
if (!badSource || !badSource.error) {
|
||||
|
@ -45,9 +45,9 @@ describe("sources - new sources", () => {
|
||||
});
|
||||
|
||||
it("should automatically select a pending source", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
const baseSource = makeSource("base.js");
|
||||
await dispatch(actions.selectSourceURL(cx, baseSource.url));
|
||||
await dispatch(actions.selectSourceURL(baseSource.url));
|
||||
|
||||
expect(getSelectedSource(getState())).toBe(undefined);
|
||||
await dispatch(actions.newSource(baseSource));
|
||||
|
@ -14,13 +14,13 @@ import { createPrettySource } from "../prettyPrint";
|
||||
import { sourceThreadClient } from "../../tests/helpers/threadClient.js";
|
||||
|
||||
describe("sources - pretty print", () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
|
||||
it("returns a pretty source for a minified file", async () => {
|
||||
const url = "base.js";
|
||||
const source = makeSource(url);
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(createPrettySource(cx, source.id));
|
||||
await dispatch(createPrettySource(source.id));
|
||||
|
||||
const prettyURL = `${source.url}:formatted`;
|
||||
const pretty = selectors.getSourceByURL(getState(), prettyURL);
|
||||
@ -31,15 +31,15 @@ describe("sources - pretty print", () => {
|
||||
|
||||
it("should create a source when first toggling pretty print", async () => {
|
||||
const source = makeSource("foobar.js", { loadedState: "loaded" });
|
||||
await dispatch(actions.togglePrettyPrint(cx, source.id));
|
||||
await dispatch(actions.togglePrettyPrint(source.id));
|
||||
expect(selectors.getSourceCount(getState())).toEqual(2);
|
||||
});
|
||||
|
||||
it("should not make a second source when toggling pretty print", async () => {
|
||||
const source = makeSource("foobar.js", { loadedState: "loaded" });
|
||||
await dispatch(actions.togglePrettyPrint(cx, source.id));
|
||||
await dispatch(actions.togglePrettyPrint(source.id));
|
||||
expect(selectors.getSourceCount(getState())).toEqual(2);
|
||||
await dispatch(actions.togglePrettyPrint(cx, source.id));
|
||||
await dispatch(actions.togglePrettyPrint(source.id));
|
||||
expect(selectors.getSourceCount(getState())).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
@ -50,9 +50,8 @@ describe("sources", () => {
|
||||
})
|
||||
);
|
||||
|
||||
const cx = selectors.getThreadContext(getState());
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: "foo1", line: 1, column: 5 })
|
||||
actions.selectLocation({ sourceId: "foo1", line: 1, column: 5 })
|
||||
);
|
||||
|
||||
const selectedSource = getSelectedSource(getState());
|
||||
@ -73,7 +72,7 @@ describe("sources", () => {
|
||||
});
|
||||
|
||||
it("should select next tab on tab closed if no previous tab", async () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
|
||||
const fooSource = makeSource("foo.js");
|
||||
|
||||
@ -82,19 +81,19 @@ describe("sources", () => {
|
||||
await dispatch(actions.newSource(makeSource("baz.js")));
|
||||
|
||||
// 3rd tab
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("foo.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("foo.js")));
|
||||
|
||||
// 2nd tab
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("bar.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("bar.js")));
|
||||
|
||||
// 1st tab
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("baz.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("baz.js")));
|
||||
|
||||
// 3rd tab is reselected
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("foo.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("foo.js")));
|
||||
|
||||
// closes the 1st tab, which should have no previous tab
|
||||
await dispatch(actions.closeTab(cx, fooSource));
|
||||
await dispatch(actions.closeTab(fooSource));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
expect(selected && selected.id).toBe("bar.js");
|
||||
@ -102,9 +101,9 @@ describe("sources", () => {
|
||||
});
|
||||
|
||||
it("should open a tab for the source", async () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
dispatch(actions.selectLocation(cx, initialLocation("foo.js")));
|
||||
dispatch(actions.selectLocation(initialLocation("foo.js")));
|
||||
|
||||
const tabs = getSourceTabs(getState());
|
||||
expect(tabs).toHaveLength(1);
|
||||
@ -112,17 +111,17 @@ describe("sources", () => {
|
||||
});
|
||||
|
||||
it("should select previous tab on tab closed", async () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
await dispatch(actions.newSource(makeSource("bar.js")));
|
||||
|
||||
const bazSource = makeSource("baz.js");
|
||||
await dispatch(actions.newSource(bazSource));
|
||||
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("foo.js")));
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("bar.js")));
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("baz.js")));
|
||||
await dispatch(actions.closeTab(cx, bazSource));
|
||||
await dispatch(actions.selectLocation(initialLocation("foo.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("bar.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("baz.js")));
|
||||
await dispatch(actions.closeTab(bazSource));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
expect(selected && selected.id).toBe("bar.js");
|
||||
@ -130,7 +129,7 @@ describe("sources", () => {
|
||||
});
|
||||
|
||||
it("should keep the selected source when other tab closed", async () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
|
||||
const bazSource = makeSource("baz.js");
|
||||
|
||||
@ -139,17 +138,17 @@ describe("sources", () => {
|
||||
await dispatch(actions.newSource(bazSource));
|
||||
|
||||
// 3rd tab
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("foo.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("foo.js")));
|
||||
|
||||
// 2nd tab
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("bar.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("bar.js")));
|
||||
|
||||
// 1st tab
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("baz.js")));
|
||||
await dispatch(actions.selectLocation(initialLocation("baz.js")));
|
||||
|
||||
// 3rd tab is reselected
|
||||
await dispatch(actions.selectLocation(cx, initialLocation("foo.js")));
|
||||
await dispatch(actions.closeTab(cx, bazSource));
|
||||
await dispatch(actions.selectLocation(initialLocation("foo.js")));
|
||||
await dispatch(actions.closeTab(bazSource));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
expect(selected && selected.id).toBe("foo.js");
|
||||
@ -169,29 +168,29 @@ describe("sources", () => {
|
||||
});
|
||||
|
||||
it("sets and clears selected location correctly", () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
const source = makeSource("testSource");
|
||||
const location = ({ test: "testLocation" }: any);
|
||||
|
||||
// set value
|
||||
dispatch(actions.setSelectedLocation(cx, source, location));
|
||||
dispatch(actions.setSelectedLocation(source, location));
|
||||
expect(getSelectedLocation(getState())).toEqual({
|
||||
sourceId: source.id,
|
||||
...location
|
||||
});
|
||||
|
||||
// clear value
|
||||
dispatch(actions.clearSelectedLocation(cx));
|
||||
dispatch(actions.clearSelectedLocation());
|
||||
expect(getSelectedLocation(getState())).toEqual(null);
|
||||
});
|
||||
|
||||
it("sets and clears pending selected location correctly", () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
const url = "testURL";
|
||||
const options = { location: { line: "testLine" } };
|
||||
|
||||
// set value
|
||||
dispatch(actions.setPendingSelectedLocation(cx, url, options));
|
||||
dispatch(actions.setPendingSelectedLocation(url, options));
|
||||
const setResult = getState().sources.pendingSelectedLocation;
|
||||
expect(setResult).toEqual({
|
||||
url,
|
||||
@ -199,19 +198,19 @@ describe("sources", () => {
|
||||
});
|
||||
|
||||
// clear value
|
||||
dispatch(actions.clearSelectedLocation(cx));
|
||||
dispatch(actions.clearSelectedLocation());
|
||||
const clearResult = getState().sources.pendingSelectedLocation;
|
||||
expect(clearResult).toEqual({ url: "" });
|
||||
});
|
||||
|
||||
it("should keep the generated the viewing context", async () => {
|
||||
const store = createStore(sourceThreadClient);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const baseSource = makeSource("base.js");
|
||||
await dispatch(actions.newSource(baseSource));
|
||||
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: baseSource.id, line: 1 })
|
||||
actions.selectLocation({ sourceId: baseSource.id, line: 1 })
|
||||
);
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
@ -220,7 +219,7 @@ describe("sources", () => {
|
||||
});
|
||||
|
||||
it("should keep the original the viewing context", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
sourceThreadClient,
|
||||
{},
|
||||
{
|
||||
@ -238,20 +237,18 @@ describe("sources", () => {
|
||||
const originalBaseSource = makeOriginalSource("base.js");
|
||||
await dispatch(actions.newSource(originalBaseSource));
|
||||
|
||||
await dispatch(actions.selectSource(cx, originalBaseSource.id));
|
||||
await dispatch(actions.selectSource(originalBaseSource.id));
|
||||
|
||||
const fooSource = makeSource("foo.js");
|
||||
await dispatch(actions.newSource(fooSource));
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: fooSource.id, line: 1 })
|
||||
);
|
||||
await dispatch(actions.selectLocation({ sourceId: fooSource.id, line: 1 }));
|
||||
|
||||
const selected = getSelectedLocation(getState());
|
||||
expect(selected && selected.line).toBe(12);
|
||||
});
|
||||
|
||||
it("should change the original the viewing context", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
sourceThreadClient,
|
||||
{},
|
||||
{
|
||||
@ -266,10 +263,10 @@ describe("sources", () => {
|
||||
const baseSource = makeOriginalSource("base.js");
|
||||
|
||||
await dispatch(actions.newSource(baseSource));
|
||||
await dispatch(actions.selectSource(cx, baseSource.id));
|
||||
await dispatch(actions.selectSource(baseSource.id));
|
||||
|
||||
await dispatch(
|
||||
actions.selectSpecificLocation(cx, {
|
||||
actions.selectSpecificLocation({
|
||||
sourceId: baseSource.id,
|
||||
line: 1
|
||||
})
|
||||
@ -281,9 +278,9 @@ describe("sources", () => {
|
||||
|
||||
describe("selectSourceURL", () => {
|
||||
it("should automatically select a pending source", async () => {
|
||||
const { dispatch, getState, cx } = createStore(sourceThreadClient);
|
||||
const { dispatch, getState } = createStore(sourceThreadClient);
|
||||
const baseSource = makeSource("base.js");
|
||||
await dispatch(actions.selectSourceURL(cx, baseSource.url));
|
||||
await dispatch(actions.selectSourceURL(baseSource.url));
|
||||
|
||||
expect(getSelectedSource(getState())).toBe(undefined);
|
||||
await dispatch(actions.newSource(baseSource));
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
} from "../selectors";
|
||||
|
||||
import type { Action, ThunkArgs } from "./types";
|
||||
import type { Source, Context } from "../types";
|
||||
import type { Source } from "../types";
|
||||
|
||||
export function updateTab(source: Source, framework: string): Action {
|
||||
const { url, id: sourceId } = source;
|
||||
@ -62,7 +62,7 @@ export function moveTab(url: string, tabIndex: number): Action {
|
||||
* @memberof actions/tabs
|
||||
* @static
|
||||
*/
|
||||
export function closeTab(cx: Context, source: Source) {
|
||||
export function closeTab(source: Source) {
|
||||
return ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const { id, url } = source;
|
||||
|
||||
@ -71,7 +71,7 @@ export function closeTab(cx: Context, source: Source) {
|
||||
const tabs = removeSourceFromTabList(getSourceTabs(getState()), source);
|
||||
const sourceId = getNewSelectedSourceId(getState(), tabs);
|
||||
dispatch(({ type: "CLOSE_TAB", url, tabs }: Action));
|
||||
dispatch(selectSource(cx, sourceId));
|
||||
dispatch(selectSource(sourceId));
|
||||
};
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ export function closeTab(cx: Context, source: Source) {
|
||||
* @memberof actions/tabs
|
||||
* @static
|
||||
*/
|
||||
export function closeTabs(cx: Context, urls: string[]) {
|
||||
export function closeTabs(urls: string[]) {
|
||||
return ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const sources = urls
|
||||
.map(url => getSourceByURL(getState(), url))
|
||||
@ -90,6 +90,6 @@ export function closeTabs(cx: Context, urls: string[]) {
|
||||
dispatch(({ type: "CLOSE_TABS", sources, tabs }: Action));
|
||||
|
||||
const sourceId = getNewSelectedSourceId(getState(), tabs);
|
||||
dispatch(selectSource(cx, sourceId));
|
||||
dispatch(selectSource(sourceId));
|
||||
};
|
||||
}
|
||||
|
@ -67,11 +67,11 @@ describe("ast", () => {
|
||||
describe("when the source is loaded", () => {
|
||||
it("should be able to set symbols", async () => {
|
||||
const store = createStore(threadClient);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const base = makeSource("base.js");
|
||||
await dispatch(actions.newSource(base));
|
||||
await dispatch(actions.loadSourceText(cx, base));
|
||||
await dispatch(actions.setSymbols(cx, "base.js"));
|
||||
await dispatch(actions.loadSourceText(base));
|
||||
await dispatch(actions.setSymbols("base.js"));
|
||||
await waitForState(store, state => !isSymbolsLoading(state, base));
|
||||
|
||||
const baseSymbols = getSymbols(getState(), base);
|
||||
@ -101,7 +101,7 @@ describe("ast", () => {
|
||||
describe("frameworks", () => {
|
||||
it("should detect react components", async () => {
|
||||
const store = createStore(threadClient, {}, sourceMaps);
|
||||
const { cx, dispatch, getState } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const source = makeOriginalSource("reactComponent.js");
|
||||
|
||||
await dispatch(actions.newSource(makeSource("reactComponent.js")));
|
||||
@ -109,20 +109,20 @@ describe("ast", () => {
|
||||
await dispatch(actions.newSource(source));
|
||||
|
||||
await dispatch(
|
||||
actions.loadSourceText(cx, getSource(getState(), source.id))
|
||||
actions.loadSourceText(getSource(getState(), source.id))
|
||||
);
|
||||
await dispatch(actions.setSymbols(cx, source.id));
|
||||
await dispatch(actions.setSymbols(source.id));
|
||||
|
||||
expect(getFramework(getState(), source)).toBe("React");
|
||||
});
|
||||
|
||||
it("should not give false positive on non react components", async () => {
|
||||
const store = createStore(threadClient);
|
||||
const { cx, dispatch, getState } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const base = makeSource("base.js");
|
||||
await dispatch(actions.newSource(base));
|
||||
await dispatch(actions.loadSourceText(cx, base));
|
||||
await dispatch(actions.setSymbols(cx, "base.js"));
|
||||
await dispatch(actions.loadSourceText(base));
|
||||
await dispatch(actions.setSymbols("base.js"));
|
||||
|
||||
expect(getFramework(getState(), base)).toBe(undefined);
|
||||
});
|
||||
@ -136,20 +136,14 @@ describe("ast", () => {
|
||||
|
||||
it("with selected line", async () => {
|
||||
const store = createStore(threadClient);
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
const source = makeSource("scopes.js");
|
||||
await dispatch(actions.newSource(source));
|
||||
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: "scopes.js", line: 5 })
|
||||
actions.selectLocation({ sourceId: "scopes.js", line: 5 })
|
||||
);
|
||||
|
||||
// Make sure the state has finished updating before pausing.
|
||||
await waitForState(store, state => {
|
||||
const symbols = getSymbols(state, source);
|
||||
return symbols && !symbols.loading && getOutOfScopeLocations(state);
|
||||
});
|
||||
|
||||
const frame = makeFrame({ id: "1", sourceId: "scopes.js" });
|
||||
await dispatch(
|
||||
actions.paused({
|
||||
@ -160,8 +154,7 @@ describe("ast", () => {
|
||||
})
|
||||
);
|
||||
|
||||
const ncx = selectors.getThreadContext(getState());
|
||||
await dispatch(actions.setOutOfScopeLocations(ncx));
|
||||
await dispatch(actions.setOutOfScopeLocations());
|
||||
|
||||
await waitForState(store, state => getOutOfScopeLocations(state));
|
||||
|
||||
@ -173,10 +166,10 @@ describe("ast", () => {
|
||||
});
|
||||
|
||||
it("without a selected line", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
const base = makeSource("base.js");
|
||||
await dispatch(actions.newSource(base));
|
||||
await dispatch(actions.selectSource(cx, "base.js"));
|
||||
await dispatch(actions.selectSource("base.js"));
|
||||
|
||||
const locations = getOutOfScopeLocations(getState());
|
||||
// const lines = getInScopeLines(getState());
|
||||
|
@ -50,53 +50,53 @@ const mockThreadClient = {
|
||||
|
||||
describe("expressions", () => {
|
||||
it("should add an expression", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockThreadClient);
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
|
||||
await dispatch(actions.addExpression(cx, "foo"));
|
||||
await dispatch(actions.addExpression("foo"));
|
||||
expect(selectors.getExpressions(getState()).size).toBe(1);
|
||||
});
|
||||
|
||||
it("should not add empty expressions", () => {
|
||||
const { dispatch, getState, cx } = createStore(mockThreadClient);
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
|
||||
dispatch(actions.addExpression(cx, (undefined: any)));
|
||||
dispatch(actions.addExpression(cx, ""));
|
||||
dispatch(actions.addExpression((undefined: any)));
|
||||
dispatch(actions.addExpression(""));
|
||||
|
||||
expect(selectors.getExpressions(getState()).size).toBe(0);
|
||||
});
|
||||
|
||||
it("should not add invalid expressions", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockThreadClient);
|
||||
await dispatch(actions.addExpression(cx, "foo#"));
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
await dispatch(actions.addExpression("foo#"));
|
||||
const state = getState();
|
||||
expect(selectors.getExpressions(state).size).toBe(0);
|
||||
expect(selectors.getExpressionError(state)).toBe(true);
|
||||
});
|
||||
|
||||
it("should update an expression", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockThreadClient);
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
|
||||
await dispatch(actions.addExpression(cx, "foo"));
|
||||
await dispatch(actions.addExpression("foo"));
|
||||
const expression = selectors.getExpression(getState(), "foo");
|
||||
await dispatch(actions.updateExpression(cx, "bar", expression));
|
||||
await dispatch(actions.updateExpression("bar", expression));
|
||||
|
||||
expect(selectors.getExpression(getState(), "bar").input).toBe("bar");
|
||||
});
|
||||
|
||||
it("should not update an expression w/ invalid code", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockThreadClient);
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
|
||||
await dispatch(actions.addExpression(cx, "foo"));
|
||||
await dispatch(actions.addExpression("foo"));
|
||||
const expression = selectors.getExpression(getState(), "foo");
|
||||
await dispatch(actions.updateExpression(cx, "#bar", expression));
|
||||
await dispatch(actions.updateExpression("#bar", expression));
|
||||
expect(selectors.getExpression(getState(), "bar")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should delete an expression", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockThreadClient);
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
|
||||
await dispatch(actions.addExpression(cx, "foo"));
|
||||
await dispatch(actions.addExpression(cx, "bar"));
|
||||
await dispatch(actions.addExpression("foo"));
|
||||
await dispatch(actions.addExpression("bar"));
|
||||
|
||||
expect(selectors.getExpressions(getState()).size).toBe(2);
|
||||
|
||||
@ -108,15 +108,15 @@ describe("expressions", () => {
|
||||
});
|
||||
|
||||
it("should evaluate expressions global scope", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockThreadClient);
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
|
||||
await dispatch(actions.addExpression(cx, "foo"));
|
||||
await dispatch(actions.addExpression(cx, "bar"));
|
||||
await dispatch(actions.addExpression("foo"));
|
||||
await dispatch(actions.addExpression("bar"));
|
||||
|
||||
expect(selectors.getExpression(getState(), "foo").value).toBe("bla");
|
||||
expect(selectors.getExpression(getState(), "bar").value).toBe("bla");
|
||||
|
||||
await dispatch(actions.evaluateExpressions(cx));
|
||||
await dispatch(actions.evaluateExpressions());
|
||||
|
||||
expect(selectors.getExpression(getState(), "foo").value).toBe("bla");
|
||||
expect(selectors.getExpression(getState(), "bar").value).toBe("bla");
|
||||
@ -124,47 +124,44 @@ describe("expressions", () => {
|
||||
|
||||
it("should evaluate expressions in specific scope", async () => {
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
await createFrames(getState, dispatch);
|
||||
await createFrames(dispatch);
|
||||
|
||||
await dispatch(actions.newSource(makeSource("source")));
|
||||
|
||||
const cx = selectors.getThreadContext(getState());
|
||||
await dispatch(actions.addExpression(cx, "foo"));
|
||||
await dispatch(actions.addExpression(cx, "bar"));
|
||||
await dispatch(actions.addExpression("foo"));
|
||||
await dispatch(actions.addExpression("bar"));
|
||||
|
||||
expect(selectors.getExpression(getState(), "foo").value).toBe("boo");
|
||||
expect(selectors.getExpression(getState(), "bar").value).toBe("boo");
|
||||
|
||||
await dispatch(actions.evaluateExpressions(cx));
|
||||
await dispatch(actions.evaluateExpressions());
|
||||
|
||||
expect(selectors.getExpression(getState(), "foo").value).toBe("boo");
|
||||
expect(selectors.getExpression(getState(), "bar").value).toBe("boo");
|
||||
});
|
||||
|
||||
it("should get the autocomplete matches for the input", async () => {
|
||||
const { dispatch, getState, cx } = createStore(mockThreadClient);
|
||||
const { dispatch, getState } = createStore(mockThreadClient);
|
||||
|
||||
await dispatch(actions.autocomplete(cx, "to", 2));
|
||||
await dispatch(actions.autocomplete("to", 2));
|
||||
|
||||
expect(selectors.getAutocompleteMatchset(getState())).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
async function createFrames(getState, dispatch) {
|
||||
async function createFrames(dispatch) {
|
||||
const frame = makeMockFrame();
|
||||
|
||||
await dispatch(actions.newSource(makeSource("example.js")));
|
||||
|
||||
await dispatch(
|
||||
actions.paused({
|
||||
thread: "FakeThread",
|
||||
thread: "UnknownThread",
|
||||
frame,
|
||||
frames: [frame],
|
||||
why: { type: "just because" }
|
||||
})
|
||||
);
|
||||
|
||||
await dispatch(
|
||||
actions.selectFrame(selectors.getThreadContext(getState()), frame)
|
||||
);
|
||||
await dispatch(actions.selectFrame(frame));
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ const {
|
||||
|
||||
describe("file text search", () => {
|
||||
it("should update search results", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
const { dispatch, getState } = createStore();
|
||||
expect(getFileSearchResults(getState())).toEqual({
|
||||
matches: [],
|
||||
matchIndex: -1,
|
||||
@ -23,7 +23,7 @@ describe("file text search", () => {
|
||||
});
|
||||
|
||||
const matches = [{ line: 1, ch: 3 }, { line: 3, ch: 2 }];
|
||||
dispatch(actions.updateSearchResults(cx, 2, 3, matches));
|
||||
dispatch(actions.updateSearchResults(2, 3, matches));
|
||||
|
||||
expect(getFileSearchResults(getState())).toEqual({
|
||||
count: 2,
|
||||
@ -34,29 +34,29 @@ describe("file text search", () => {
|
||||
});
|
||||
|
||||
it("should update the file search query", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
const { dispatch, getState } = createStore();
|
||||
let fileSearchQueryState = getFileSearchQuery(getState());
|
||||
expect(fileSearchQueryState).toBe("");
|
||||
dispatch(actions.setFileSearchQuery(cx, "foobar"));
|
||||
dispatch(actions.setFileSearchQuery("foobar"));
|
||||
fileSearchQueryState = getFileSearchQuery(getState());
|
||||
expect(fileSearchQueryState).toBe("foobar");
|
||||
});
|
||||
|
||||
it("should toggle a file search modifier", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
const { dispatch, getState } = createStore();
|
||||
let fileSearchModState = getFileSearchModifiers(getState());
|
||||
expect(fileSearchModState.get("caseSensitive")).toBe(false);
|
||||
dispatch(actions.toggleFileSearchModifier(cx, "caseSensitive"));
|
||||
dispatch(actions.toggleFileSearchModifier("caseSensitive"));
|
||||
fileSearchModState = getFileSearchModifiers(getState());
|
||||
expect(fileSearchModState.get("caseSensitive")).toBe(true);
|
||||
});
|
||||
|
||||
it("should toggle a file search query cleaning", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setFileSearchQuery(cx, "foobar"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setFileSearchQuery("foobar"));
|
||||
let fileSearchQueryState = getFileSearchQuery(getState());
|
||||
expect(fileSearchQueryState).toBe("foobar");
|
||||
dispatch(actions.setFileSearchQuery(cx, ""));
|
||||
dispatch(actions.setFileSearchQuery(""));
|
||||
fileSearchQueryState = getFileSearchQuery(getState());
|
||||
expect(fileSearchQueryState).toBe("");
|
||||
});
|
||||
|
@ -48,11 +48,11 @@ describe("navigation", () => {
|
||||
});
|
||||
|
||||
it("navigation closes project-search", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
const mockQuery = "foo";
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo1")));
|
||||
await dispatch(actions.searchSources(cx, mockQuery));
|
||||
await dispatch(actions.searchSources(mockQuery));
|
||||
|
||||
let results = getTextSearchResults(getState());
|
||||
expect(results).toHaveLength(1);
|
||||
@ -77,9 +77,9 @@ describe("navigation", () => {
|
||||
});
|
||||
|
||||
it("navigation clears the file-search query", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
dispatch(actions.setFileSearchQuery(cx, "foobar"));
|
||||
dispatch(actions.setFileSearchQuery("foobar"));
|
||||
expect(getFileSearchQuery(getState())).toBe("foobar");
|
||||
|
||||
await dispatch(actions.willNavigate("will-navigate"));
|
||||
@ -88,10 +88,10 @@ describe("navigation", () => {
|
||||
});
|
||||
|
||||
it("navigation clears the file-search results", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
const searchResults = [{ line: 1, ch: 3 }, { line: 3, ch: 2 }];
|
||||
dispatch(actions.updateSearchResults(cx, 2, 3, searchResults));
|
||||
dispatch(actions.updateSearchResults(2, 3, searchResults));
|
||||
expect(getFileSearchResults(getState())).toEqual({
|
||||
count: 2,
|
||||
index: 2,
|
||||
|
@ -69,7 +69,7 @@ function mockSourceMaps() {
|
||||
|
||||
describe("when adding breakpoints", () => {
|
||||
it("a corresponding pending breakpoint should be added", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [1] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -78,12 +78,12 @@ describe("when adding breakpoints", () => {
|
||||
const source = makeSource("foo.js");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
const bp = generateBreakpoint("foo.js", 5, 1);
|
||||
const id = makePendingLocationId(bp.location);
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, bp.location));
|
||||
await dispatch(actions.addBreakpoint(bp.location));
|
||||
const pendingBps = selectors.getPendingBreakpoints(getState());
|
||||
|
||||
expect(selectors.getPendingBreakpointList(getState())).toHaveLength(2);
|
||||
@ -104,7 +104,7 @@ describe("when adding breakpoints", () => {
|
||||
});
|
||||
|
||||
it("add a corresponding pendingBreakpoint for each addition", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [0] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -119,11 +119,11 @@ describe("when adding breakpoints", () => {
|
||||
await dispatch(actions.newSource(source1));
|
||||
await dispatch(actions.newSource(source2));
|
||||
|
||||
await dispatch(actions.loadSourceText(cx, source1));
|
||||
await dispatch(actions.loadSourceText(cx, source2));
|
||||
await dispatch(actions.loadSourceText(source1));
|
||||
await dispatch(actions.loadSourceText(source2));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, breakpoint1.location));
|
||||
await dispatch(actions.addBreakpoint(cx, breakpoint2.location));
|
||||
await dispatch(actions.addBreakpoint(breakpoint1.location));
|
||||
await dispatch(actions.addBreakpoint(breakpoint2.location));
|
||||
|
||||
const pendingBps = selectors.getPendingBreakpoints(getState());
|
||||
|
||||
@ -135,7 +135,7 @@ describe("when adding breakpoints", () => {
|
||||
});
|
||||
|
||||
it("hidden breakponts do not create pending bps", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [0] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -144,10 +144,10 @@ describe("when adding breakpoints", () => {
|
||||
const source = makeSource("foo");
|
||||
await dispatch(actions.newSource(makeSource("foo")));
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(
|
||||
actions.addBreakpoint(cx, breakpoint1.location, { hidden: true })
|
||||
actions.addBreakpoint(breakpoint1.location, { hidden: true })
|
||||
);
|
||||
const pendingBps = selectors.getPendingBreakpoints(getState());
|
||||
|
||||
@ -155,7 +155,7 @@ describe("when adding breakpoints", () => {
|
||||
});
|
||||
|
||||
it("remove a corresponding pending breakpoint when deleting", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [0] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -170,12 +170,12 @@ describe("when adding breakpoints", () => {
|
||||
await dispatch(actions.newSource(source1));
|
||||
await dispatch(actions.newSource(source2));
|
||||
|
||||
await dispatch(actions.loadSourceText(cx, source1));
|
||||
await dispatch(actions.loadSourceText(cx, source2));
|
||||
await dispatch(actions.loadSourceText(source1));
|
||||
await dispatch(actions.loadSourceText(source2));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, breakpoint1.location));
|
||||
await dispatch(actions.addBreakpoint(cx, breakpoint2.location));
|
||||
await dispatch(actions.removeBreakpoint(cx, breakpoint1));
|
||||
await dispatch(actions.addBreakpoint(breakpoint1.location));
|
||||
await dispatch(actions.addBreakpoint(breakpoint2.location));
|
||||
await dispatch(actions.removeBreakpoint(breakpoint1));
|
||||
|
||||
const pendingBps = selectors.getPendingBreakpoints(getState());
|
||||
expect(pendingBps.hasOwnProperty(breakpointLocationId1)).toBe(false);
|
||||
@ -186,7 +186,7 @@ describe("when adding breakpoints", () => {
|
||||
|
||||
describe("when changing an existing breakpoint", () => {
|
||||
it("updates corresponding pendingBreakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [0] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -197,11 +197,11 @@ describe("when changing an existing breakpoint", () => {
|
||||
const source = makeSource("foo");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.newSource(makeSource("foo")));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, bp.location));
|
||||
await dispatch(actions.addBreakpoint(bp.location));
|
||||
await dispatch(
|
||||
actions.setBreakpointOptions(cx, bp.location, { condition: "2" })
|
||||
actions.setBreakpointOptions(bp.location, { condition: "2" })
|
||||
);
|
||||
const bps = selectors.getPendingBreakpoints(getState());
|
||||
const breakpoint = bps[id];
|
||||
@ -209,7 +209,7 @@ describe("when changing an existing breakpoint", () => {
|
||||
});
|
||||
|
||||
it("if disabled, updates corresponding pendingBreakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [0] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -221,17 +221,17 @@ describe("when changing an existing breakpoint", () => {
|
||||
|
||||
const source = makeSource("foo");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, bp.location));
|
||||
await dispatch(actions.disableBreakpoint(cx, bp));
|
||||
await dispatch(actions.addBreakpoint(bp.location));
|
||||
await dispatch(actions.disableBreakpoint(bp));
|
||||
const bps = selectors.getPendingBreakpoints(getState());
|
||||
const breakpoint = bps[id];
|
||||
expect(breakpoint.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it("does not delete the pre-existing pendingBreakpoint", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [0] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -241,13 +241,13 @@ describe("when changing an existing breakpoint", () => {
|
||||
const source = makeSource("foo.js");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
const id = makePendingLocationId(bp.location);
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, bp.location));
|
||||
await dispatch(actions.addBreakpoint(bp.location));
|
||||
await dispatch(
|
||||
actions.setBreakpointOptions(cx, bp.location, { condition: "2" })
|
||||
actions.setBreakpointOptions(bp.location, { condition: "2" })
|
||||
);
|
||||
const bps = selectors.getPendingBreakpoints(getState());
|
||||
const breakpoint = bps[id];
|
||||
@ -267,7 +267,7 @@ describe("initializing when pending breakpoints exist in prefs", () => {
|
||||
});
|
||||
|
||||
it("re-adding breakpoints update existing pending breakpoints", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [1, 2] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -278,15 +278,15 @@ describe("initializing when pending breakpoints exist in prefs", () => {
|
||||
|
||||
const source = makeSource("bar.js");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.addBreakpoint(cx, bar.location));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
await dispatch(actions.addBreakpoint(bar.location));
|
||||
|
||||
const bps = selectors.getPendingBreakpointList(getState());
|
||||
expect(bps).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("adding bps doesn't remove existing pending breakpoints", async () => {
|
||||
const { dispatch, getState, cx } = createStore(
|
||||
const { dispatch, getState } = createStore(
|
||||
mockClient({ "5": [0] }),
|
||||
loadInitialState(),
|
||||
mockSourceMaps()
|
||||
@ -296,9 +296,9 @@ describe("initializing when pending breakpoints exist in prefs", () => {
|
||||
const source = makeSource("foo.js");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await dispatch(actions.addBreakpoint(cx, bp.location));
|
||||
await dispatch(actions.addBreakpoint(bp.location));
|
||||
|
||||
const bps = selectors.getPendingBreakpointList(getState());
|
||||
expect(bps).toHaveLength(2);
|
||||
@ -313,12 +313,12 @@ describe("initializing with disabled pending breakpoints in prefs", () => {
|
||||
mockSourceMaps()
|
||||
);
|
||||
|
||||
const { getState, dispatch, cx } = store;
|
||||
const { getState, dispatch } = store;
|
||||
const source = makeSource("bar.js");
|
||||
|
||||
await dispatch(actions.newSource(makeSource("bar.js")));
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await waitForState(store, state => {
|
||||
const bps = selectors.getBreakpointsForSource(state, source.id);
|
||||
@ -346,7 +346,7 @@ describe("adding sources", () => {
|
||||
loadInitialState({ disabled: true }),
|
||||
mockSourceMaps()
|
||||
);
|
||||
const { getState, dispatch, cx } = store;
|
||||
const { getState, dispatch } = store;
|
||||
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(0);
|
||||
|
||||
@ -354,7 +354,7 @@ describe("adding sources", () => {
|
||||
|
||||
await dispatch(actions.newSource(makeSource("bar.js")));
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
await waitForState(store, state => selectors.getBreakpointCount(state) > 0);
|
||||
|
||||
@ -396,7 +396,7 @@ describe("adding sources", () => {
|
||||
loadInitialState({ disabled: true }),
|
||||
mockSourceMaps()
|
||||
);
|
||||
const { getState, dispatch, cx } = store;
|
||||
const { getState, dispatch } = store;
|
||||
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(0);
|
||||
|
||||
@ -405,8 +405,8 @@ describe("adding sources", () => {
|
||||
await dispatch(actions.newSource(makeSource("bar.js")));
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
await dispatch(actions.newSources([source1, source2]));
|
||||
await dispatch(actions.loadSourceText(cx, source1));
|
||||
await dispatch(actions.loadSourceText(cx, source2));
|
||||
await dispatch(actions.loadSourceText(source1));
|
||||
await dispatch(actions.loadSourceText(source2));
|
||||
|
||||
await waitForState(store, state => selectors.getBreakpointCount(state) > 0);
|
||||
expect(selectors.getBreakpointCount(getState())).toEqual(1);
|
||||
|
@ -44,16 +44,16 @@ const threadClient = {
|
||||
|
||||
describe("project text search", () => {
|
||||
it("should add a project text search query", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
const { dispatch, getState } = createStore();
|
||||
const mockQuery = "foo";
|
||||
|
||||
dispatch(actions.addSearchQuery(cx, mockQuery));
|
||||
dispatch(actions.addSearchQuery(mockQuery));
|
||||
|
||||
expect(getTextSearchQuery(getState())).toEqual(mockQuery);
|
||||
});
|
||||
|
||||
it("should search all the loaded sources based on the query", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
const mockQuery = "foo";
|
||||
const source1 = makeSource("foo1");
|
||||
const source2 = makeSource("foo2");
|
||||
@ -61,7 +61,7 @@ describe("project text search", () => {
|
||||
await dispatch(actions.newSource(source1));
|
||||
await dispatch(actions.newSource(source2));
|
||||
|
||||
await dispatch(actions.searchSources(cx, mockQuery));
|
||||
await dispatch(actions.searchSources(mockQuery));
|
||||
|
||||
const results = getTextSearchResults(getState());
|
||||
expect(results).toMatchSnapshot();
|
||||
@ -81,26 +81,26 @@ describe("project text search", () => {
|
||||
getOriginalLocations: async items => items
|
||||
};
|
||||
|
||||
const { dispatch, getState, cx } = createStore(threadClient, {}, mockMaps);
|
||||
const { dispatch, getState } = createStore(threadClient, {}, mockMaps);
|
||||
const mockQuery = "bla";
|
||||
|
||||
await dispatch(actions.newSource(source1));
|
||||
await dispatch(actions.newSource(source2));
|
||||
|
||||
await dispatch(actions.searchSources(cx, mockQuery));
|
||||
await dispatch(actions.searchSources(mockQuery));
|
||||
|
||||
const results = getTextSearchResults(getState());
|
||||
expect(results).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should search a specific source", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
const source = makeSource("bar");
|
||||
await dispatch(actions.newSource(source));
|
||||
await dispatch(actions.loadSourceText(cx, source));
|
||||
await dispatch(actions.loadSourceText(source));
|
||||
|
||||
dispatch(actions.addSearchQuery(cx, "bla"));
|
||||
dispatch(actions.addSearchQuery("bla"));
|
||||
|
||||
const barSource = getSource(getState(), "bar");
|
||||
if (!barSource) {
|
||||
@ -108,7 +108,7 @@ describe("project text search", () => {
|
||||
}
|
||||
const sourceId = barSource.id;
|
||||
|
||||
await dispatch(actions.searchSource(cx, sourceId, "bla"), "bla");
|
||||
await dispatch(actions.searchSource(sourceId, "bla"), "bla");
|
||||
|
||||
const results = getTextSearchResults(getState());
|
||||
|
||||
@ -117,36 +117,36 @@ describe("project text search", () => {
|
||||
});
|
||||
|
||||
it("should clear all the search results", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
const mockQuery = "foo";
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo1")));
|
||||
await dispatch(actions.searchSources(cx, mockQuery));
|
||||
await dispatch(actions.searchSources(mockQuery));
|
||||
|
||||
expect(getTextSearchResults(getState())).toMatchSnapshot();
|
||||
|
||||
await dispatch(actions.clearSearchResults(cx));
|
||||
await dispatch(actions.clearSearchResults());
|
||||
|
||||
expect(getTextSearchResults(getState())).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should set the status properly", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
const { dispatch, getState } = createStore();
|
||||
const mockStatus = "Fetching";
|
||||
dispatch(actions.updateSearchStatus(cx, mockStatus));
|
||||
dispatch(actions.updateSearchStatus(mockStatus));
|
||||
expect(getTextSearchStatus(getState())).toEqual(mockStatus);
|
||||
});
|
||||
|
||||
it("should close project search", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
const mockQuery = "foo";
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo1")));
|
||||
await dispatch(actions.searchSources(cx, mockQuery));
|
||||
await dispatch(actions.searchSources(mockQuery));
|
||||
|
||||
expect(getTextSearchResults(getState())).toMatchSnapshot();
|
||||
|
||||
dispatch(actions.closeProjectSearch(cx));
|
||||
dispatch(actions.closeProjectSearch());
|
||||
|
||||
expect(getTextSearchQuery(getState())).toEqual("");
|
||||
|
||||
|
@ -17,39 +17,39 @@ const { getProjectDirectoryRoot, getDisplayedSources } = selectors;
|
||||
|
||||
describe("setProjectDirectoryRoot", () => {
|
||||
it("should set domain directory as root", async () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "example.com"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("example.com"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("example.com");
|
||||
});
|
||||
|
||||
it("should set a directory as root directory", async () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/example.com/foo"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("/example.com/foo"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("/example.com/foo");
|
||||
});
|
||||
|
||||
it("should add to the directory ", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/example.com/foo"));
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/foo/bar"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("/example.com/foo"));
|
||||
dispatch(actions.setProjectDirectoryRoot("/foo/bar"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("/example.com/foo/bar");
|
||||
});
|
||||
|
||||
it("should update the directory ", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/example.com/foo"));
|
||||
dispatch(actions.clearProjectDirectoryRoot(cx));
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/example.com/bar"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("/example.com/foo"));
|
||||
dispatch(actions.clearProjectDirectoryRoot());
|
||||
dispatch(actions.setProjectDirectoryRoot("/example.com/bar"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("/example.com/bar");
|
||||
});
|
||||
|
||||
it("should filter sources", async () => {
|
||||
const store = createStore({});
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
await dispatch(actions.newSource(makeSource("js/scopes.js")));
|
||||
await dispatch(actions.newSource(makeSource("lib/vendor.js")));
|
||||
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "localhost:8000/examples/js"));
|
||||
dispatch(actions.setProjectDirectoryRoot("localhost:8000/examples/js"));
|
||||
|
||||
const filteredSourcesByThread = getDisplayedSources(getState());
|
||||
const filteredSources = Object.values(filteredSourcesByThread)[0];
|
||||
@ -63,16 +63,16 @@ describe("setProjectDirectoryRoot", () => {
|
||||
});
|
||||
|
||||
it("should update the child directory ", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "example.com"));
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "example.com/foo/bar"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("example.com"));
|
||||
dispatch(actions.setProjectDirectoryRoot("example.com/foo/bar"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("example.com/foo/bar");
|
||||
});
|
||||
|
||||
it("should update the child directory when domain name is Webpack://", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "webpack://"));
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "webpack:///app"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("webpack://"));
|
||||
dispatch(actions.setProjectDirectoryRoot("webpack:///app"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("webpack:///app");
|
||||
});
|
||||
});
|
||||
|
@ -16,26 +16,26 @@ import { sourceThreadClient as threadClient } from "./helpers/threadClient.js";
|
||||
|
||||
describe("closing tabs", () => {
|
||||
it("closing a tab", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
const fooSource = makeSource("foo.js");
|
||||
await dispatch(actions.newSource(fooSource));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
dispatch(actions.closeTab(cx, fooSource));
|
||||
await dispatch(actions.selectLocation({ sourceId: "foo.js", line: 1 }));
|
||||
dispatch(actions.closeTab(fooSource));
|
||||
|
||||
expect(getSelectedSource(getState())).toBe(undefined);
|
||||
expect(getSourceTabs(getState())).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("closing the inactive tab", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
const fooSource = makeSource("foo.js");
|
||||
await dispatch(actions.newSource(fooSource));
|
||||
await dispatch(actions.newSource(makeSource("bar.js")));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
dispatch(actions.closeTab(cx, fooSource));
|
||||
await dispatch(actions.selectLocation({ sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "bar.js", line: 1 }));
|
||||
dispatch(actions.closeTab(fooSource));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
expect(selected && selected.id).toBe("bar.js");
|
||||
@ -43,26 +43,26 @@ describe("closing tabs", () => {
|
||||
});
|
||||
|
||||
it("closing the only tab", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
const fooSource = makeSource("foo.js");
|
||||
await dispatch(actions.newSource(fooSource));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
dispatch(actions.closeTab(cx, fooSource));
|
||||
await dispatch(actions.selectLocation({ sourceId: "foo.js", line: 1 }));
|
||||
dispatch(actions.closeTab(fooSource));
|
||||
|
||||
expect(getSelectedSource(getState())).toBe(undefined);
|
||||
expect(getSourceTabs(getState())).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("closing the active tab", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
const barSource = makeSource("bar.js");
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
await dispatch(actions.newSource(barSource));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(actions.closeTab(cx, barSource));
|
||||
await dispatch(actions.selectLocation({ sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(actions.closeTab(barSource));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
expect(selected && selected.id).toBe("foo.js");
|
||||
@ -70,24 +70,22 @@ describe("closing tabs", () => {
|
||||
});
|
||||
|
||||
it("closing many inactive tabs", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
const fooSource = makeSource("foo.js");
|
||||
const barSource = makeSource("bar.js");
|
||||
await dispatch(actions.newSource(fooSource));
|
||||
await dispatch(actions.newSource(barSource));
|
||||
await dispatch(actions.newSource(makeSource("bazz.js")));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: "bazz.js", line: 1 })
|
||||
);
|
||||
await dispatch(actions.selectLocation({ sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "bazz.js", line: 1 }));
|
||||
|
||||
const tabs = [
|
||||
"http://localhost:8000/examples/foo.js",
|
||||
"http://localhost:8000/examples/bar.js"
|
||||
];
|
||||
dispatch(actions.closeTabs(cx, tabs));
|
||||
dispatch(actions.closeTabs(tabs));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
expect(selected && selected.id).toBe("bazz.js");
|
||||
@ -95,21 +93,19 @@ describe("closing tabs", () => {
|
||||
});
|
||||
|
||||
it("closing many tabs including the active tab", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
await dispatch(actions.newSource(makeSource("bar.js")));
|
||||
await dispatch(actions.newSource(makeSource("bazz.js")));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: "bazz.js", line: 1 })
|
||||
);
|
||||
await dispatch(actions.selectLocation({ sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "bazz.js", line: 1 }));
|
||||
const tabs = [
|
||||
"http://localhost:8000/examples/bar.js",
|
||||
"http://localhost:8000/examples/bazz.js"
|
||||
];
|
||||
await dispatch(actions.closeTabs(cx, tabs));
|
||||
await dispatch(actions.closeTabs(tabs));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
expect(selected && selected.id).toBe("foo.js");
|
||||
@ -117,14 +113,14 @@ describe("closing tabs", () => {
|
||||
});
|
||||
|
||||
it("closing all the tabs", async () => {
|
||||
const { dispatch, getState, cx } = createStore(threadClient);
|
||||
const { dispatch, getState } = createStore(threadClient);
|
||||
|
||||
await dispatch(actions.newSource(makeSource("foo.js")));
|
||||
await dispatch(actions.newSource(makeSource("bar.js")));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation({ sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.closeTabs(cx, [
|
||||
actions.closeTabs([
|
||||
"http://localhost:8000/examples/foo.js",
|
||||
"http://localhost:8000/examples/bar.js"
|
||||
])
|
||||
|
@ -85,39 +85,39 @@ describe("ui", () => {
|
||||
|
||||
describe("setProjectDirectoryRoot", () => {
|
||||
it("should set domain directory as root", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "example.com"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("example.com"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("example.com");
|
||||
});
|
||||
|
||||
it("should set a directory as root directory", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/example.com/foo"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("/example.com/foo"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("/example.com/foo");
|
||||
});
|
||||
|
||||
it("should add to the directory ", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/example.com/foo"));
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/foo/bar"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("/example.com/foo"));
|
||||
dispatch(actions.setProjectDirectoryRoot("/foo/bar"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("/example.com/foo/bar");
|
||||
});
|
||||
|
||||
it("should update the directory ", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/example.com/foo"));
|
||||
dispatch(actions.clearProjectDirectoryRoot(cx));
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "/example.com/bar"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("/example.com/foo"));
|
||||
dispatch(actions.clearProjectDirectoryRoot());
|
||||
dispatch(actions.setProjectDirectoryRoot("/example.com/bar"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("/example.com/bar");
|
||||
});
|
||||
|
||||
it("should filter sources", async () => {
|
||||
const store = createStore({});
|
||||
const { dispatch, getState, cx } = store;
|
||||
const { dispatch, getState } = store;
|
||||
await dispatch(actions.newSource(makeSource("js/scopes.js")));
|
||||
await dispatch(actions.newSource(makeSource("lib/vendor.js")));
|
||||
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "localhost:8000/examples/js"));
|
||||
dispatch(actions.setProjectDirectoryRoot("localhost:8000/examples/js"));
|
||||
|
||||
const filteredSourcesByThread = getDisplayedSources(getState());
|
||||
const filteredSources = Object.values(filteredSourcesByThread)[0];
|
||||
@ -131,16 +131,16 @@ describe("setProjectDirectoryRoot", () => {
|
||||
});
|
||||
|
||||
it("should update the child directory ", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "example.com"));
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "example.com/foo/bar"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("example.com"));
|
||||
dispatch(actions.setProjectDirectoryRoot("example.com/foo/bar"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("example.com/foo/bar");
|
||||
});
|
||||
|
||||
it("should update the child directory when domain name is Webpack://", () => {
|
||||
const { dispatch, getState, cx } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "webpack://"));
|
||||
dispatch(actions.setProjectDirectoryRoot(cx, "webpack:///app"));
|
||||
const { dispatch, getState } = createStore();
|
||||
dispatch(actions.setProjectDirectoryRoot("webpack://"));
|
||||
dispatch(actions.setProjectDirectoryRoot("webpack:///app"));
|
||||
expect(getProjectDirectoryRoot(getState())).toBe("webpack:///app");
|
||||
});
|
||||
});
|
||||
|
@ -6,31 +6,26 @@
|
||||
|
||||
import type { SymbolDeclarations, AstLocation } from "../../workers/parser";
|
||||
import type { PromiseAction } from "../utils/middleware/promise";
|
||||
import type { Context } from "../../types";
|
||||
|
||||
export type ASTAction =
|
||||
| PromiseAction<
|
||||
{|
|
||||
+type: "SET_SYMBOLS",
|
||||
+cx: Context,
|
||||
+sourceId: string
|
||||
|},
|
||||
SymbolDeclarations
|
||||
>
|
||||
| {|
|
||||
+type: "OUT_OF_SCOPE_LOCATIONS",
|
||||
+cx: Context,
|
||||
+locations: ?(AstLocation[])
|
||||
|}
|
||||
| {|
|
||||
+type: "IN_SCOPE_LINES",
|
||||
+cx: Context,
|
||||
+lines: number[]
|
||||
|}
|
||||
| PromiseAction<
|
||||
{|
|
||||
+type: "SET_PREVIEW",
|
||||
+cx: Context
|
||||
+type: "SET_PREVIEW"
|
||||
|},
|
||||
{
|
||||
expression: string,
|
||||
@ -41,6 +36,5 @@ export type ASTAction =
|
||||
}
|
||||
>
|
||||
| {|
|
||||
+type: "CLEAR_SELECTION",
|
||||
+cx: Context
|
||||
+type: "CLEAR_SELECTION"
|
||||
|};
|
||||
|
@ -9,8 +9,7 @@ import type {
|
||||
SourceLocation,
|
||||
XHRBreakpoint,
|
||||
Source,
|
||||
BreakpointPositions,
|
||||
Context
|
||||
BreakpointPositions
|
||||
} from "../../types";
|
||||
|
||||
import type { PromiseAction } from "../utils/middleware/promise";
|
||||
@ -42,17 +41,14 @@ export type BreakpointAction =
|
||||
|}>
|
||||
| {|
|
||||
+type: "SET_BREAKPOINT",
|
||||
+cx: Context,
|
||||
+breakpoint: Breakpoint
|
||||
|}
|
||||
| {|
|
||||
+type: "REMOVE_BREAKPOINT",
|
||||
+cx: Context,
|
||||
+location: SourceLocation
|
||||
|}
|
||||
| {|
|
||||
type: "ADD_BREAKPOINT_POSITIONS",
|
||||
+cx: Context,
|
||||
positions: BreakpointPositions,
|
||||
source: Source
|
||||
|};
|
||||
|
@ -5,33 +5,23 @@
|
||||
// @flow
|
||||
|
||||
import type { Command } from "../../reducers/types";
|
||||
import type {
|
||||
Expression,
|
||||
LoadedObject,
|
||||
Frame,
|
||||
Scope,
|
||||
Why,
|
||||
ThreadContext
|
||||
} from "../../types";
|
||||
import type { Expression, LoadedObject, Frame, Scope, Why } from "../../types";
|
||||
|
||||
import type { PromiseAction } from "../utils/middleware/promise";
|
||||
|
||||
export type PauseAction =
|
||||
| {|
|
||||
+type: "BREAK_ON_NEXT",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+value: boolean
|
||||
|}
|
||||
| {|
|
||||
// Note: Do not include cx, as this action is triggered by the server.
|
||||
+type: "RESUME",
|
||||
+thread: string,
|
||||
+value: void,
|
||||
+wasStepping: boolean
|
||||
|}
|
||||
| {|
|
||||
// Note: Do not include cx, as this action is triggered by the server.
|
||||
+type: "PAUSED",
|
||||
+thread: string,
|
||||
+why: Why,
|
||||
@ -47,13 +37,11 @@ export type PauseAction =
|
||||
|}
|
||||
| PromiseAction<{|
|
||||
+type: "COMMAND",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+command: Command
|
||||
|}>
|
||||
| {|
|
||||
+type: "SELECT_FRAME",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+frame: Frame
|
||||
|}
|
||||
@ -64,14 +52,12 @@ export type PauseAction =
|
||||
|}
|
||||
| {|
|
||||
+type: "SET_POPUP_OBJECT_PROPERTIES",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+objectId: string,
|
||||
+properties: Object
|
||||
|}
|
||||
| {|
|
||||
+type: "ADD_EXPRESSION",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+id: number,
|
||||
+input: string,
|
||||
@ -81,7 +67,6 @@ export type PauseAction =
|
||||
| PromiseAction<
|
||||
{|
|
||||
+type: "EVALUATE_EXPRESSION",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+input: string
|
||||
|},
|
||||
@ -89,13 +74,11 @@ export type PauseAction =
|
||||
>
|
||||
| PromiseAction<{|
|
||||
+type: "EVALUATE_EXPRESSIONS",
|
||||
+cx: ThreadContext,
|
||||
+results: Expression[],
|
||||
+inputs: string[]
|
||||
|}>
|
||||
| {|
|
||||
+type: "UPDATE_EXPRESSION",
|
||||
+cx: ThreadContext,
|
||||
+expression: Expression,
|
||||
+input: string,
|
||||
+expressionError: ?string
|
||||
@ -112,14 +95,12 @@ export type PauseAction =
|
||||
|}
|
||||
| {|
|
||||
+type: "AUTOCOMPLETE",
|
||||
+cx: ThreadContext,
|
||||
+input: string,
|
||||
+result: Object
|
||||
|}
|
||||
| PromiseAction<
|
||||
{|
|
||||
+type: "MAP_SCOPES",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+frame: Frame
|
||||
|},
|
||||
@ -132,7 +113,6 @@ export type PauseAction =
|
||||
>
|
||||
| {|
|
||||
+type: "MAP_FRAMES",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+frames: Frame[],
|
||||
+selectedFrameId: string
|
||||
@ -140,7 +120,6 @@ export type PauseAction =
|
||||
| PromiseAction<
|
||||
{|
|
||||
+type: "ADD_SCOPES",
|
||||
+cx: ThreadContext,
|
||||
+thread: string,
|
||||
+frame: Frame
|
||||
|},
|
||||
|
@ -4,13 +4,12 @@
|
||||
|
||||
// @flow
|
||||
|
||||
import type { Source, SourceLocation, Context } from "../../types";
|
||||
import type { Source, SourceLocation } from "../../types";
|
||||
import type { PromiseAction } from "../utils/middleware/promise";
|
||||
|
||||
export type LoadSourceAction = PromiseAction<
|
||||
{|
|
||||
+type: "LOAD_SOURCE_TEXT",
|
||||
+cx: Context,
|
||||
+sourceId: string,
|
||||
+epoch: number
|
||||
|},
|
||||
@ -20,37 +19,31 @@ export type SourceAction =
|
||||
| LoadSourceAction
|
||||
| {|
|
||||
+type: "ADD_SOURCE",
|
||||
+cx: Context,
|
||||
+source: Source
|
||||
|}
|
||||
| {|
|
||||
+type: "ADD_SOURCES",
|
||||
+cx: Context,
|
||||
+sources: Array<Source>
|
||||
|}
|
||||
| {|
|
||||
+type: "UPDATE_SOURCE",
|
||||
+cx: Context,
|
||||
+source: Source
|
||||
|}
|
||||
| {|
|
||||
+type: "SET_SELECTED_LOCATION",
|
||||
+cx: Context,
|
||||
+source: Source,
|
||||
+location?: SourceLocation
|
||||
|}
|
||||
| {|
|
||||
+type: "SET_PENDING_SELECTED_LOCATION",
|
||||
+cx: Context,
|
||||
+url: string,
|
||||
+line?: number,
|
||||
+column?: number
|
||||
|}
|
||||
| {| type: "CLEAR_SELECTED_LOCATION", +cx: Context |}
|
||||
| {| type: "CLEAR_SELECTED_LOCATION" |}
|
||||
| PromiseAction<
|
||||
{|
|
||||
+type: "BLACKBOX",
|
||||
+cx: Context,
|
||||
+source: Source
|
||||
|},
|
||||
{|
|
||||
|
@ -4,12 +4,7 @@
|
||||
|
||||
// @flow
|
||||
|
||||
import type {
|
||||
Source,
|
||||
PartialRange,
|
||||
SourceLocation,
|
||||
Context
|
||||
} from "../../types";
|
||||
import type { Source, PartialRange, SourceLocation } from "../../types";
|
||||
|
||||
import type {
|
||||
ActiveSearchType,
|
||||
@ -69,7 +64,6 @@ export type UIAction =
|
||||
|}
|
||||
| {|
|
||||
+type: "SET_PROJECT_DIRECTORY_ROOT",
|
||||
+cx: Context,
|
||||
+url: string
|
||||
|}
|
||||
| {|
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// @flow
|
||||
|
||||
import type { WorkerList, MainThread, Context } from "../../types";
|
||||
import type { WorkerList, MainThread } from "../../types";
|
||||
import type { State } from "../../reducers/types";
|
||||
import type { MatchedLocations } from "../../reducers/file-search";
|
||||
import type { TreeNode } from "../../utils/sources-tree/types";
|
||||
@ -75,23 +75,18 @@ export type FocusItem = {
|
||||
|
||||
export type SourceTreeAction =
|
||||
| {| +type: "SET_EXPANDED_STATE", +thread: string, +expanded: any |}
|
||||
| {| +type: "SET_FOCUSED_SOURCE_ITEM", +cx: Context, item: FocusItem |};
|
||||
| {| +type: "SET_FOCUSED_SOURCE_ITEM", item: FocusItem |};
|
||||
|
||||
export type ProjectTextSearchAction =
|
||||
| {| +type: "ADD_QUERY", +cx: Context, +query: string |}
|
||||
| {| +type: "ADD_QUERY", +query: string |}
|
||||
| {|
|
||||
+type: "ADD_SEARCH_RESULT",
|
||||
+cx: Context,
|
||||
+result: ProjectTextSearchResult
|
||||
|}
|
||||
| {| +type: "UPDATE_STATUS", +cx: Context, +status: string |}
|
||||
| {| +type: "CLEAR_SEARCH_RESULTS", +cx: Context |}
|
||||
| {|
|
||||
+type: "ADD_ONGOING_SEARCH",
|
||||
+cx: Context,
|
||||
+ongoingSearch: SearchOperation
|
||||
|}
|
||||
| {| +type: "CLEAR_SEARCH", +cx: Context |};
|
||||
| {| +type: "UPDATE_STATUS", +status: string |}
|
||||
| {| +type: "CLEAR_SEARCH_RESULTS" |}
|
||||
| {| +type: "ADD_ONGOING_SEARCH", +ongoingSearch: SearchOperation |}
|
||||
| {| +type: "CLEAR_SEARCH" |};
|
||||
|
||||
export type FileTextSearchModifier =
|
||||
| "caseSensitive"
|
||||
@ -101,17 +96,14 @@ export type FileTextSearchModifier =
|
||||
export type FileTextSearchAction =
|
||||
| {|
|
||||
+type: "TOGGLE_FILE_SEARCH_MODIFIER",
|
||||
+cx: Context,
|
||||
+modifier: FileTextSearchModifier
|
||||
|}
|
||||
| {|
|
||||
+type: "UPDATE_FILE_SEARCH_QUERY",
|
||||
+cx: Context,
|
||||
+query: string
|
||||
|}
|
||||
| {|
|
||||
+type: "UPDATE_SEARCH_RESULTS",
|
||||
+cx: Context,
|
||||
+results: {
|
||||
matches: MatchedLocations[],
|
||||
matchIndex: number,
|
||||
@ -125,16 +117,14 @@ export type QuickOpenAction =
|
||||
| {| +type: "OPEN_QUICK_OPEN", +query?: string |}
|
||||
| {| +type: "CLOSE_QUICK_OPEN" |};
|
||||
|
||||
export type DebuggeeAction =
|
||||
export type DebugeeAction =
|
||||
| {|
|
||||
+type: "SET_WORKERS",
|
||||
+cx: Context,
|
||||
+workers: WorkerList,
|
||||
+mainThread: string
|
||||
|}
|
||||
| {|
|
||||
+type: "SELECT_THREAD",
|
||||
+cx: Context,
|
||||
+thread: string
|
||||
|};
|
||||
|
||||
@ -166,5 +156,5 @@ export type Action =
|
||||
| QuickOpenAction
|
||||
| FileTextSearchAction
|
||||
| ProjectTextSearchAction
|
||||
| DebuggeeAction
|
||||
| DebugeeAction
|
||||
| SourceTreeAction;
|
||||
|
@ -17,7 +17,7 @@ import type { ThunkArgs, panelPositionType } from "./types";
|
||||
import { getEditor, getLocationsInViewport } from "../utils/editor";
|
||||
import { searchContents } from "./file-search";
|
||||
|
||||
import type { SourceLocation, Context } from "../types";
|
||||
import type { SourceLocation } from "../types";
|
||||
import type {
|
||||
ActiveSearchType,
|
||||
OrientationType,
|
||||
@ -53,13 +53,13 @@ export function setActiveSearch(activeSearch?: ActiveSearchType) {
|
||||
};
|
||||
}
|
||||
|
||||
export function updateActiveFileSearch(cx: Context) {
|
||||
export function updateActiveFileSearch() {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
const isFileSearchOpen = getActiveSearch(getState()) === "file";
|
||||
const fileSearchQuery = getFileSearchQuery(getState());
|
||||
if (isFileSearchOpen && fileSearchQuery) {
|
||||
const editor = getEditor();
|
||||
dispatch(searchContents(cx, fileSearchQuery, editor));
|
||||
dispatch(searchContents(fileSearchQuery, editor));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -73,7 +73,7 @@ export function toggleFrameworkGrouping(toggleValue: boolean) {
|
||||
};
|
||||
}
|
||||
|
||||
export function showSource(cx: Context, sourceId: string) {
|
||||
export function showSource(sourceId: string) {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
const source = getSource(getState(), sourceId);
|
||||
if (!source) {
|
||||
@ -91,7 +91,7 @@ export function showSource(cx: Context, sourceId: string) {
|
||||
dispatch(setPrimaryPaneTab("sources"));
|
||||
|
||||
dispatch({ type: "SHOW_SOURCE", source: null });
|
||||
dispatch(selectSource(cx, source.id));
|
||||
dispatch(selectSource(source.id));
|
||||
dispatch({ type: "SHOW_SOURCE", source });
|
||||
};
|
||||
}
|
||||
@ -171,15 +171,14 @@ export function closeConditionalPanel() {
|
||||
};
|
||||
}
|
||||
|
||||
export function clearProjectDirectoryRoot(cx: Context) {
|
||||
export function clearProjectDirectoryRoot() {
|
||||
return {
|
||||
type: "SET_PROJECT_DIRECTORY_ROOT",
|
||||
cx,
|
||||
url: ""
|
||||
};
|
||||
}
|
||||
|
||||
export function setProjectDirectoryRoot(cx: Context, newRoot: string) {
|
||||
export function setProjectDirectoryRoot(newRoot: string) {
|
||||
return ({ dispatch, getState }: ThunkArgs) => {
|
||||
const curRoot = getProjectDirectoryRoot(getState());
|
||||
if (newRoot && curRoot) {
|
||||
@ -196,7 +195,6 @@ export function setProjectDirectoryRoot(cx: Context, newRoot: string) {
|
||||
|
||||
dispatch({
|
||||
type: "SET_PROJECT_DIRECTORY_ROOT",
|
||||
cx,
|
||||
url: newRoot
|
||||
});
|
||||
};
|
||||
|
@ -18,7 +18,6 @@ import { history } from "./middleware/history";
|
||||
import { promise } from "./middleware/promise";
|
||||
import { thunk } from "./middleware/thunk";
|
||||
import { timing } from "./middleware/timing";
|
||||
import { context } from "./middleware/context";
|
||||
|
||||
/**
|
||||
* @memberof utils/create-store
|
||||
@ -48,7 +47,6 @@ type ReduxStoreOptions = {
|
||||
const configureStore = (opts: ReduxStoreOptions = {}) => {
|
||||
const middleware = [
|
||||
thunk(opts.makeThunkArgs),
|
||||
context,
|
||||
promise,
|
||||
|
||||
// Order is important: services must go last as they always
|
||||
|
@ -1,37 +0,0 @@
|
||||
/* 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/>. */
|
||||
|
||||
// @flow
|
||||
|
||||
import {
|
||||
validateNavigateContext,
|
||||
validateContext
|
||||
} from "../../../utils/context";
|
||||
|
||||
import type { ThunkArgs } from "../../types";
|
||||
|
||||
function validateActionContext(getState, action) {
|
||||
if (action.type == "COMMAND" && action.status == "done") {
|
||||
// The thread will have resumed execution since the action was initiated,
|
||||
// so just make sure we haven't navigated.
|
||||
validateNavigateContext(getState(), action.cx);
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate using all available information in the context.
|
||||
validateContext(getState(), action.cx);
|
||||
}
|
||||
|
||||
// Middleware which looks for actions that have a cx property and ignores
|
||||
// them if the context is no longer valid.
|
||||
function context({ dispatch, getState }: ThunkArgs) {
|
||||
return (next: Function) => (action: Object) => {
|
||||
if ("cx" in action) {
|
||||
validateActionContext(getState, action);
|
||||
}
|
||||
return next(action);
|
||||
};
|
||||
}
|
||||
|
||||
export { context };
|
@ -8,7 +8,6 @@ DIRS += [
|
||||
]
|
||||
|
||||
CompiledModules(
|
||||
'context.js',
|
||||
'history.js',
|
||||
'log.js',
|
||||
'promise.js',
|
||||
|
@ -17,17 +17,12 @@ import { breakpointItems } from "./menus/breakpoints";
|
||||
import type { BreakpointItemActions } from "./menus/breakpoints";
|
||||
import type { EditorItemActions } from "./menus/editor";
|
||||
|
||||
import type {
|
||||
Source,
|
||||
Breakpoint as BreakpointType,
|
||||
ThreadContext
|
||||
} from "../../types";
|
||||
import type { Source, Breakpoint as BreakpointType } from "../../types";
|
||||
|
||||
const breakpointSvg = document.createElement("div");
|
||||
ReactDOM.render(<Svg name="breakpoint" />, breakpointSvg);
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
breakpoint: BreakpointType,
|
||||
selectedSource: Source,
|
||||
editor: Object,
|
||||
@ -67,7 +62,6 @@ class Breakpoint extends PureComponent<Props> {
|
||||
|
||||
onClick = (event: MouseEvent) => {
|
||||
const {
|
||||
cx,
|
||||
breakpointActions,
|
||||
editorActions,
|
||||
breakpoint,
|
||||
@ -84,33 +78,31 @@ class Breakpoint extends PureComponent<Props> {
|
||||
|
||||
const selectedLocation = getSelectedLocation(breakpoint, selectedSource);
|
||||
if (event.metaKey) {
|
||||
return editorActions.continueToHere(cx, selectedLocation.line);
|
||||
return editorActions.continueToHere(selectedLocation.line);
|
||||
}
|
||||
|
||||
if (event.shiftKey) {
|
||||
if (features.columnBreakpoints) {
|
||||
return breakpointActions.toggleBreakpointsAtLine(
|
||||
cx,
|
||||
!breakpoint.disabled,
|
||||
selectedLocation.line
|
||||
);
|
||||
}
|
||||
|
||||
return breakpointActions.toggleDisabledBreakpoint(cx, breakpoint);
|
||||
return breakpointActions.toggleDisabledBreakpoint(breakpoint);
|
||||
}
|
||||
|
||||
return breakpointActions.removeBreakpointsAtLine(
|
||||
cx,
|
||||
selectedLocation.sourceId,
|
||||
selectedLocation.line
|
||||
);
|
||||
};
|
||||
|
||||
onContextMenu = (event: MouseEvent) => {
|
||||
const { cx, breakpoint, breakpointActions } = this.props;
|
||||
const { breakpoint, breakpointActions } = this.props;
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
showMenu(event, breakpointItems(cx, breakpoint, breakpointActions));
|
||||
showMenu(event, breakpointItems(breakpoint, breakpointActions));
|
||||
};
|
||||
|
||||
addBreakpoint(props: Props) {
|
||||
|
@ -14,14 +14,9 @@ import { editorItemActions } from "./menus/editor";
|
||||
|
||||
import type { BreakpointItemActions } from "./menus/breakpoints";
|
||||
import type { EditorItemActions } from "./menus/editor";
|
||||
import type {
|
||||
Breakpoint as BreakpointType,
|
||||
Source,
|
||||
ThreadContext
|
||||
} from "../../types";
|
||||
import type { Breakpoint as BreakpointType, Source } from "../../types";
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
selectedSource: Source,
|
||||
breakpoints: BreakpointType[],
|
||||
editor: Object,
|
||||
@ -32,7 +27,6 @@ type Props = {
|
||||
class Breakpoints extends Component<Props> {
|
||||
render() {
|
||||
const {
|
||||
cx,
|
||||
breakpoints,
|
||||
selectedSource,
|
||||
editor,
|
||||
@ -49,7 +43,6 @@ class Breakpoints extends Component<Props> {
|
||||
{breakpoints.map(bp => {
|
||||
return (
|
||||
<Breakpoint
|
||||
cx={cx}
|
||||
key={makeBreakpointId(bp.location)}
|
||||
breakpoint={bp}
|
||||
selectedSource={selectedSource}
|
||||
|
@ -14,14 +14,13 @@ import { breakpointItems, createBreakpointItems } from "./menus/breakpoints";
|
||||
// eslint-disable-next-line max-len
|
||||
import type { ColumnBreakpoint as ColumnBreakpointType } from "../../selectors/visibleColumnBreakpoints";
|
||||
import type { BreakpointItemActions } from "./menus/breakpoints";
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
|
||||
type Bookmark = {
|
||||
clear: Function
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
editor: Object,
|
||||
source: Source,
|
||||
columnBreakpoint: ColumnBreakpointType,
|
||||
@ -89,11 +88,11 @@ export default class ColumnBreakpoint extends PureComponent<Props> {
|
||||
onClick = (event: MouseEvent) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
const { cx, columnBreakpoint, breakpointActions } = this.props;
|
||||
const { columnBreakpoint, breakpointActions } = this.props;
|
||||
if (columnBreakpoint.breakpoint) {
|
||||
breakpointActions.removeBreakpoint(cx, columnBreakpoint.breakpoint);
|
||||
breakpointActions.removeBreakpoint(columnBreakpoint.breakpoint);
|
||||
} else {
|
||||
breakpointActions.addBreakpoint(cx, columnBreakpoint.location);
|
||||
breakpointActions.addBreakpoint(columnBreakpoint.location);
|
||||
}
|
||||
};
|
||||
|
||||
@ -101,14 +100,13 @@ export default class ColumnBreakpoint extends PureComponent<Props> {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
const {
|
||||
cx,
|
||||
columnBreakpoint: { breakpoint, location },
|
||||
breakpointActions
|
||||
} = this.props;
|
||||
|
||||
const items = breakpoint
|
||||
? breakpointItems(cx, breakpoint, breakpointActions)
|
||||
: createBreakpointItems(cx, location, breakpointActions);
|
||||
? breakpointItems(breakpoint, breakpointActions)
|
||||
: createBreakpointItems(location, breakpointActions);
|
||||
|
||||
showMenu(event, items);
|
||||
};
|
||||
|
@ -8,22 +8,17 @@ import React, { Component } from "react";
|
||||
|
||||
import ColumnBreakpoint from "./ColumnBreakpoint";
|
||||
|
||||
import {
|
||||
getSelectedSource,
|
||||
visibleColumnBreakpoints,
|
||||
getContext
|
||||
} from "../../selectors";
|
||||
import { getSelectedSource, visibleColumnBreakpoints } from "../../selectors";
|
||||
import { connect } from "../../utils/connect";
|
||||
import { makeBreakpointId } from "../../utils/breakpoint";
|
||||
import { breakpointItemActions } from "./menus/breakpoints";
|
||||
import type { BreakpointItemActions } from "./menus/breakpoints";
|
||||
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
// eslint-disable-next-line max-len
|
||||
import type { ColumnBreakpoint as ColumnBreakpointType } from "../../selectors/visibleColumnBreakpoints";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
editor: Object,
|
||||
selectedSource: Source,
|
||||
columnBreakpoints: ColumnBreakpointType[],
|
||||
@ -35,7 +30,6 @@ class ColumnBreakpoints extends Component<Props> {
|
||||
|
||||
render() {
|
||||
const {
|
||||
cx,
|
||||
editor,
|
||||
columnBreakpoints,
|
||||
selectedSource,
|
||||
@ -50,7 +44,6 @@ class ColumnBreakpoints extends Component<Props> {
|
||||
editor.codeMirror.operation(() => {
|
||||
breakpoints = columnBreakpoints.map(breakpoint => (
|
||||
<ColumnBreakpoint
|
||||
cx={cx}
|
||||
key={makeBreakpointId(breakpoint.location)}
|
||||
columnBreakpoint={breakpoint}
|
||||
editor={editor}
|
||||
@ -65,7 +58,6 @@ class ColumnBreakpoints extends Component<Props> {
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
cx: getContext(state),
|
||||
selectedSource: getSelectedSource(state),
|
||||
columnBreakpoints: visibleColumnBreakpoints(state)
|
||||
};
|
||||
|
@ -14,16 +14,14 @@ import actions from "../../actions";
|
||||
import {
|
||||
getBreakpointForLocation,
|
||||
getConditionalPanelLocation,
|
||||
getLogPointStatus,
|
||||
getContext
|
||||
getLogPointStatus
|
||||
} from "../../selectors";
|
||||
|
||||
import type { SourceLocation, Context } from "../../types";
|
||||
import type { SourceLocation } from "../../types";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
breakpoint: ?Object,
|
||||
setBreakpointOptions: typeof actions.setBreakpointOptions,
|
||||
setBreakpointOptions: Function,
|
||||
location: SourceLocation,
|
||||
log: boolean,
|
||||
editor: Object,
|
||||
@ -65,10 +63,10 @@ export class ConditionalPanel extends PureComponent<Props> {
|
||||
};
|
||||
|
||||
setBreakpoint(value: string) {
|
||||
const { cx, location, log, breakpoint } = this.props;
|
||||
const { location, log, breakpoint } = this.props;
|
||||
const options = breakpoint ? breakpoint.options : {};
|
||||
const type = log ? "logValue" : "condition";
|
||||
return this.props.setBreakpointOptions(cx, location, {
|
||||
return this.props.setBreakpointOptions(location, {
|
||||
...options,
|
||||
[type]: value
|
||||
});
|
||||
@ -201,7 +199,6 @@ const mapStateToProps = state => {
|
||||
const location = getConditionalPanelLocation(state);
|
||||
const log = getLogPointStatus(state);
|
||||
return {
|
||||
cx: getContext(state),
|
||||
breakpoint: getBreakpointForLocation(state, location),
|
||||
location,
|
||||
log
|
||||
|
@ -12,18 +12,16 @@ import { getSourceLocationFromMouseEvent } from "../../utils/editor";
|
||||
import {
|
||||
getPrettySource,
|
||||
getIsPaused,
|
||||
getCurrentThread,
|
||||
getThreadContext
|
||||
getCurrentThread
|
||||
} from "../../selectors";
|
||||
|
||||
import { editorMenuItems, editorItemActions } from "./menus/editor";
|
||||
|
||||
import type { Source, ThreadContext } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
import type { EditorItemActions } from "./menus/editor";
|
||||
import type SourceEditor from "../../utils/editor/source-editor";
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
contextMenu: ?MouseEvent,
|
||||
editorActions: EditorItemActions,
|
||||
clearContextMenu: () => void,
|
||||
@ -45,7 +43,6 @@ class EditorMenu extends Component<Props> {
|
||||
|
||||
showMenu(props) {
|
||||
const {
|
||||
cx,
|
||||
editor,
|
||||
selectedSource,
|
||||
editorActions,
|
||||
@ -64,7 +61,6 @@ class EditorMenu extends Component<Props> {
|
||||
showMenu(
|
||||
event,
|
||||
editorMenuItems({
|
||||
cx,
|
||||
editorActions,
|
||||
selectedSource,
|
||||
hasPrettySource,
|
||||
@ -82,7 +78,6 @@ class EditorMenu extends Component<Props> {
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, props) => ({
|
||||
cx: getThreadContext(state),
|
||||
isPaused: getIsPaused(state, getCurrentThread(state)),
|
||||
hasPrettySource: !!getPrettySource(state, props.selectedSource.id)
|
||||
});
|
||||
|
@ -10,8 +10,7 @@ import actions from "../../actions";
|
||||
import {
|
||||
getSelectedSource,
|
||||
getPrettySource,
|
||||
getPaneCollapse,
|
||||
getContext
|
||||
getPaneCollapse
|
||||
} from "../../selectors";
|
||||
|
||||
import {
|
||||
@ -28,7 +27,7 @@ import { shouldShowPrettyPrint } from "../../utils/editor";
|
||||
import { PaneToggleButton } from "../shared/Button";
|
||||
import AccessibleImage from "../shared/AccessibleImage";
|
||||
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
|
||||
import "./Footer.css";
|
||||
|
||||
@ -38,7 +37,6 @@ type CursorPosition = {
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
selectedSource: Source,
|
||||
mappedSource: Source,
|
||||
endPanelCollapsed: boolean,
|
||||
@ -85,7 +83,7 @@ class SourceFooter extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
prettyPrintButton() {
|
||||
const { cx, selectedSource, togglePrettyPrint } = this.props;
|
||||
const { selectedSource, togglePrettyPrint } = this.props;
|
||||
|
||||
if (!selectedSource) {
|
||||
return;
|
||||
@ -109,7 +107,7 @@ class SourceFooter extends PureComponent<Props, State> {
|
||||
const type = "prettyPrint";
|
||||
return (
|
||||
<button
|
||||
onClick={() => togglePrettyPrint(cx, selectedSource.id)}
|
||||
onClick={() => togglePrettyPrint(selectedSource.id)}
|
||||
className={classnames("action", type, {
|
||||
active: sourceLoaded,
|
||||
pretty: isPretty(selectedSource)
|
||||
@ -124,7 +122,7 @@ class SourceFooter extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
blackBoxButton() {
|
||||
const { cx, selectedSource, toggleBlackBox } = this.props;
|
||||
const { selectedSource, toggleBlackBox } = this.props;
|
||||
const sourceLoaded = selectedSource && isLoaded(selectedSource);
|
||||
|
||||
if (!selectedSource) {
|
||||
@ -145,7 +143,7 @@ class SourceFooter extends PureComponent<Props, State> {
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() => toggleBlackBox(cx, selectedSource)}
|
||||
onClick={() => toggleBlackBox(selectedSource)}
|
||||
className={classnames("action", type, {
|
||||
active: sourceLoaded,
|
||||
blackboxed: blackboxed
|
||||
@ -184,12 +182,7 @@ class SourceFooter extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
renderSourceSummary() {
|
||||
const {
|
||||
cx,
|
||||
mappedSource,
|
||||
jumpToMappedLocation,
|
||||
selectedSource
|
||||
} = this.props;
|
||||
const { mappedSource, jumpToMappedLocation, selectedSource } = this.props;
|
||||
|
||||
if (!mappedSource || !isOriginal(selectedSource)) {
|
||||
return null;
|
||||
@ -209,7 +202,7 @@ class SourceFooter extends PureComponent<Props, State> {
|
||||
return (
|
||||
<button
|
||||
className="mapped-source"
|
||||
onClick={() => jumpToMappedLocation(cx, mappedSourceLocation)}
|
||||
onClick={() => jumpToMappedLocation(mappedSourceLocation)}
|
||||
title={tooltip}
|
||||
>
|
||||
<span>{title}</span>
|
||||
@ -262,7 +255,6 @@ const mapStateToProps = state => {
|
||||
const selectedSource = getSelectedSource(state);
|
||||
|
||||
return {
|
||||
cx: getContext(state),
|
||||
selectedSource,
|
||||
mappedSource: getGeneratedSource(state, selectedSource),
|
||||
prettySource: getPrettySource(
|
||||
|
@ -24,8 +24,7 @@ const {
|
||||
import actions from "../../../actions";
|
||||
import {
|
||||
getAllPopupObjectProperties,
|
||||
getCurrentThread,
|
||||
getThreadContext
|
||||
getCurrentThread
|
||||
} from "../../../selectors";
|
||||
import Popover from "../../shared/Popover";
|
||||
import PreviewFunction from "../../shared/PreviewFunction";
|
||||
@ -37,11 +36,9 @@ import "./Popup.css";
|
||||
|
||||
import type { EditorRange } from "../../../utils/editor/types";
|
||||
import type { Coords } from "../../shared/Popover";
|
||||
import type { ThreadContext } from "../../../types";
|
||||
|
||||
type PopupValue = Object | null;
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
popupObjectProperties: Object,
|
||||
popoverPos: Object,
|
||||
value: PopupValue,
|
||||
@ -93,7 +90,6 @@ export class Popup extends Component<Props, State> {
|
||||
|
||||
async componentWillMount() {
|
||||
const {
|
||||
cx,
|
||||
value,
|
||||
setPopupObjectProperties,
|
||||
popupObjectProperties
|
||||
@ -110,7 +106,7 @@ export class Popup extends Component<Props, State> {
|
||||
const onLoadItemProperties = loadItemProperties(root, createObjectClient);
|
||||
if (onLoadItemProperties !== null) {
|
||||
const properties = await onLoadItemProperties;
|
||||
setPopupObjectProperties(cx, root.contents.value, properties);
|
||||
setPopupObjectProperties(root.contents.value, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,7 +179,7 @@ export class Popup extends Component<Props, State> {
|
||||
};
|
||||
|
||||
renderFunctionPreview() {
|
||||
const { cx, selectSourceURL, value } = this.props;
|
||||
const { selectSourceURL, value } = this.props;
|
||||
|
||||
if (!value) {
|
||||
return null;
|
||||
@ -193,9 +189,7 @@ export class Popup extends Component<Props, State> {
|
||||
return (
|
||||
<div
|
||||
className="preview-popup"
|
||||
onClick={() =>
|
||||
selectSourceURL(cx, location.url, { line: location.line })
|
||||
}
|
||||
onClick={() => selectSourceURL(location.url, { line: location.line })}
|
||||
>
|
||||
<PreviewFunction func={value} />
|
||||
</div>
|
||||
@ -327,7 +321,6 @@ export class Popup extends Component<Props, State> {
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getThreadContext(state),
|
||||
popupObjectProperties: getAllPopupObjectProperties(
|
||||
state,
|
||||
getCurrentThread(state)
|
||||
|
@ -12,21 +12,22 @@ import Popup from "./Popup";
|
||||
import {
|
||||
getPreview,
|
||||
getSelectedSource,
|
||||
getThreadContext
|
||||
getIsPaused,
|
||||
getCurrentThread
|
||||
} from "../../../selectors";
|
||||
import actions from "../../../actions";
|
||||
import { toEditorRange } from "../../../utils/editor";
|
||||
|
||||
import type { Source, ThreadContext } from "../../../types";
|
||||
import type { Source } from "../../../types";
|
||||
|
||||
import type { Preview as PreviewType } from "../../../reducers/ast";
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
editor: any,
|
||||
editorRef: ?HTMLDivElement,
|
||||
selectedSource: Source,
|
||||
preview: PreviewType,
|
||||
isPaused: boolean,
|
||||
clearPreview: typeof actions.clearPreview,
|
||||
setPopupObjectProperties: typeof actions.setPopupObjectProperties,
|
||||
addExpression: typeof actions.addExpression,
|
||||
@ -112,41 +113,40 @@ class Preview extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
onTokenEnter = ({ target, tokenPos }) => {
|
||||
const { cx, updatePreview, editor } = this.props;
|
||||
if (cx.isPaused) {
|
||||
updatePreview(cx, target, tokenPos, editor.codeMirror);
|
||||
if (this.props.isPaused) {
|
||||
this.props.updatePreview(target, tokenPos, this.props.editor.codeMirror);
|
||||
}
|
||||
};
|
||||
|
||||
onTokenLeave = e => {
|
||||
if (this.props.cx.isPaused && !inPopup(e)) {
|
||||
this.props.clearPreview(this.props.cx);
|
||||
if (this.props.isPaused && !inPopup(e)) {
|
||||
this.props.clearPreview();
|
||||
}
|
||||
};
|
||||
|
||||
onMouseUp = () => {
|
||||
if (this.props.cx.isPaused) {
|
||||
if (this.props.isPaused) {
|
||||
this.setState({ selecting: false });
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
onMouseDown = () => {
|
||||
if (this.props.cx.isPaused) {
|
||||
if (this.props.isPaused) {
|
||||
this.setState({ selecting: true });
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
onScroll = () => {
|
||||
if (this.props.cx.isPaused) {
|
||||
this.props.clearPreview(this.props.cx);
|
||||
if (this.props.isPaused) {
|
||||
this.props.clearPreview();
|
||||
}
|
||||
};
|
||||
|
||||
onClose = e => {
|
||||
if (this.props.cx.isPaused) {
|
||||
this.props.clearPreview(this.props.cx);
|
||||
if (this.props.isPaused) {
|
||||
this.props.clearPreview();
|
||||
}
|
||||
};
|
||||
|
||||
@ -183,8 +183,8 @@ class Preview extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getThreadContext(state),
|
||||
preview: getPreview(state),
|
||||
isPaused: getIsPaused(state, getCurrentThread(state)),
|
||||
selectedSource: getSelectedSource(state)
|
||||
});
|
||||
|
||||
|
@ -17,8 +17,7 @@ import {
|
||||
getFileSearchQuery,
|
||||
getFileSearchModifiers,
|
||||
getFileSearchResults,
|
||||
getHighlightedLineRange,
|
||||
getContext
|
||||
getHighlightedLineRange
|
||||
} from "../../selectors";
|
||||
|
||||
import { removeOverlay } from "../../utils/editor";
|
||||
@ -26,7 +25,7 @@ import { removeOverlay } from "../../utils/editor";
|
||||
import { scrollList } from "../../utils/result-list";
|
||||
import classnames from "classnames";
|
||||
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
import type { Modifiers, SearchResults } from "../../reducers/file-search";
|
||||
|
||||
import SearchInput from "../shared/SearchInput";
|
||||
@ -56,7 +55,6 @@ type State = {
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
editor: SourceEditor,
|
||||
selectedSource?: Source,
|
||||
searchOn: boolean,
|
||||
@ -139,10 +137,10 @@ class SearchBar extends Component<Props, State> {
|
||||
};
|
||||
|
||||
closeSearch = (e: SyntheticEvent<HTMLElement>) => {
|
||||
const { cx, closeFileSearch, editor, searchOn } = this.props;
|
||||
const { closeFileSearch, editor, searchOn } = this.props;
|
||||
if (editor && searchOn) {
|
||||
this.clearSearch();
|
||||
closeFileSearch(cx, editor);
|
||||
closeFileSearch(editor);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
@ -171,12 +169,12 @@ class SearchBar extends Component<Props, State> {
|
||||
};
|
||||
|
||||
doSearch = (query: string) => {
|
||||
const { cx, selectedSource } = this.props;
|
||||
const { selectedSource } = this.props;
|
||||
if (!selectedSource || !selectedSource.text) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.doSearch(cx, query, this.props.editor);
|
||||
this.props.doSearch(query, this.props.editor);
|
||||
};
|
||||
|
||||
traverseResults = (e: SyntheticEvent<HTMLElement>, rev: boolean) => {
|
||||
@ -187,7 +185,7 @@ class SearchBar extends Component<Props, State> {
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
this.props.traverseResults(this.props.cx, rev, editor);
|
||||
this.props.traverseResults(rev, editor);
|
||||
};
|
||||
|
||||
// Handlers
|
||||
@ -244,7 +242,7 @@ class SearchBar extends Component<Props, State> {
|
||||
}
|
||||
|
||||
renderSearchModifiers = () => {
|
||||
const { cx, modifiers, toggleFileSearchModifier, query } = this.props;
|
||||
const { modifiers, toggleFileSearchModifier, query } = this.props;
|
||||
const { doSearch } = this;
|
||||
|
||||
function SearchModBtn({ modVal, className, svgName, tooltip }) {
|
||||
@ -255,12 +253,12 @@ class SearchBar extends Component<Props, State> {
|
||||
<button
|
||||
className={preppedClass}
|
||||
onMouseDown={() => {
|
||||
toggleFileSearchModifier(cx, modVal);
|
||||
toggleFileSearchModifier(modVal);
|
||||
doSearch(query);
|
||||
}}
|
||||
onKeyDown={(e: any) => {
|
||||
if (e.key === "Enter") {
|
||||
toggleFileSearchModifier(cx, modVal);
|
||||
toggleFileSearchModifier(modVal);
|
||||
doSearch(query);
|
||||
}
|
||||
}}
|
||||
@ -359,7 +357,6 @@ SearchBar.contextTypes = {
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getContext(state),
|
||||
searchOn: getActiveSearch(state) === "file",
|
||||
selectedSource: getSelectedSource(state),
|
||||
selectedLocation: getSelectedLocation(state),
|
||||
|
@ -13,7 +13,7 @@ import SourceIcon from "../shared/SourceIcon";
|
||||
import { CloseButton } from "../shared/Button";
|
||||
|
||||
import type { List } from "immutable";
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
|
||||
import actions from "../../actions";
|
||||
|
||||
@ -33,8 +33,7 @@ import {
|
||||
getSelectedSource,
|
||||
getActiveSearch,
|
||||
getSourcesForTabs,
|
||||
getHasSiblingOfSameName,
|
||||
getContext
|
||||
getHasSiblingOfSameName
|
||||
} from "../../selectors";
|
||||
import type { ActiveSearchType } from "../../selectors";
|
||||
|
||||
@ -43,7 +42,6 @@ import classnames from "classnames";
|
||||
type SourcesList = List<Source>;
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
tabSources: SourcesList,
|
||||
selectedSource: Source,
|
||||
source: Source,
|
||||
@ -65,7 +63,6 @@ class Tab extends PureComponent<Props> {
|
||||
|
||||
showContextMenu(e, tab: string) {
|
||||
const {
|
||||
cx,
|
||||
closeTab,
|
||||
closeTabs,
|
||||
tabSources,
|
||||
@ -91,13 +88,13 @@ class Tab extends PureComponent<Props> {
|
||||
{
|
||||
item: {
|
||||
...tabMenuItems.closeTab,
|
||||
click: () => closeTab(cx, sourceTab)
|
||||
click: () => closeTab(sourceTab)
|
||||
}
|
||||
},
|
||||
{
|
||||
item: {
|
||||
...tabMenuItems.closeOtherTabs,
|
||||
click: () => closeTabs(cx, otherTabURLs),
|
||||
click: () => closeTabs(otherTabURLs),
|
||||
disabled: otherTabURLs.length === 0
|
||||
}
|
||||
},
|
||||
@ -106,7 +103,7 @@ class Tab extends PureComponent<Props> {
|
||||
...tabMenuItems.closeTabsToEnd,
|
||||
click: () => {
|
||||
const tabIndex = tabSources.findIndex(t => t.id == tab);
|
||||
closeTabs(cx, tabURLs.filter((t, i) => i > tabIndex));
|
||||
closeTabs(tabURLs.filter((t, i) => i > tabIndex));
|
||||
},
|
||||
disabled:
|
||||
tabCount === 1 ||
|
||||
@ -114,10 +111,7 @@ class Tab extends PureComponent<Props> {
|
||||
}
|
||||
},
|
||||
{
|
||||
item: {
|
||||
...tabMenuItems.closeAllTabs,
|
||||
click: () => closeTabs(cx, tabURLs)
|
||||
}
|
||||
item: { ...tabMenuItems.closeAllTabs, click: () => closeTabs(tabURLs) }
|
||||
},
|
||||
{ item: { type: "separator" } },
|
||||
{
|
||||
@ -138,7 +132,7 @@ class Tab extends PureComponent<Props> {
|
||||
item: {
|
||||
...tabMenuItems.showSource,
|
||||
disabled: !selectedSource.url,
|
||||
click: () => showSource(cx, tab)
|
||||
click: () => showSource(tab)
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -148,13 +142,13 @@ class Tab extends PureComponent<Props> {
|
||||
? L10N.getStr("sourceFooter.unblackbox")
|
||||
: L10N.getStr("sourceFooter.blackbox"),
|
||||
disabled: !shouldBlackbox(source),
|
||||
click: () => toggleBlackBox(cx, source)
|
||||
click: () => toggleBlackBox(source)
|
||||
}
|
||||
},
|
||||
{
|
||||
item: {
|
||||
...tabMenuItems.prettyPrint,
|
||||
click: () => togglePrettyPrint(cx, tab),
|
||||
click: () => togglePrettyPrint(tab),
|
||||
disabled: isPretty(sourceTab)
|
||||
}
|
||||
}
|
||||
@ -173,7 +167,6 @@ class Tab extends PureComponent<Props> {
|
||||
|
||||
render() {
|
||||
const {
|
||||
cx,
|
||||
selectedSource,
|
||||
selectSource,
|
||||
closeTab,
|
||||
@ -190,13 +183,13 @@ class Tab extends PureComponent<Props> {
|
||||
|
||||
function onClickClose(e) {
|
||||
e.stopPropagation();
|
||||
closeTab(cx, source);
|
||||
closeTab(source);
|
||||
}
|
||||
|
||||
function handleTabClick(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return selectSource(cx, sourceId);
|
||||
return selectSource(sourceId);
|
||||
}
|
||||
|
||||
const className = classnames("source-tab", {
|
||||
@ -213,7 +206,7 @@ class Tab extends PureComponent<Props> {
|
||||
key={sourceId}
|
||||
onClick={handleTabClick}
|
||||
// Accommodate middle click to close tab
|
||||
onMouseUp={e => e.button === 1 && closeTab(cx, source)}
|
||||
onMouseUp={e => e.button === 1 && closeTab(source)}
|
||||
onContextMenu={e => this.onTabContextMenu(e, sourceId)}
|
||||
title={getFileURL(source, false)}
|
||||
>
|
||||
@ -238,7 +231,6 @@ const mapStateToProps = (state, { source }) => {
|
||||
const selectedSource = getSelectedSource(state);
|
||||
|
||||
return {
|
||||
cx: getContext(state),
|
||||
tabSources: getSourcesForTabs(state),
|
||||
selectedSource: selectedSource,
|
||||
activeSearch: getActiveSearch(state),
|
||||
|
@ -11,8 +11,7 @@ import {
|
||||
getSelectedSource,
|
||||
getSourcesForTabs,
|
||||
getIsPaused,
|
||||
getCurrentThread,
|
||||
getContext
|
||||
getCurrentThread
|
||||
} from "../../selectors";
|
||||
import { isVisible } from "../../utils/ui";
|
||||
|
||||
@ -29,12 +28,11 @@ import Dropdown from "../shared/Dropdown";
|
||||
import AccessibleImage from "../shared/AccessibleImage";
|
||||
import CommandBar from "../SecondaryPanes/CommandBar";
|
||||
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
|
||||
type SourcesList = Source[];
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
tabSources: SourcesList,
|
||||
selectedSource: ?Source,
|
||||
horizontal: boolean,
|
||||
@ -138,10 +136,10 @@ class Tabs extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
renderDropdownSource = (source: Source) => {
|
||||
const { cx, selectSource } = this.props;
|
||||
const { selectSource } = this.props;
|
||||
const filename = getFilename(source);
|
||||
|
||||
const onClick = () => selectSource(cx, source.id);
|
||||
const onClick = () => selectSource(source.id);
|
||||
return (
|
||||
<li key={source.id} onClick={onClick}>
|
||||
<AccessibleImage
|
||||
@ -228,7 +226,6 @@ class Tabs extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getContext(state),
|
||||
selectedSource: getSelectedSource(state),
|
||||
tabSources: getSourcesForTabs(state),
|
||||
isPaused: getIsPaused(state, getCurrentThread(state))
|
||||
|
@ -35,8 +35,7 @@ import {
|
||||
getConditionalPanelLocation,
|
||||
getSymbols,
|
||||
getIsPaused,
|
||||
getCurrentThread,
|
||||
getThreadContext
|
||||
getCurrentThread
|
||||
} from "../../selectors";
|
||||
|
||||
// Redux actions
|
||||
@ -81,14 +80,13 @@ import "./Highlight.css";
|
||||
|
||||
import type SourceEditor from "../../utils/editor/source-editor";
|
||||
import type { SymbolDeclarations } from "../../workers/parser";
|
||||
import type { SourceLocation, Source, ThreadContext } from "../../types";
|
||||
import type { SourceLocation, Source } from "../../types";
|
||||
|
||||
const cssVars = {
|
||||
searchbarHeight: "var(--editor-searchbar-height)"
|
||||
};
|
||||
|
||||
export type Props = {
|
||||
cx: ThreadContext,
|
||||
selectedLocation: ?SourceLocation,
|
||||
selectedSource: ?Source,
|
||||
searchOn: boolean,
|
||||
@ -233,11 +231,11 @@ class Editor extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
onClosePress = (key, e: KeyboardEvent) => {
|
||||
const { cx, selectedSource } = this.props;
|
||||
const { selectedSource } = this.props;
|
||||
if (selectedSource) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.props.closeTab(cx, selectedSource);
|
||||
this.props.closeTab(selectedSource);
|
||||
}
|
||||
};
|
||||
|
||||
@ -301,7 +299,7 @@ class Editor extends PureComponent<Props, State> {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.toggleBreakpointAtLine(this.props.cx, line);
|
||||
this.props.toggleBreakpointAtLine(line);
|
||||
};
|
||||
|
||||
onToggleConditionalPanel = (key, e: KeyboardEvent) => {
|
||||
@ -355,7 +353,7 @@ class Editor extends PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
onSearchAgain = (_, e: KeyboardEvent) => {
|
||||
this.props.traverseResults(this.props.cx, e.shiftKey, this.state.editor);
|
||||
this.props.traverseResults(e.shiftKey, this.state.editor);
|
||||
};
|
||||
|
||||
openMenu(event: MouseEvent) {
|
||||
@ -363,7 +361,6 @@ class Editor extends PureComponent<Props, State> {
|
||||
event.preventDefault();
|
||||
|
||||
const {
|
||||
cx,
|
||||
selectedSource,
|
||||
breakpointActions,
|
||||
editorActions,
|
||||
@ -386,9 +383,9 @@ class Editor extends PureComponent<Props, State> {
|
||||
|
||||
if (target.classList.contains("CodeMirror-linenumber")) {
|
||||
return showMenu(event, [
|
||||
...createBreakpointItems(cx, location, breakpointActions),
|
||||
...createBreakpointItems(location, breakpointActions),
|
||||
{ type: "separator" },
|
||||
continueToHereItem(cx, location, isPaused, editorActions)
|
||||
continueToHereItem(location, isPaused, editorActions)
|
||||
]);
|
||||
}
|
||||
|
||||
@ -410,7 +407,6 @@ class Editor extends PureComponent<Props, State> {
|
||||
ev: MouseEvent
|
||||
) => {
|
||||
const {
|
||||
cx,
|
||||
selectedSource,
|
||||
conditionalPanelLocation,
|
||||
closeConditionalPanel,
|
||||
@ -442,10 +438,10 @@ class Editor extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
if (ev.metaKey) {
|
||||
return continueToHere(cx, sourceLine);
|
||||
return continueToHere(sourceLine);
|
||||
}
|
||||
|
||||
return addBreakpointAtLine(cx, sourceLine);
|
||||
return addBreakpointAtLine(sourceLine);
|
||||
};
|
||||
|
||||
onGutterContextMenu = (event: MouseEvent) => {
|
||||
@ -453,7 +449,7 @@ class Editor extends PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
onClick(e: MouseEvent) {
|
||||
const { cx, selectedSource, jumpToMappedLocation } = this.props;
|
||||
const { selectedSource, jumpToMappedLocation } = this.props;
|
||||
|
||||
if (selectedSource && e.metaKey && e.altKey) {
|
||||
const sourceLocation = getSourceLocationFromMouseEvent(
|
||||
@ -461,7 +457,7 @@ class Editor extends PureComponent<Props, State> {
|
||||
selectedSource,
|
||||
e
|
||||
);
|
||||
jumpToMappedLocation(cx, sourceLocation);
|
||||
jumpToMappedLocation(sourceLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -601,7 +597,7 @@ class Editor extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
renderItems() {
|
||||
const { cx, selectedSource, conditionalPanelLocation } = this.props;
|
||||
const { selectedSource, conditionalPanelLocation } = this.props;
|
||||
const { editor, contextMenu } = this.state;
|
||||
|
||||
if (!selectedSource || !editor || !getDocument(selectedSource.id)) {
|
||||
@ -613,7 +609,7 @@ class Editor extends PureComponent<Props, State> {
|
||||
<DebugLine editor={editor} />
|
||||
<HighlightLine />
|
||||
<EmptyLines editor={editor} />
|
||||
<Breakpoints editor={editor} cx={cx} />
|
||||
<Breakpoints editor={editor} />
|
||||
<Preview editor={editor} editorRef={this.$editorWrapper} />
|
||||
<HighlightLines editor={editor} />
|
||||
{
|
||||
@ -670,7 +666,6 @@ const mapStateToProps = state => {
|
||||
const selectedSource = getSelectedSource(state);
|
||||
|
||||
return {
|
||||
cx: getThreadContext(state),
|
||||
selectedLocation: getSelectedLocation(state),
|
||||
selectedSource,
|
||||
searchOn: getActiveSearch(state) === "file",
|
||||
|
@ -6,11 +6,10 @@
|
||||
|
||||
import actions from "../../../actions";
|
||||
import { bindActionCreators } from "redux";
|
||||
import type { SourceLocation, Breakpoint, Context } from "../../../types";
|
||||
import type { SourceLocation, Breakpoint } from "../../../types";
|
||||
import { features } from "../../../utils/prefs";
|
||||
|
||||
export const addBreakpointItem = (
|
||||
cx: Context,
|
||||
location: SourceLocation,
|
||||
breakpointActions: BreakpointItemActions
|
||||
) => ({
|
||||
@ -18,12 +17,11 @@ export const addBreakpointItem = (
|
||||
label: L10N.getStr("editor.addBreakpoint"),
|
||||
accesskey: L10N.getStr("shortcuts.toggleBreakpoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => breakpointActions.addBreakpoint(cx, location),
|
||||
click: () => breakpointActions.addBreakpoint(location),
|
||||
accelerator: L10N.getStr("toggleBreakpoint.key")
|
||||
});
|
||||
|
||||
export const removeBreakpointItem = (
|
||||
cx: Context,
|
||||
breakpoint: Breakpoint,
|
||||
breakpointActions: BreakpointItemActions
|
||||
) => ({
|
||||
@ -31,7 +29,7 @@ export const removeBreakpointItem = (
|
||||
label: L10N.getStr("editor.removeBreakpoint"),
|
||||
accesskey: L10N.getStr("shortcuts.toggleBreakpoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => breakpointActions.removeBreakpoint(cx, breakpoint),
|
||||
click: () => breakpointActions.removeBreakpoint(breakpoint),
|
||||
accelerator: L10N.getStr("toggleBreakpoint.key")
|
||||
});
|
||||
|
||||
@ -110,14 +108,13 @@ export const logPointItem = (
|
||||
};
|
||||
|
||||
export const toggleDisabledBreakpointItem = (
|
||||
cx: Context,
|
||||
breakpoint: Breakpoint,
|
||||
breakpointActions: BreakpointItemActions
|
||||
) => {
|
||||
return {
|
||||
accesskey: L10N.getStr("editor.disableBreakpoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => breakpointActions.toggleDisabledBreakpoint(cx, breakpoint),
|
||||
click: () => breakpointActions.toggleDisabledBreakpoint(breakpoint),
|
||||
...(breakpoint.disabled
|
||||
? {
|
||||
id: "node-menu-enable-breakpoint",
|
||||
@ -131,30 +128,21 @@ export const toggleDisabledBreakpointItem = (
|
||||
};
|
||||
|
||||
export function breakpointItems(
|
||||
cx: Context,
|
||||
breakpoint: Breakpoint,
|
||||
breakpointActions: BreakpointItemActions
|
||||
) {
|
||||
const items = [
|
||||
removeBreakpointItem(cx, breakpoint, breakpointActions),
|
||||
toggleDisabledBreakpointItem(cx, breakpoint, breakpointActions)
|
||||
removeBreakpointItem(breakpoint, breakpointActions),
|
||||
toggleDisabledBreakpointItem(breakpoint, breakpointActions)
|
||||
];
|
||||
|
||||
if (features.columnBreakpoints) {
|
||||
items.push(
|
||||
{ type: "separator" },
|
||||
removeBreakpointsOnLineItem(cx, breakpoint.location, breakpointActions),
|
||||
removeBreakpointsOnLineItem(breakpoint.location, breakpointActions),
|
||||
breakpoint.disabled
|
||||
? enableBreakpointsOnLineItem(
|
||||
cx,
|
||||
breakpoint.location,
|
||||
breakpointActions
|
||||
)
|
||||
: disableBreakpointsOnLineItem(
|
||||
cx,
|
||||
breakpoint.location,
|
||||
breakpointActions
|
||||
),
|
||||
? enableBreakpointsOnLineItem(breakpoint.location, breakpointActions)
|
||||
: disableBreakpointsOnLineItem(breakpoint.location, breakpointActions),
|
||||
{ type: "separator" }
|
||||
);
|
||||
}
|
||||
@ -169,12 +157,11 @@ export function breakpointItems(
|
||||
}
|
||||
|
||||
export function createBreakpointItems(
|
||||
cx: Context,
|
||||
location: SourceLocation,
|
||||
breakpointActions: BreakpointItemActions
|
||||
) {
|
||||
const items = [
|
||||
addBreakpointItem(cx, location, breakpointActions),
|
||||
addBreakpointItem(location, breakpointActions),
|
||||
addConditionalBreakpointItem(location, breakpointActions)
|
||||
];
|
||||
|
||||
@ -186,7 +173,6 @@ export function createBreakpointItems(
|
||||
|
||||
// ToDo: Only enable if there are more than one breakpoints on a line?
|
||||
export const removeBreakpointsOnLineItem = (
|
||||
cx: Context,
|
||||
location: SourceLocation,
|
||||
breakpointActions: BreakpointItemActions
|
||||
) => ({
|
||||
@ -195,15 +181,10 @@ export const removeBreakpointsOnLineItem = (
|
||||
accesskey: L10N.getStr("breakpointMenuItem.removeAllAtLine.accesskey"),
|
||||
disabled: false,
|
||||
click: () =>
|
||||
breakpointActions.removeBreakpointsAtLine(
|
||||
cx,
|
||||
location.sourceId,
|
||||
location.line
|
||||
)
|
||||
breakpointActions.removeBreakpointsAtLine(location.sourceId, location.line)
|
||||
});
|
||||
|
||||
export const enableBreakpointsOnLineItem = (
|
||||
cx: Context,
|
||||
location: SourceLocation,
|
||||
breakpointActions: BreakpointItemActions
|
||||
) => ({
|
||||
@ -212,15 +193,10 @@ export const enableBreakpointsOnLineItem = (
|
||||
accesskey: L10N.getStr("breakpointMenuItem.enableAllAtLine.accesskey"),
|
||||
disabled: false,
|
||||
click: () =>
|
||||
breakpointActions.enableBreakpointsAtLine(
|
||||
cx,
|
||||
location.sourceId,
|
||||
location.line
|
||||
)
|
||||
breakpointActions.enableBreakpointsAtLine(location.sourceId, location.line)
|
||||
});
|
||||
|
||||
export const disableBreakpointsOnLineItem = (
|
||||
cx: Context,
|
||||
location: SourceLocation,
|
||||
breakpointActions: BreakpointItemActions
|
||||
) => ({
|
||||
@ -229,11 +205,7 @@ export const disableBreakpointsOnLineItem = (
|
||||
accesskey: L10N.getStr("breakpointMenuItem.disableAllAtLine.accesskey"),
|
||||
disabled: false,
|
||||
click: () =>
|
||||
breakpointActions.disableBreakpointsAtLine(
|
||||
cx,
|
||||
location.sourceId,
|
||||
location.line
|
||||
)
|
||||
breakpointActions.disableBreakpointsAtLine(location.sourceId, location.line)
|
||||
});
|
||||
|
||||
export type BreakpointItemActions = {
|
||||
|
@ -19,26 +19,20 @@ import { downloadFile } from "../../../utils/utils";
|
||||
|
||||
import actions from "../../../actions";
|
||||
|
||||
import type {
|
||||
Source,
|
||||
SourceLocation,
|
||||
Context,
|
||||
ThreadContext
|
||||
} from "../../../types";
|
||||
import type { Source, SourceLocation } from "../../../types";
|
||||
|
||||
function isMapped(selectedSource) {
|
||||
return isOriginalId(selectedSource.id) || !!selectedSource.sourceMapURL;
|
||||
}
|
||||
|
||||
export const continueToHereItem = (
|
||||
cx: ThreadContext,
|
||||
location: SourceLocation,
|
||||
isPaused: boolean,
|
||||
editorActions: EditorItemActions
|
||||
) => ({
|
||||
accesskey: L10N.getStr("editor.continueToHere.accesskey"),
|
||||
disabled: !isPaused,
|
||||
click: () => editorActions.continueToHere(cx, location.line, location.column),
|
||||
click: () => editorActions.continueToHere(location.line, location.column),
|
||||
id: "node-menu-continue-to-here",
|
||||
label: L10N.getStr("editor.continueToHere.label")
|
||||
});
|
||||
@ -91,7 +85,6 @@ const copySourceUri2Item = (
|
||||
});
|
||||
|
||||
const jumpToMappedLocationItem = (
|
||||
cx: Context,
|
||||
selectedSource: Source,
|
||||
location: SourceLocation,
|
||||
hasPrettySource: boolean,
|
||||
@ -107,11 +100,10 @@ const jumpToMappedLocationItem = (
|
||||
accesskey: L10N.getStr("editor.jumpToMappedLocation1.accesskey"),
|
||||
disabled:
|
||||
(!isMapped(selectedSource) && !isPretty(selectedSource)) || hasPrettySource,
|
||||
click: () => editorActions.jumpToMappedLocation(cx, location)
|
||||
click: () => editorActions.jumpToMappedLocation(location)
|
||||
});
|
||||
|
||||
const showSourceMenuItem = (
|
||||
cx: Context,
|
||||
selectedSource: Source,
|
||||
editorActions: EditorItemActions
|
||||
) => ({
|
||||
@ -119,11 +111,10 @@ const showSourceMenuItem = (
|
||||
label: L10N.getStr("sourceTabs.revealInTree"),
|
||||
accesskey: L10N.getStr("sourceTabs.revealInTree.accesskey"),
|
||||
disabled: !selectedSource.url,
|
||||
click: () => editorActions.showSource(cx, selectedSource.id)
|
||||
click: () => editorActions.showSource(selectedSource.id)
|
||||
});
|
||||
|
||||
const blackBoxMenuItem = (
|
||||
cx: Context,
|
||||
selectedSource: Source,
|
||||
editorActions: EditorItemActions
|
||||
) => ({
|
||||
@ -133,11 +124,10 @@ const blackBoxMenuItem = (
|
||||
: L10N.getStr("sourceFooter.blackbox"),
|
||||
accesskey: L10N.getStr("sourceFooter.blackbox.accesskey"),
|
||||
disabled: !shouldBlackbox(selectedSource),
|
||||
click: () => editorActions.toggleBlackBox(cx, selectedSource)
|
||||
click: () => editorActions.toggleBlackBox(selectedSource)
|
||||
});
|
||||
|
||||
const watchExpressionItem = (
|
||||
cx: ThreadContext,
|
||||
selectedSource: Source,
|
||||
selectionText: string,
|
||||
editorActions: EditorItemActions
|
||||
@ -145,7 +135,7 @@ const watchExpressionItem = (
|
||||
id: "node-menu-add-watch-expression",
|
||||
label: L10N.getStr("expressions.label"),
|
||||
accesskey: L10N.getStr("expressions.accesskey"),
|
||||
click: () => editorActions.addExpression(cx, selectionText)
|
||||
click: () => editorActions.addExpression(selectionText)
|
||||
});
|
||||
|
||||
const evaluateInConsoleItem = (
|
||||
@ -171,7 +161,6 @@ const downloadFileItem = (
|
||||
};
|
||||
|
||||
export function editorMenuItems({
|
||||
cx,
|
||||
editorActions,
|
||||
selectedSource,
|
||||
location,
|
||||
@ -180,7 +169,6 @@ export function editorMenuItems({
|
||||
isTextSelected,
|
||||
isPaused
|
||||
}: {
|
||||
cx: ThreadContext,
|
||||
editorActions: EditorItemActions,
|
||||
selectedSource: Source,
|
||||
location: SourceLocation,
|
||||
@ -193,27 +181,26 @@ export function editorMenuItems({
|
||||
|
||||
items.push(
|
||||
jumpToMappedLocationItem(
|
||||
cx,
|
||||
selectedSource,
|
||||
location,
|
||||
hasPrettySource,
|
||||
editorActions
|
||||
),
|
||||
continueToHereItem(cx, location, isPaused, editorActions),
|
||||
continueToHereItem(location, isPaused, editorActions),
|
||||
{ type: "separator" },
|
||||
copyToClipboardItem(selectedSource, editorActions),
|
||||
copySourceItem(selectedSource, selectionText, editorActions),
|
||||
copySourceUri2Item(selectedSource, editorActions),
|
||||
downloadFileItem(selectedSource, editorActions),
|
||||
{ type: "separator" },
|
||||
showSourceMenuItem(cx, selectedSource, editorActions),
|
||||
blackBoxMenuItem(cx, selectedSource, editorActions)
|
||||
showSourceMenuItem(selectedSource, editorActions),
|
||||
blackBoxMenuItem(selectedSource, editorActions)
|
||||
);
|
||||
|
||||
if (isTextSelected) {
|
||||
items.push(
|
||||
{ type: "separator" },
|
||||
watchExpressionItem(cx, selectedSource, selectionText, editorActions),
|
||||
watchExpressionItem(selectedSource, selectionText, editorActions),
|
||||
evaluateInConsoleItem(selectedSource, selectionText, editorActions)
|
||||
);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ describe("doSearch", () => {
|
||||
.find("SearchInput")
|
||||
.simulate("change", { target: { value: "query" } });
|
||||
|
||||
const doSearchArgs = props.doSearch.mock.calls[0][1];
|
||||
const doSearchArgs = props.doSearch.mock.calls[0][0];
|
||||
expect(doSearchArgs).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@ -16,8 +16,7 @@ import actions from "../../actions";
|
||||
import {
|
||||
getSelectedSource,
|
||||
getSymbols,
|
||||
getSelectedLocation,
|
||||
getContext
|
||||
getSelectedLocation
|
||||
} from "../../selectors";
|
||||
|
||||
import OutlineFilter from "./OutlineFilter";
|
||||
@ -31,10 +30,9 @@ import type {
|
||||
SymbolDeclaration,
|
||||
FunctionDeclaration
|
||||
} from "../../workers/parser";
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
symbols: SymbolDeclarations,
|
||||
selectedSource: ?Source,
|
||||
alphabetizeOutline: boolean,
|
||||
@ -74,12 +72,12 @@ export class Outline extends Component<Props, State> {
|
||||
}
|
||||
|
||||
selectItem(location: AstLocation) {
|
||||
const { cx, selectedSource, selectLocation } = this.props;
|
||||
const { selectedSource, selectLocation } = this.props;
|
||||
if (!selectedSource) {
|
||||
return;
|
||||
}
|
||||
|
||||
selectLocation(cx, {
|
||||
selectLocation({
|
||||
sourceId: selectedSource.id,
|
||||
line: location.start.line,
|
||||
column: location.start.column
|
||||
@ -266,7 +264,6 @@ const mapStateToProps = state => {
|
||||
const symbols = selectedSource ? getSymbols(state, selectedSource) : null;
|
||||
|
||||
return {
|
||||
cx: getContext(state),
|
||||
symbols,
|
||||
selectedSource,
|
||||
selectedLocation: getSelectedLocation(state),
|
||||
|
@ -19,8 +19,7 @@ import {
|
||||
getDisplayedSourcesForThread,
|
||||
getFocusedSourceItem,
|
||||
getWorkerByThread,
|
||||
getWorkerCount,
|
||||
getContext
|
||||
getWorkerCount
|
||||
} from "../../selectors";
|
||||
|
||||
import { getGeneratedSourceByURL } from "../../reducers/sources";
|
||||
@ -52,12 +51,11 @@ import type {
|
||||
TreeDirectory,
|
||||
ParentMap
|
||||
} from "../../utils/sources-tree/types";
|
||||
import type { Worker, Source, Context } from "../../types";
|
||||
import type { Worker, Source } from "../../types";
|
||||
import type { SourcesMap, State as AppState } from "../../reducers/types";
|
||||
import type { Item } from "../shared/ManagedTree";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
thread: string,
|
||||
worker: Worker,
|
||||
sources: SourcesMap,
|
||||
@ -158,12 +156,12 @@ class SourcesTree extends Component<Props, State> {
|
||||
|
||||
selectItem = (item: TreeNode) => {
|
||||
if (item.type == "source" && !Array.isArray(item.contents)) {
|
||||
this.props.selectSource(this.props.cx, item.contents.id);
|
||||
this.props.selectSource(item.contents.id);
|
||||
}
|
||||
};
|
||||
|
||||
onFocus = (item: TreeNode) => {
|
||||
this.props.focusItem(this.props.cx, { thread: this.props.thread, item });
|
||||
this.props.focusItem({ thread: this.props.thread, item });
|
||||
};
|
||||
|
||||
onActivate = (item: TreeNode) => {
|
||||
@ -373,7 +371,6 @@ const mapStateToProps = (state, props) => {
|
||||
const displayedSources = getDisplayedSourcesForThread(state, thread);
|
||||
|
||||
return {
|
||||
cx: getContext(state),
|
||||
shownSource: getSourceForTree(state, displayedSources, shownSource, thread),
|
||||
selectedSource: getSourceForTree(
|
||||
state,
|
||||
|
@ -15,8 +15,7 @@ import AccessibleImage from "../shared/AccessibleImage";
|
||||
import {
|
||||
getGeneratedSourceByURL,
|
||||
getHasSiblingOfSameName,
|
||||
hasPrettySource as checkHasPrettySource,
|
||||
getContext
|
||||
hasPrettySource as checkHasPrettySource
|
||||
} from "../../selectors";
|
||||
import actions from "../../actions";
|
||||
|
||||
@ -31,10 +30,9 @@ import { copyToTheClipboard } from "../../utils/clipboard";
|
||||
import { features } from "../../utils/prefs";
|
||||
|
||||
import type { TreeNode } from "../../utils/sources-tree/types";
|
||||
import type { Source, Context } from "../../types";
|
||||
import type { Source } from "../../types";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
debuggeeUrl: string,
|
||||
projectRoot: string,
|
||||
source: ?Source,
|
||||
@ -136,7 +134,7 @@ class SourceTreeItem extends Component<Props, State> {
|
||||
click: () => copyToTheClipboard(contents.url)
|
||||
};
|
||||
|
||||
const { cx, source } = this.props;
|
||||
const { source } = this.props;
|
||||
if (source) {
|
||||
const blackBoxMenuItem = {
|
||||
id: "node-menu-blackbox",
|
||||
@ -145,7 +143,7 @@ class SourceTreeItem extends Component<Props, State> {
|
||||
: L10N.getStr("sourceFooter.blackbox"),
|
||||
accesskey: L10N.getStr("sourceFooter.blackbox.accesskey"),
|
||||
disabled: !shouldBlackbox(source),
|
||||
click: () => this.props.toggleBlackBox(cx, source)
|
||||
click: () => this.props.toggleBlackBox(source)
|
||||
};
|
||||
menuOptions.push(copySourceUri2, blackBoxMenuItem);
|
||||
}
|
||||
@ -157,14 +155,14 @@ class SourceTreeItem extends Component<Props, State> {
|
||||
|
||||
if (features.root) {
|
||||
const { path } = item;
|
||||
const { cx, projectRoot } = this.props;
|
||||
const { projectRoot } = this.props;
|
||||
|
||||
if (projectRoot.endsWith(path)) {
|
||||
menuOptions.push({
|
||||
id: "node-remove-directory-root",
|
||||
label: removeDirectoryRootLabel,
|
||||
disabled: false,
|
||||
click: () => this.props.clearProjectDirectoryRoot(cx)
|
||||
click: () => this.props.clearProjectDirectoryRoot()
|
||||
});
|
||||
} else {
|
||||
menuOptions.push({
|
||||
@ -172,7 +170,7 @@ class SourceTreeItem extends Component<Props, State> {
|
||||
label: setDirectoryRootLabel,
|
||||
accesskey: setDirectoryRootKey,
|
||||
disabled: false,
|
||||
click: () => this.props.setProjectDirectoryRoot(cx, path)
|
||||
click: () => this.props.setProjectDirectoryRoot(path)
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -275,7 +273,6 @@ function getHasMatchingGeneratedSource(state, source: ?Source) {
|
||||
const mapStateToProps = (state, props) => {
|
||||
const { source } = props;
|
||||
return {
|
||||
cx: getContext(state),
|
||||
hasMatchingGeneratedSource: getHasMatchingGeneratedSource(state, source),
|
||||
hasSiblingOfSameName: getHasSiblingOfSameName(state, source),
|
||||
hasPrettySource: source ? checkHasPrettySource(state, source.id) : false
|
||||
|
@ -14,8 +14,7 @@ import {
|
||||
getActiveSearch,
|
||||
getProjectDirectoryRoot,
|
||||
getSelectedPrimaryPaneTab,
|
||||
getThreads,
|
||||
getContext
|
||||
getThreads
|
||||
} from "../../selectors";
|
||||
import { features, prefs } from "../../utils/prefs";
|
||||
import { connect } from "../../utils/connect";
|
||||
@ -27,7 +26,7 @@ import AccessibleImage from "../shared/AccessibleImage";
|
||||
|
||||
import type { SourcesMapByThread } from "../../reducers/types";
|
||||
import type { SelectedPrimaryPaneTabType } from "../../selectors";
|
||||
import type { Thread, Context } from "../../types";
|
||||
import type { Thread } from "../../types";
|
||||
|
||||
import "./Sources.css";
|
||||
|
||||
@ -36,7 +35,6 @@ type State = {
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
selectedTab: SelectedPrimaryPaneTabType,
|
||||
sources: SourcesMapByThread,
|
||||
horizontal: boolean,
|
||||
@ -103,7 +101,7 @@ class PrimaryPanes extends Component<Props, State> {
|
||||
}
|
||||
|
||||
renderProjectRootHeader() {
|
||||
const { cx, projectRoot } = this.props;
|
||||
const { projectRoot } = this.props;
|
||||
|
||||
if (!projectRoot) {
|
||||
return null;
|
||||
@ -115,7 +113,7 @@ class PrimaryPanes extends Component<Props, State> {
|
||||
<div key="root" className="sources-clear-root-container">
|
||||
<button
|
||||
className="sources-clear-root"
|
||||
onClick={() => this.props.clearProjectDirectoryRoot(cx)}
|
||||
onClick={() => this.props.clearProjectDirectoryRoot()}
|
||||
title={L10N.getStr("removeDirectoryRoot.label")}
|
||||
>
|
||||
<AccessibleImage className="home" />
|
||||
@ -166,7 +164,6 @@ class PrimaryPanes extends Component<Props, State> {
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getContext(state),
|
||||
selectedTab: getSelectedPrimaryPaneTab(state),
|
||||
sources: getDisplayedSources(state),
|
||||
sourceSearchOn: getActiveSearch(state) === "source",
|
||||
|
@ -9,7 +9,7 @@ import { shallow } from "enzyme";
|
||||
import { showMenu } from "devtools-contextmenu";
|
||||
|
||||
import SourcesTree from "../SourcesTree";
|
||||
import { makeMockSource, mockcx } from "../../../utils/test-mockup";
|
||||
import { makeMockSource } from "../../../utils/test-mockup";
|
||||
import { copyToTheClipboard } from "../../../utils/clipboard";
|
||||
|
||||
jest.mock("devtools-contextmenu", () => ({ showMenu: jest.fn() }));
|
||||
@ -194,7 +194,6 @@ describe("SourcesTree", () => {
|
||||
instance.onActivate(item);
|
||||
expect(spy).toHaveBeenCalledWith(item);
|
||||
expect(props.selectSource).toHaveBeenCalledWith(
|
||||
mockcx,
|
||||
"server1.conn13.child1/39"
|
||||
);
|
||||
});
|
||||
@ -205,7 +204,6 @@ describe("SourcesTree", () => {
|
||||
const { instance, props } = render();
|
||||
instance.selectItem(createMockItem());
|
||||
expect(props.selectSource).toHaveBeenCalledWith(
|
||||
mockcx,
|
||||
"server1.conn13.child1/39"
|
||||
);
|
||||
});
|
||||
@ -359,7 +357,6 @@ function generateDefaults(overrides: Object) {
|
||||
)
|
||||
};
|
||||
return {
|
||||
cx: mockcx,
|
||||
thread: "FakeThread",
|
||||
autoExpandAll: true,
|
||||
selectSource: jest.fn(),
|
||||
|
@ -19,8 +19,7 @@ import {
|
||||
getActiveSearch,
|
||||
getTextSearchResults,
|
||||
getTextSearchStatus,
|
||||
getTextSearchQuery,
|
||||
getContext
|
||||
getTextSearchQuery
|
||||
} from "../selectors";
|
||||
|
||||
import ManagedTree from "./shared/ManagedTree";
|
||||
@ -30,7 +29,6 @@ import AccessibleImage from "./shared/AccessibleImage";
|
||||
import type { List } from "immutable";
|
||||
import type { ActiveSearchType } from "../reducers/types";
|
||||
import type { StatusType } from "../reducers/project-text-search";
|
||||
import type { Context } from "../types";
|
||||
|
||||
import "./ProjectSearch.css";
|
||||
|
||||
@ -61,7 +59,6 @@ type State = {
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
query: string,
|
||||
results: List<Result>,
|
||||
status: StatusType,
|
||||
@ -122,17 +119,17 @@ export class ProjectSearch extends Component<Props, State> {
|
||||
}
|
||||
|
||||
doSearch(searchTerm: string) {
|
||||
this.props.searchSources(this.props.cx, searchTerm);
|
||||
this.props.searchSources(searchTerm);
|
||||
}
|
||||
|
||||
toggleProjectTextSearch = (key: string, e: KeyboardEvent) => {
|
||||
const { cx, closeProjectSearch, setActiveSearch } = this.props;
|
||||
const { closeProjectSearch, setActiveSearch } = this.props;
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (this.isProjectSearchEnabled()) {
|
||||
return closeProjectSearch(cx);
|
||||
return closeProjectSearch();
|
||||
}
|
||||
|
||||
return setActiveSearch("project");
|
||||
@ -141,7 +138,7 @@ export class ProjectSearch extends Component<Props, State> {
|
||||
isProjectSearchEnabled = () => this.props.activeSearch === "project";
|
||||
|
||||
selectMatchItem = (matchItem: Match) => {
|
||||
this.props.selectSpecificLocation(this.props.cx, {
|
||||
this.props.selectSpecificLocation({
|
||||
sourceId: matchItem.sourceId,
|
||||
line: matchItem.line,
|
||||
column: matchItem.column
|
||||
@ -199,10 +196,10 @@ export class ProjectSearch extends Component<Props, State> {
|
||||
|
||||
inputOnChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
|
||||
const inputValue = e.target.value;
|
||||
const { cx, clearSearch } = this.props;
|
||||
const { clearSearch } = this.props;
|
||||
this.setState({ inputValue });
|
||||
if (inputValue === "") {
|
||||
clearSearch(cx);
|
||||
clearSearch();
|
||||
}
|
||||
};
|
||||
|
||||
@ -334,7 +331,6 @@ ProjectSearch.contextTypes = {
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getContext(state),
|
||||
activeSearch: getActiveSearch(state),
|
||||
results: getTextSearchResults(state),
|
||||
query: getTextSearchQuery(state),
|
||||
|
@ -17,8 +17,7 @@ import {
|
||||
getSelectedSource,
|
||||
getSymbols,
|
||||
getTabs,
|
||||
isSymbolsLoading,
|
||||
getContext
|
||||
isSymbolsLoading
|
||||
} from "../selectors";
|
||||
import { scrollList } from "../utils/result-list";
|
||||
import {
|
||||
@ -36,14 +35,13 @@ import type {
|
||||
QuickOpenResult
|
||||
} from "../utils/quick-open";
|
||||
|
||||
import type { Source, Context } from "../types";
|
||||
import type { Source } from "../types";
|
||||
import type { QuickOpenType } from "../reducers/quick-open";
|
||||
import type { Tab } from "../reducers/tabs";
|
||||
|
||||
import "./QuickOpenModal.css";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
enabled: boolean,
|
||||
sources: Array<Object>,
|
||||
selectedSource?: Source,
|
||||
@ -247,11 +245,11 @@ export class QuickOpenModal extends Component<Props, State> {
|
||||
};
|
||||
|
||||
gotoLocation = (location: ?GotoLocationType) => {
|
||||
const { cx, selectSpecificLocation, selectedSource } = this.props;
|
||||
const { selectSpecificLocation, selectedSource } = this.props;
|
||||
const selectedSourceId = selectedSource ? selectedSource.id : "";
|
||||
if (location != null) {
|
||||
const sourceId = location.sourceId ? location.sourceId : selectedSourceId;
|
||||
selectSpecificLocation(cx, {
|
||||
selectSpecificLocation({
|
||||
sourceId,
|
||||
line: location.line,
|
||||
column: location.column
|
||||
@ -421,7 +419,6 @@ function mapStateToProps(state) {
|
||||
const selectedSource = getSelectedSource(state);
|
||||
|
||||
return {
|
||||
cx: getContext(state),
|
||||
enabled: getQuickOpenEnabled(state),
|
||||
sources: formatSources(getDisplayedSourcesList(state), getTabs(state)),
|
||||
selectedSource,
|
||||
|
@ -27,8 +27,7 @@ import type {
|
||||
Breakpoint as BreakpointType,
|
||||
Frame,
|
||||
Source,
|
||||
SourceLocation,
|
||||
Context
|
||||
SourceLocation
|
||||
} from "../../../types";
|
||||
|
||||
type FormattedFrame = Frame & {
|
||||
@ -39,12 +38,10 @@ import {
|
||||
getBreakpointsList,
|
||||
getSelectedFrame,
|
||||
getSelectedSource,
|
||||
getCurrentThread,
|
||||
getContext
|
||||
getCurrentThread
|
||||
} from "../../../selectors";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
breakpoint: BreakpointType,
|
||||
breakpoints: BreakpointType[],
|
||||
selectedSource: Source,
|
||||
@ -82,22 +79,22 @@ class Breakpoint extends PureComponent<Props> {
|
||||
|
||||
selectBreakpoint = event => {
|
||||
event.preventDefault();
|
||||
const { cx, selectSpecificLocation } = this.props;
|
||||
selectSpecificLocation(cx, this.selectedLocation);
|
||||
const { selectSpecificLocation } = this.props;
|
||||
selectSpecificLocation(this.selectedLocation);
|
||||
};
|
||||
|
||||
removeBreakpoint = event => {
|
||||
const { cx, removeBreakpoint, breakpoint } = this.props;
|
||||
const { removeBreakpoint, breakpoint } = this.props;
|
||||
event.stopPropagation();
|
||||
removeBreakpoint(cx, breakpoint);
|
||||
removeBreakpoint(breakpoint);
|
||||
};
|
||||
|
||||
handleBreakpointCheckbox = () => {
|
||||
const { cx, breakpoint, enableBreakpoint, disableBreakpoint } = this.props;
|
||||
const { breakpoint, enableBreakpoint, disableBreakpoint } = this.props;
|
||||
if (breakpoint.disabled) {
|
||||
enableBreakpoint(cx, breakpoint);
|
||||
enableBreakpoint(breakpoint);
|
||||
} else {
|
||||
disableBreakpoint(cx, breakpoint);
|
||||
disableBreakpoint(breakpoint);
|
||||
}
|
||||
};
|
||||
|
||||
@ -214,7 +211,6 @@ const getFormattedFrame = createSelector(
|
||||
);
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getContext(state),
|
||||
breakpoints: getBreakpointsList(state),
|
||||
frame: getFormattedFrame(state, getCurrentThread(state))
|
||||
});
|
||||
|
@ -14,17 +14,15 @@ import {
|
||||
} from "../../../utils/source";
|
||||
import {
|
||||
getHasSiblingOfSameName,
|
||||
getBreakpointsForSource,
|
||||
getContext
|
||||
getBreakpointsForSource
|
||||
} from "../../../selectors";
|
||||
|
||||
import SourceIcon from "../../shared/SourceIcon";
|
||||
|
||||
import type { Source, Breakpoint, Context } from "../../../types";
|
||||
import type { Source, Breakpoint } from "../../../types";
|
||||
import showContextMenu from "./BreakpointHeadingsContextMenu";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
sources: Source[],
|
||||
source: Source,
|
||||
hasSiblingOfSameName: boolean,
|
||||
@ -41,13 +39,7 @@ class BreakpointHeading extends PureComponent<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
cx,
|
||||
sources,
|
||||
source,
|
||||
hasSiblingOfSameName,
|
||||
selectSource
|
||||
} = this.props;
|
||||
const { sources, source, hasSiblingOfSameName, selectSource } = this.props;
|
||||
|
||||
const path = getDisplayPath(source, sources);
|
||||
const query = hasSiblingOfSameName ? getSourceQueryString(source) : "";
|
||||
@ -56,7 +48,7 @@ class BreakpointHeading extends PureComponent<Props> {
|
||||
<div
|
||||
className="breakpoint-heading"
|
||||
title={getFileURL(source, false)}
|
||||
onClick={() => selectSource(cx, source.id)}
|
||||
onClick={() => selectSource(source.id)}
|
||||
onContextMenu={this.onContextMenu}
|
||||
>
|
||||
<SourceIcon
|
||||
@ -73,7 +65,6 @@ class BreakpointHeading extends PureComponent<Props> {
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, { source }) => ({
|
||||
cx: getContext(state),
|
||||
hasSiblingOfSameName: getHasSiblingOfSameName(state, source),
|
||||
breakpointsForSource: getBreakpointsForSource(state, source.id)
|
||||
});
|
||||
|
@ -7,10 +7,9 @@
|
||||
import { buildMenu, showMenu } from "devtools-contextmenu";
|
||||
|
||||
import actions from "../../../actions";
|
||||
import type { Breakpoint, Source, Context } from "../../../types";
|
||||
import type { Breakpoint, Source } from "../../../types";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
source: Source,
|
||||
breakpointsForSource: Breakpoint[],
|
||||
disableBreakpointsInSource: typeof actions.disableBreakpointsInSource,
|
||||
@ -21,7 +20,6 @@ type Props = {
|
||||
|
||||
export default function showContextMenu(props: Props) {
|
||||
const {
|
||||
cx,
|
||||
source,
|
||||
breakpointsForSource,
|
||||
disableBreakpointsInSource,
|
||||
@ -56,7 +54,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: disableInSourceLabel,
|
||||
accesskey: disableInSourceKey,
|
||||
disabled: false,
|
||||
click: () => disableBreakpointsInSource(cx, source)
|
||||
click: () => disableBreakpointsInSource(source)
|
||||
};
|
||||
|
||||
const enableInSourceItem = {
|
||||
@ -64,7 +62,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: enableInSourceLabel,
|
||||
accesskey: enableInSourceKey,
|
||||
disabled: false,
|
||||
click: () => enableBreakpointsInSource(cx, source)
|
||||
click: () => enableBreakpointsInSource(source)
|
||||
};
|
||||
|
||||
const removeInSourceItem = {
|
||||
@ -72,7 +70,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: removeInSourceLabel,
|
||||
accesskey: removeInSourceKey,
|
||||
disabled: false,
|
||||
click: () => removeBreakpointsInSource(cx, source)
|
||||
click: () => removeBreakpointsInSource(source)
|
||||
};
|
||||
|
||||
const hideDisableInSourceItem = breakpointsForSource.every(
|
||||
|
@ -9,10 +9,9 @@ import { getSelectedLocation } from "../../../utils/source-maps";
|
||||
import actions from "../../../actions";
|
||||
import { features } from "../../../utils/prefs";
|
||||
|
||||
import type { Breakpoint, Source, Context } from "../../../types";
|
||||
import type { Breakpoint, Source } from "../../../types";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
breakpoint: Breakpoint,
|
||||
breakpoints: Breakpoint[],
|
||||
selectedSource: Source,
|
||||
@ -30,7 +29,6 @@ type Props = {
|
||||
|
||||
export default function showContextMenu(props: Props) {
|
||||
const {
|
||||
cx,
|
||||
breakpoint,
|
||||
breakpoints,
|
||||
selectedSource,
|
||||
@ -117,7 +115,7 @@ export default function showContextMenu(props: Props) {
|
||||
accesskey: deleteSelfKey,
|
||||
disabled: false,
|
||||
click: () => {
|
||||
removeBreakpoint(cx, breakpoint);
|
||||
removeBreakpoint(breakpoint);
|
||||
}
|
||||
};
|
||||
|
||||
@ -126,7 +124,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: deleteAllLabel,
|
||||
accesskey: deleteAllKey,
|
||||
disabled: false,
|
||||
click: () => removeAllBreakpoints(cx)
|
||||
click: () => removeAllBreakpoints()
|
||||
};
|
||||
|
||||
const deleteOthersItem = {
|
||||
@ -134,7 +132,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: deleteOthersLabel,
|
||||
accesskey: deleteOthersKey,
|
||||
disabled: false,
|
||||
click: () => removeBreakpoints(cx, otherBreakpoints)
|
||||
click: () => removeBreakpoints(otherBreakpoints)
|
||||
};
|
||||
|
||||
const enableSelfItem = {
|
||||
@ -143,7 +141,7 @@ export default function showContextMenu(props: Props) {
|
||||
accesskey: enableSelfKey,
|
||||
disabled: false,
|
||||
click: () => {
|
||||
toggleDisabledBreakpoint(cx, breakpoint);
|
||||
toggleDisabledBreakpoint(breakpoint);
|
||||
}
|
||||
};
|
||||
|
||||
@ -152,7 +150,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: enableAllLabel,
|
||||
accesskey: enableAllKey,
|
||||
disabled: false,
|
||||
click: () => toggleAllBreakpoints(cx, false)
|
||||
click: () => toggleAllBreakpoints(false)
|
||||
};
|
||||
|
||||
const enableOthersItem = {
|
||||
@ -160,7 +158,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: enableOthersLabel,
|
||||
accesskey: enableOthersKey,
|
||||
disabled: false,
|
||||
click: () => toggleBreakpoints(cx, false, otherDisabledBreakpoints)
|
||||
click: () => toggleBreakpoints(false, otherDisabledBreakpoints)
|
||||
};
|
||||
|
||||
const disableSelfItem = {
|
||||
@ -169,7 +167,7 @@ export default function showContextMenu(props: Props) {
|
||||
accesskey: disableSelfKey,
|
||||
disabled: false,
|
||||
click: () => {
|
||||
toggleDisabledBreakpoint(cx, breakpoint);
|
||||
toggleDisabledBreakpoint(breakpoint);
|
||||
}
|
||||
};
|
||||
|
||||
@ -178,14 +176,14 @@ export default function showContextMenu(props: Props) {
|
||||
label: disableAllLabel,
|
||||
accesskey: disableAllKey,
|
||||
disabled: false,
|
||||
click: () => toggleAllBreakpoints(cx, true)
|
||||
click: () => toggleAllBreakpoints(true)
|
||||
};
|
||||
|
||||
const disableOthersItem = {
|
||||
id: "node-menu-disable-others",
|
||||
label: disableOthersLabel,
|
||||
accesskey: disableOthersKey,
|
||||
click: () => toggleBreakpoints(cx, true, otherEnabledBreakpoints)
|
||||
click: () => toggleBreakpoints(true, otherEnabledBreakpoints)
|
||||
};
|
||||
|
||||
const removeConditionItem = {
|
||||
@ -194,7 +192,7 @@ export default function showContextMenu(props: Props) {
|
||||
accesskey: removeConditionKey,
|
||||
disabled: false,
|
||||
click: () =>
|
||||
setBreakpointOptions(cx, selectedLocation, {
|
||||
setBreakpointOptions(selectedLocation, {
|
||||
...breakpoint.options,
|
||||
condition: null
|
||||
})
|
||||
@ -205,7 +203,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: addConditionLabel,
|
||||
accesskey: addConditionKey,
|
||||
click: () => {
|
||||
selectSpecificLocation(cx, selectedLocation);
|
||||
selectSpecificLocation(selectedLocation);
|
||||
openConditionalPanel(selectedLocation);
|
||||
},
|
||||
accelerator: L10N.getStr("toggleCondPanel.breakpoint.key")
|
||||
@ -216,7 +214,7 @@ export default function showContextMenu(props: Props) {
|
||||
label: editConditionLabel,
|
||||
accesskey: editConditionKey,
|
||||
click: () => {
|
||||
selectSpecificLocation(cx, selectedLocation);
|
||||
selectSpecificLocation(selectedLocation);
|
||||
openConditionalPanel(selectedLocation);
|
||||
},
|
||||
accelerator: L10N.getStr("toggleCondPanel.breakpoint.key")
|
||||
@ -246,7 +244,7 @@ export default function showContextMenu(props: Props) {
|
||||
accesskey: L10N.getStr("editor.removeLogPoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () =>
|
||||
setBreakpointOptions(cx, selectedLocation, {
|
||||
setBreakpointOptions(selectedLocation, {
|
||||
...breakpoint.options,
|
||||
logValue: null
|
||||
})
|
||||
|
@ -12,8 +12,7 @@ import { buildMenu } from "devtools-contextmenu";
|
||||
|
||||
import {
|
||||
makeMockBreakpoint,
|
||||
makeMockSource,
|
||||
mockcx
|
||||
makeMockSource
|
||||
} from "../../../../utils/test-mockup";
|
||||
|
||||
jest.mock("devtools-contextmenu");
|
||||
@ -56,7 +55,6 @@ function generateDefaults(disabled) {
|
||||
];
|
||||
|
||||
const props = {
|
||||
cx: mockcx,
|
||||
breakpoints,
|
||||
breakpoint: breakpoints[0],
|
||||
removeBreakpoint: jest.fn(),
|
||||
@ -92,7 +90,7 @@ describe("BreakpointsContextMenu", () => {
|
||||
expect(props.removeBreakpoints).toHaveBeenCalled();
|
||||
|
||||
const otherBreakpoints = [props.breakpoints[1], props.breakpoints[2]];
|
||||
expect(props.removeBreakpoints.mock.calls[0][1]).toEqual(
|
||||
expect(props.removeBreakpoints.mock.calls[0][0]).toEqual(
|
||||
otherBreakpoints
|
||||
);
|
||||
});
|
||||
@ -107,10 +105,10 @@ describe("BreakpointsContextMenu", () => {
|
||||
|
||||
expect(props.toggleBreakpoints).toHaveBeenCalled();
|
||||
|
||||
expect(props.toggleBreakpoints.mock.calls[0][1]).toBe(false);
|
||||
expect(props.toggleBreakpoints.mock.calls[0][0]).toBe(false);
|
||||
|
||||
const otherBreakpoints = [props.breakpoints[1], props.breakpoints[2]];
|
||||
expect(props.toggleBreakpoints.mock.calls[0][2]).toEqual(
|
||||
expect(props.toggleBreakpoints.mock.calls[0][1]).toEqual(
|
||||
otherBreakpoints
|
||||
);
|
||||
});
|
||||
@ -124,10 +122,10 @@ describe("BreakpointsContextMenu", () => {
|
||||
disableOthers.item.click();
|
||||
|
||||
expect(props.toggleBreakpoints).toHaveBeenCalled();
|
||||
expect(props.toggleBreakpoints.mock.calls[0][1]).toBe(true);
|
||||
expect(props.toggleBreakpoints.mock.calls[0][0]).toBe(true);
|
||||
|
||||
const otherBreakpoints = [props.breakpoints[1], props.breakpoints[2]];
|
||||
expect(props.toggleBreakpoints.mock.calls[0][2]).toEqual(
|
||||
expect(props.toggleBreakpoints.mock.calls[0][1]).toEqual(
|
||||
otherBreakpoints
|
||||
);
|
||||
});
|
||||
|
@ -12,11 +12,11 @@ import { connect } from "../../utils/connect";
|
||||
import classnames from "classnames";
|
||||
import { features } from "../../utils/prefs";
|
||||
import {
|
||||
getIsPaused,
|
||||
getIsWaitingOnBreak,
|
||||
getCanRewind,
|
||||
getSkipPausing,
|
||||
getCurrentThread,
|
||||
getThreadContext
|
||||
getCurrentThread
|
||||
} from "../../selectors";
|
||||
import { formatKeyShortcut } from "../../utils/text";
|
||||
import actions from "../../actions";
|
||||
@ -25,7 +25,6 @@ import AccessibleImage from "../shared/AccessibleImage";
|
||||
import "./CommandBar.css";
|
||||
|
||||
import { appinfo } from "devtools-services";
|
||||
import type { ThreadContext } from "../../types";
|
||||
|
||||
const isMacOS = appinfo.OS === "Darwin";
|
||||
|
||||
@ -76,7 +75,7 @@ function formatKey(action) {
|
||||
}
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
isPaused: boolean,
|
||||
isWaitingOnBreak: boolean,
|
||||
horizontal: boolean,
|
||||
canRewind: boolean,
|
||||
@ -122,44 +121,41 @@ class CommandBar extends Component<Props> {
|
||||
}
|
||||
|
||||
handleEvent(e, action) {
|
||||
const { cx } = this.props;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (action === "resume") {
|
||||
this.props.cx.isPaused
|
||||
? this.props.resume(cx)
|
||||
: this.props.breakOnNext(cx);
|
||||
this.props.isPaused ? this.props.resume() : this.props.breakOnNext();
|
||||
} else {
|
||||
this.props[action](cx);
|
||||
this.props[action]();
|
||||
}
|
||||
}
|
||||
|
||||
renderStepButtons() {
|
||||
const { cx, canRewind } = this.props;
|
||||
const className = cx.isPaused ? "active" : "disabled";
|
||||
const isDisabled = !cx.isPaused;
|
||||
const { isPaused, canRewind } = this.props;
|
||||
const className = isPaused ? "active" : "disabled";
|
||||
const isDisabled = !isPaused;
|
||||
|
||||
if (canRewind || (!cx.isPaused && features.removeCommandBarOptions)) {
|
||||
if (canRewind || (!isPaused && features.removeCommandBarOptions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return [
|
||||
debugBtn(
|
||||
() => this.props.stepOver(cx),
|
||||
this.props.stepOver,
|
||||
"stepOver",
|
||||
className,
|
||||
L10N.getFormatStr("stepOverTooltip", formatKey("stepOver")),
|
||||
isDisabled
|
||||
),
|
||||
debugBtn(
|
||||
() => this.props.stepIn(cx),
|
||||
this.props.stepIn,
|
||||
"stepIn",
|
||||
className,
|
||||
L10N.getFormatStr("stepInTooltip", formatKey("stepIn")),
|
||||
isDisabled
|
||||
),
|
||||
debugBtn(
|
||||
() => this.props.stepOut(cx),
|
||||
this.props.stepOut,
|
||||
"stepOut",
|
||||
className,
|
||||
L10N.getFormatStr("stepOutTooltip", formatKey("stepOut")),
|
||||
@ -169,13 +165,13 @@ class CommandBar extends Component<Props> {
|
||||
}
|
||||
|
||||
resume() {
|
||||
this.props.resume(this.props.cx);
|
||||
this.props.resume();
|
||||
}
|
||||
|
||||
renderPauseButton() {
|
||||
const { cx, breakOnNext, isWaitingOnBreak, canRewind } = this.props;
|
||||
const { isPaused, breakOnNext, isWaitingOnBreak, canRewind } = this.props;
|
||||
|
||||
if (cx.isPaused) {
|
||||
if (isPaused) {
|
||||
if (canRewind) {
|
||||
return null;
|
||||
}
|
||||
@ -202,7 +198,7 @@ class CommandBar extends Component<Props> {
|
||||
}
|
||||
|
||||
return debugBtn(
|
||||
() => breakOnNext(cx),
|
||||
breakOnNext,
|
||||
"pause",
|
||||
"active",
|
||||
L10N.getFormatStr("pauseButtonTooltip", formatKey("resume"))
|
||||
@ -210,37 +206,32 @@ class CommandBar extends Component<Props> {
|
||||
}
|
||||
|
||||
renderTimeTravelButtons() {
|
||||
const { cx, canRewind } = this.props;
|
||||
const { isPaused, canRewind } = this.props;
|
||||
|
||||
if (!canRewind || !cx.isPaused) {
|
||||
if (!canRewind || !isPaused) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isDisabled = !cx.isPaused;
|
||||
const isDisabled = !isPaused;
|
||||
|
||||
return [
|
||||
debugBtn(
|
||||
() => this.props.rewind(cx),
|
||||
"rewind",
|
||||
"active",
|
||||
"Rewind Execution"
|
||||
),
|
||||
debugBtn(this.props.rewind, "rewind", "active", "Rewind Execution"),
|
||||
|
||||
debugBtn(
|
||||
() => this.props.resume(cx),
|
||||
this.props.resume,
|
||||
"resume",
|
||||
"active",
|
||||
L10N.getFormatStr("resumeButtonTooltip", formatKey("resume"))
|
||||
),
|
||||
<div key="divider-1" className="divider" />,
|
||||
debugBtn(
|
||||
() => this.props.reverseStepOver(cx),
|
||||
this.props.reverseStepOver,
|
||||
"reverseStepOver",
|
||||
"active",
|
||||
"Reverse step over"
|
||||
),
|
||||
debugBtn(
|
||||
() => this.props.stepOver(cx),
|
||||
this.props.stepOver,
|
||||
"stepOver",
|
||||
"active",
|
||||
L10N.getFormatStr("stepOverTooltip", formatKey("stepOver")),
|
||||
@ -248,7 +239,7 @@ class CommandBar extends Component<Props> {
|
||||
),
|
||||
<div key="divider-2" className="divider" />,
|
||||
debugBtn(
|
||||
() => this.props.stepOut(cx),
|
||||
this.props.stepOut,
|
||||
"stepOut",
|
||||
"active",
|
||||
L10N.getFormatStr("stepOutTooltip", formatKey("stepOut")),
|
||||
@ -256,7 +247,7 @@ class CommandBar extends Component<Props> {
|
||||
),
|
||||
|
||||
debugBtn(
|
||||
() => this.props.stepIn(cx),
|
||||
this.props.stepIn,
|
||||
"stepIn",
|
||||
"active",
|
||||
L10N.getFormatStr("stepInTooltip", formatKey("stepIn")),
|
||||
@ -312,7 +303,7 @@ CommandBar.contextTypes = {
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getThreadContext(state),
|
||||
isPaused: getIsPaused(state, getCurrentThread(state)),
|
||||
isWaitingOnBreak: getIsWaitingOnBreak(state, getCurrentThread(state)),
|
||||
canRewind: getCanRewind(state),
|
||||
skipPausing: getSkipPausing(state)
|
||||
|
@ -13,8 +13,7 @@ import actions from "../../actions";
|
||||
import {
|
||||
getExpressions,
|
||||
getExpressionError,
|
||||
getAutocompleteMatchset,
|
||||
getThreadContext
|
||||
getAutocompleteMatchset
|
||||
} from "../../selectors";
|
||||
import { getValue } from "../../utils/expressions";
|
||||
import { createObjectClient } from "../../client/firefox";
|
||||
@ -23,7 +22,7 @@ import { CloseButton } from "../shared/Button";
|
||||
import { debounce } from "lodash";
|
||||
|
||||
import type { List } from "immutable";
|
||||
import type { Expression, ThreadContext } from "../../types";
|
||||
import type { Expression } from "../../types";
|
||||
|
||||
import "./Expressions.css";
|
||||
|
||||
@ -37,7 +36,6 @@ type State = {
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
expressions: List<Expression>,
|
||||
expressionError: boolean,
|
||||
showInput: boolean,
|
||||
@ -73,10 +71,10 @@ class Expressions extends Component<Props, State> {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { cx, expressions, evaluateExpressions, showInput } = this.props;
|
||||
const { expressions, evaluateExpressions, showInput } = this.props;
|
||||
|
||||
if (expressions.size > 0) {
|
||||
evaluateExpressions(cx);
|
||||
evaluateExpressions();
|
||||
}
|
||||
|
||||
// Ensures that the input is focused when the "+"
|
||||
@ -161,7 +159,7 @@ class Expressions extends Component<Props, State> {
|
||||
|
||||
findAutocompleteMatches = debounce((value, selectionStart) => {
|
||||
const { autocomplete } = this.props;
|
||||
autocomplete(this.props.cx, value, selectionStart);
|
||||
autocomplete(value, selectionStart);
|
||||
}, 250);
|
||||
|
||||
handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
||||
@ -192,11 +190,7 @@ class Expressions extends Component<Props, State> {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.props.updateExpression(
|
||||
this.props.cx,
|
||||
this.state.inputValue,
|
||||
expression
|
||||
);
|
||||
this.props.updateExpression(this.state.inputValue, expression);
|
||||
this.hideInput();
|
||||
};
|
||||
|
||||
@ -206,7 +200,7 @@ class Expressions extends Component<Props, State> {
|
||||
e.stopPropagation();
|
||||
|
||||
this.props.clearExpressionError();
|
||||
await this.props.addExpression(this.props.cx, this.state.inputValue);
|
||||
await this.props.addExpression(this.state.inputValue);
|
||||
this.setState({
|
||||
editing: false,
|
||||
editIndex: -1,
|
||||
@ -372,7 +366,6 @@ class Expressions extends Component<Props, State> {
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
cx: getThreadContext(state),
|
||||
autocompleteMatches: getAutocompleteMatchset(state),
|
||||
expressions: getExpressions(state),
|
||||
expressionError: getExpressionError(state)
|
||||
|
@ -13,9 +13,8 @@ import { formatDisplayName } from "../../../utils/pause/frames";
|
||||
import { getFilename, getFileURL } from "../../../utils/source";
|
||||
import FrameMenu from "./FrameMenu";
|
||||
import FrameIndent from "./FrameIndent";
|
||||
import actions from "../../../actions";
|
||||
|
||||
import type { Frame, ThreadContext } from "../../../types";
|
||||
import type { Frame } from "../../../types";
|
||||
|
||||
type FrameTitleProps = {
|
||||
frame: Frame,
|
||||
@ -62,12 +61,11 @@ function FrameLocation({ frame, displayFullUrl = false }: FrameLocationProps) {
|
||||
FrameLocation.displayName = "FrameLocation";
|
||||
|
||||
type FrameComponentProps = {
|
||||
cx: ThreadContext,
|
||||
frame: Frame,
|
||||
selectedFrame: Frame,
|
||||
copyStackTrace: Function,
|
||||
toggleFrameworkGrouping: Function,
|
||||
selectFrame: typeof actions.selectFrame,
|
||||
selectFrame: Function,
|
||||
frameworkGroupingOn: boolean,
|
||||
hideLocation: boolean,
|
||||
shouldMapDisplayName: boolean,
|
||||
@ -109,7 +107,7 @@ export default class FrameComponent extends Component<FrameComponentProps> {
|
||||
if (e.button !== 0) {
|
||||
return;
|
||||
}
|
||||
this.props.selectFrame(this.props.cx, frame);
|
||||
this.props.selectFrame(frame);
|
||||
}
|
||||
|
||||
onKeyUp(
|
||||
@ -120,7 +118,7 @@ export default class FrameComponent extends Component<FrameComponentProps> {
|
||||
if (event.key != "Enter") {
|
||||
return;
|
||||
}
|
||||
this.props.selectFrame(this.props.cx, frame);
|
||||
this.props.selectFrame(frame);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -15,8 +15,7 @@ import FrameComponent from "./Frame";
|
||||
|
||||
import "./Group.css";
|
||||
|
||||
import actions from "../../../actions";
|
||||
import type { Frame, ThreadContext } from "../../../types";
|
||||
import type { Frame } from "../../../types";
|
||||
import Badge from "../../shared/Badge";
|
||||
import FrameIndent from "./FrameIndent";
|
||||
|
||||
@ -40,10 +39,9 @@ function FrameLocation({ frame, expanded }: FrameLocationProps) {
|
||||
FrameLocation.displayName = "FrameLocation";
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
group: Frame[],
|
||||
selectedFrame: Frame,
|
||||
selectFrame: typeof actions.selectFrame,
|
||||
selectFrame: Function,
|
||||
toggleFrameworkGrouping: Function,
|
||||
copyStackTrace: Function,
|
||||
toggleBlackBox: Function,
|
||||
@ -90,7 +88,6 @@ export default class Group extends Component<Props, State> {
|
||||
|
||||
renderFrames() {
|
||||
const {
|
||||
cx,
|
||||
group,
|
||||
selectFrame,
|
||||
selectedFrame,
|
||||
@ -117,7 +114,6 @@ export default class Group extends Component<Props, State> {
|
||||
}
|
||||
return acc.concat(
|
||||
<FrameComponent
|
||||
cx={cx}
|
||||
copyStackTrace={copyStackTrace}
|
||||
frame={frame}
|
||||
frameworkGroupingOn={frameworkGroupingOn}
|
||||
|
@ -8,7 +8,7 @@ import React, { Component } from "react";
|
||||
import { connect } from "../../../utils/connect";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import type { Frame, Why, ThreadContext } from "../../../types";
|
||||
import type { Frame, Why } from "../../../types";
|
||||
|
||||
import FrameComponent from "./Frame";
|
||||
import Group from "./Group";
|
||||
@ -24,8 +24,7 @@ import {
|
||||
getSelectedFrame,
|
||||
getCallStackFrames,
|
||||
getPauseReason,
|
||||
getCurrentThread,
|
||||
getThreadContext
|
||||
getCurrentThread
|
||||
} from "../../../selectors";
|
||||
|
||||
import "./Frames.css";
|
||||
@ -33,12 +32,11 @@ import "./Frames.css";
|
||||
const NUM_FRAMES_SHOWN = 7;
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
frames: Array<Frame>,
|
||||
frameworkGroupingOn: boolean,
|
||||
selectedFrame: Object,
|
||||
why: Why,
|
||||
selectFrame: typeof actions.selectFrame,
|
||||
selectFrame: Function,
|
||||
toggleBlackBox: Function,
|
||||
toggleFrameworkGrouping: Function,
|
||||
disableFrameTruncate: boolean,
|
||||
@ -116,7 +114,6 @@ class Frames extends Component<Props, State> {
|
||||
|
||||
renderFrames(frames: Frame[]) {
|
||||
const {
|
||||
cx,
|
||||
selectFrame,
|
||||
selectedFrame,
|
||||
toggleBlackBox,
|
||||
@ -139,7 +136,6 @@ class Frames extends Component<Props, State> {
|
||||
(frameOrGroup: FrameOrGroup) =>
|
||||
frameOrGroup.id ? (
|
||||
<FrameComponent
|
||||
cx={cx}
|
||||
frame={(frameOrGroup: any)}
|
||||
toggleFrameworkGrouping={this.toggleFrameworkGrouping}
|
||||
copyStackTrace={this.copyStackTrace}
|
||||
@ -155,7 +151,6 @@ class Frames extends Component<Props, State> {
|
||||
/>
|
||||
) : (
|
||||
<Group
|
||||
cx={cx}
|
||||
group={(frameOrGroup: any)}
|
||||
toggleFrameworkGrouping={this.toggleFrameworkGrouping}
|
||||
copyStackTrace={this.copyStackTrace}
|
||||
@ -221,7 +216,6 @@ class Frames extends Component<Props, State> {
|
||||
Frames.contextTypes = { l10n: PropTypes.object };
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
cx: getThreadContext(state),
|
||||
frames: getCallStackFrames(state),
|
||||
why: getPauseReason(state, getCurrentThread(state)),
|
||||
frameworkGroupingOn: getFrameworkGroupingState(state),
|
||||
|
@ -7,18 +7,13 @@
|
||||
import React from "react";
|
||||
import { shallow, mount } from "enzyme";
|
||||
import Frame from "../Frame.js";
|
||||
import {
|
||||
makeMockFrame,
|
||||
makeMockSource,
|
||||
mockthreadcx
|
||||
} from "../../../../utils/test-mockup";
|
||||
import { makeMockFrame, makeMockSource } from "../../../../utils/test-mockup";
|
||||
|
||||
import FrameMenu from "../FrameMenu";
|
||||
jest.mock("../FrameMenu", () => jest.fn());
|
||||
|
||||
function frameProperties(frame, selectedFrame: any, overrides = {}) {
|
||||
return {
|
||||
cx: mockthreadcx,
|
||||
frame,
|
||||
selectedFrame,
|
||||
copyStackTrace: jest.fn(),
|
||||
|
@ -7,11 +7,7 @@
|
||||
import React from "react";
|
||||
import { shallow } from "enzyme";
|
||||
import Group from "../Group.js";
|
||||
import {
|
||||
makeMockFrame,
|
||||
makeMockSource,
|
||||
mockthreadcx
|
||||
} from "../../../../utils/test-mockup";
|
||||
import { makeMockFrame, makeMockSource } from "../../../../utils/test-mockup";
|
||||
|
||||
import FrameMenu from "../FrameMenu";
|
||||
jest.mock("../FrameMenu", () => jest.fn());
|
||||
@ -19,7 +15,6 @@ jest.mock("../FrameMenu", () => jest.fn());
|
||||
function render(overrides = {}) {
|
||||
const frame = { ...makeMockFrame(), displayName: "foo", library: "Back" };
|
||||
const defaultProps = {
|
||||
cx: mockthreadcx,
|
||||
group: [frame],
|
||||
selectedFrame: frame,
|
||||
frameworkGroupingOn: true,
|
||||
|
@ -155,14 +155,6 @@ exports[`Group passes the getFrameTitle prop to the Frame components 1`] = `
|
||||
/>
|
||||
<Frame
|
||||
copyStackTrace={[MockFunction]}
|
||||
cx={
|
||||
Object {
|
||||
"isPaused": false,
|
||||
"navigateCounter": 0,
|
||||
"pauseCounter": 0,
|
||||
"thread": "FakeThread",
|
||||
}
|
||||
}
|
||||
disableContextMenu={false}
|
||||
displayFullUrl={false}
|
||||
frame={
|
||||
@ -266,14 +258,6 @@ exports[`Group passes the getFrameTitle prop to the Frame components 1`] = `
|
||||
/>
|
||||
<Frame
|
||||
copyStackTrace={[MockFunction]}
|
||||
cx={
|
||||
Object {
|
||||
"isPaused": false,
|
||||
"navigateCounter": 0,
|
||||
"pauseCounter": 0,
|
||||
"thread": "FakeThread",
|
||||
}
|
||||
}
|
||||
disableContextMenu={false}
|
||||
displayFullUrl={false}
|
||||
frame={
|
||||
@ -377,14 +361,6 @@ exports[`Group passes the getFrameTitle prop to the Frame components 1`] = `
|
||||
/>
|
||||
<Frame
|
||||
copyStackTrace={[MockFunction]}
|
||||
cx={
|
||||
Object {
|
||||
"isPaused": false,
|
||||
"navigateCounter": 0,
|
||||
"pauseCounter": 0,
|
||||
"thread": "FakeThread",
|
||||
}
|
||||
}
|
||||
disableContextMenu={false}
|
||||
displayFullUrl={false}
|
||||
frame={
|
||||
@ -642,14 +618,6 @@ exports[`Group renders group with anonymous functions 2`] = `
|
||||
/>
|
||||
<Frame
|
||||
copyStackTrace={[MockFunction]}
|
||||
cx={
|
||||
Object {
|
||||
"isPaused": false,
|
||||
"navigateCounter": 0,
|
||||
"pauseCounter": 0,
|
||||
"thread": "FakeThread",
|
||||
}
|
||||
}
|
||||
disableContextMenu={false}
|
||||
displayFullUrl={false}
|
||||
frame={
|
||||
@ -752,14 +720,6 @@ exports[`Group renders group with anonymous functions 2`] = `
|
||||
/>
|
||||
<Frame
|
||||
copyStackTrace={[MockFunction]}
|
||||
cx={
|
||||
Object {
|
||||
"isPaused": false,
|
||||
"navigateCounter": 0,
|
||||
"pauseCounter": 0,
|
||||
"thread": "FakeThread",
|
||||
}
|
||||
}
|
||||
disableContextMenu={false}
|
||||
displayFullUrl={false}
|
||||
frame={
|
||||
@ -862,14 +822,6 @@ exports[`Group renders group with anonymous functions 2`] = `
|
||||
/>
|
||||
<Frame
|
||||
copyStackTrace={[MockFunction]}
|
||||
cx={
|
||||
Object {
|
||||
"isPaused": false,
|
||||
"navigateCounter": 0,
|
||||
"pauseCounter": 0,
|
||||
"thread": "FakeThread",
|
||||
}
|
||||
}
|
||||
disableContextMenu={false}
|
||||
displayFullUrl={false}
|
||||
frame={
|
||||
|
@ -9,14 +9,13 @@ import { connect } from "../../utils/connect";
|
||||
import classnames from "classnames";
|
||||
|
||||
import actions from "../../actions";
|
||||
import { getCurrentThread, getIsPaused, getContext } from "../../selectors";
|
||||
import { getCurrentThread, getIsPaused } from "../../selectors";
|
||||
import { getDisplayName, isWorker } from "../../utils/workers";
|
||||
import AccessibleImage from "../shared/AccessibleImage";
|
||||
|
||||
import type { Context, Thread } from "../../types";
|
||||
import type { Thread } from "../../types";
|
||||
|
||||
type Props = {
|
||||
cx: Context,
|
||||
selectThread: typeof actions.selectThread,
|
||||
isPaused: boolean,
|
||||
thread: Thread,
|
||||
@ -26,7 +25,7 @@ type Props = {
|
||||
export class Worker extends Component<Props> {
|
||||
onSelectThread = () => {
|
||||
const { thread } = this.props;
|
||||
this.props.selectThread(this.props.cx, thread.actor);
|
||||
this.props.selectThread(thread.actor);
|
||||
};
|
||||
|
||||
render() {
|
||||
@ -58,7 +57,6 @@ export class Worker extends Component<Props> {
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, props: Props) => ({
|
||||
cx: getContext(state),
|
||||
currentThread: getCurrentThread(state),
|
||||
isPaused: getIsPaused(state, props.thread.actor)
|
||||
});
|
||||
|
@ -21,8 +21,7 @@ import {
|
||||
getShouldPauseOnExceptions,
|
||||
getShouldPauseOnCaughtExceptions,
|
||||
getWorkers,
|
||||
getCurrentThread,
|
||||
getThreadContext
|
||||
getCurrentThread
|
||||
} from "../../selectors";
|
||||
|
||||
import AccessibleImage from "../shared/AccessibleImage";
|
||||
@ -43,7 +42,7 @@ import Scopes from "./Scopes";
|
||||
|
||||
import "./SecondaryPanes.css";
|
||||
|
||||
import type { Expression, Frame, WorkerList, ThreadContext } from "../../types";
|
||||
import type { Expression, Frame, WorkerList } from "../../types";
|
||||
|
||||
type AccordionPaneItem = {
|
||||
header: string,
|
||||
@ -73,7 +72,6 @@ type State = {
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cx: ThreadContext,
|
||||
expressions: List<Expression>,
|
||||
hasFrames: boolean,
|
||||
horizontal: boolean,
|
||||
@ -116,7 +114,6 @@ class SecondaryPanes extends Component<Props, State> {
|
||||
|
||||
renderBreakpointsToggle() {
|
||||
const {
|
||||
cx,
|
||||
toggleAllBreakpoints,
|
||||
breakpoints,
|
||||
breakpointsDisabled
|
||||
@ -138,7 +135,7 @@ class SecondaryPanes extends Component<Props, State> {
|
||||
key: "breakpoints-toggle",
|
||||
onChange: e => {
|
||||
e.stopPropagation();
|
||||
toggleAllBreakpoints(cx, !breakpointsDisabled);
|
||||
toggleAllBreakpoints(!breakpointsDisabled);
|
||||
},
|
||||
onClick: e => e.stopPropagation(),
|
||||
checked: !breakpointsDisabled && !isIndeterminate,
|
||||
@ -165,7 +162,7 @@ class SecondaryPanes extends Component<Props, State> {
|
||||
debugBtn(
|
||||
evt => {
|
||||
evt.stopPropagation();
|
||||
this.props.evaluateExpressions(this.props.cx);
|
||||
this.props.evaluateExpressions();
|
||||
},
|
||||
"refresh",
|
||||
"refresh",
|
||||
@ -465,7 +462,6 @@ const mapStateToProps = state => {
|
||||
const thread = getCurrentThread(state);
|
||||
|
||||
return {
|
||||
cx: getThreadContext(state),
|
||||
expressions: getExpressions(state),
|
||||
hasFrames: !!getTopFrame(state, thread),
|
||||
breakpoints: getBreakpointsList(state),
|
||||
|
@ -7,12 +7,10 @@
|
||||
import React from "react";
|
||||
import { shallow } from "enzyme";
|
||||
import CommandBar from "../CommandBar";
|
||||
import { mockthreadcx } from "../../../utils/test-mockup";
|
||||
|
||||
describe("CommandBar", () => {
|
||||
it("f8 key command calls props.breakOnNext when not in paused state", () => {
|
||||
const props = {
|
||||
cx: mockthreadcx,
|
||||
breakOnNext: jest.fn(),
|
||||
resume: jest.fn(),
|
||||
isPaused: false
|
||||
@ -45,7 +43,6 @@ describe("CommandBar", () => {
|
||||
|
||||
it("f8 key command calls props.resume when in paused state", () => {
|
||||
const props = {
|
||||
cx: { ...mockthreadcx, isPaused: true },
|
||||
breakOnNext: jest.fn(),
|
||||
resume: jest.fn(),
|
||||
isPaused: true
|
||||
|
@ -8,7 +8,6 @@ import React from "react";
|
||||
import { shallow } from "enzyme";
|
||||
import Outline from "../../components/PrimaryPanes/Outline";
|
||||
import { makeSymbolDeclaration } from "../../utils/test-head";
|
||||
import { mockcx } from "../../utils/test-mockup";
|
||||
import { showMenu } from "devtools-contextmenu";
|
||||
import { copyToTheClipboard } from "../../utils/clipboard";
|
||||
|
||||
@ -20,7 +19,6 @@ const mockFunctionText = "mock function text";
|
||||
|
||||
function generateDefaults(overrides) {
|
||||
return {
|
||||
cx: mockcx,
|
||||
selectLocation: jest.fn(),
|
||||
selectedSource: { id: sourceId },
|
||||
getFunctionText: jest.fn().mockReturnValue(mockFunctionText),
|
||||
@ -72,10 +70,7 @@ describe("Outline", () => {
|
||||
const { selectLocation } = props;
|
||||
const listItem = component.find("li").first();
|
||||
listItem.simulate("click");
|
||||
expect(selectLocation).toHaveBeenCalledWith(mockcx, {
|
||||
line: startLine,
|
||||
sourceId
|
||||
});
|
||||
expect(selectLocation).toHaveBeenCalledWith({ line: startLine, sourceId });
|
||||
});
|
||||
|
||||
describe("renders outline", () => {
|
||||
@ -215,7 +210,7 @@ describe("Outline", () => {
|
||||
|
||||
await component.find("h2").simulate("click", {});
|
||||
|
||||
expect(props.selectLocation).toHaveBeenCalledWith(mockcx, {
|
||||
expect(props.selectLocation).toHaveBeenCalledWith({
|
||||
line: 24,
|
||||
sourceId: sourceId
|
||||
});
|
||||
|
@ -8,7 +8,6 @@ import React from "react";
|
||||
import { mount, shallow } from "enzyme";
|
||||
import { ProjectSearch } from "../ProjectSearch";
|
||||
import { statusType } from "../../reducers/project-text-search";
|
||||
import { mockcx } from "../../utils/test-mockup";
|
||||
|
||||
const hooks = { on: [], off: [] };
|
||||
const shortcuts = {
|
||||
@ -76,7 +75,6 @@ const testMatch = {
|
||||
|
||||
function render(overrides = {}, mounted = false) {
|
||||
const props = {
|
||||
cx: mockcx,
|
||||
status: "DONE",
|
||||
sources: {},
|
||||
results: [],
|
||||
@ -189,7 +187,7 @@ describe("ProjectSearch", () => {
|
||||
component
|
||||
.find("SearchInput input")
|
||||
.simulate("keydown", { key: "Enter", stopPropagation: jest.fn() });
|
||||
expect(searchSources).toHaveBeenCalledWith(mockcx, "foo");
|
||||
expect(searchSources).toHaveBeenCalledWith("foo");
|
||||
});
|
||||
|
||||
it("onEnterPress shortcut no match or setExpanded", () => {
|
||||
@ -217,7 +215,7 @@ describe("ProjectSearch", () => {
|
||||
);
|
||||
component.instance().state.focusedItem = { ...testMatch };
|
||||
shortcuts.dispatch("Enter");
|
||||
expect(selectSpecificLocation).toHaveBeenCalledWith(mockcx, {
|
||||
expect(selectSpecificLocation).toHaveBeenCalledWith({
|
||||
sourceId: "some-target/source42",
|
||||
line: 3,
|
||||
column: 30
|
||||
|
@ -8,7 +8,6 @@
|
||||
import React from "react";
|
||||
import { shallow, mount } from "enzyme";
|
||||
import { QuickOpenModal } from "../QuickOpenModal";
|
||||
import { mockcx } from "../../utils/test-mockup";
|
||||
|
||||
jest.mock("fuzzaldrin-plus");
|
||||
|
||||
@ -16,7 +15,6 @@ import { filter } from "fuzzaldrin-plus";
|
||||
|
||||
function generateModal(propOverrides, renderType = "shallow") {
|
||||
const props = {
|
||||
cx: mockcx,
|
||||
enabled: false,
|
||||
query: "",
|
||||
searchType: "sources",
|
||||
@ -316,7 +314,7 @@ describe("QuickOpenModal", () => {
|
||||
key: "Enter"
|
||||
};
|
||||
wrapper.find("SearchInput").simulate("keydown", event);
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith(mockcx, {
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith({
|
||||
column: 12,
|
||||
line: 34,
|
||||
sourceId: ""
|
||||
@ -338,7 +336,7 @@ describe("QuickOpenModal", () => {
|
||||
key: "Enter"
|
||||
};
|
||||
wrapper.find("SearchInput").simulate("keydown", event);
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith(mockcx, {
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith({
|
||||
column: 12,
|
||||
line: 34,
|
||||
sourceId: sourceId
|
||||
@ -449,7 +447,7 @@ describe("QuickOpenModal", () => {
|
||||
key: "Enter"
|
||||
};
|
||||
wrapper.find("SearchInput").simulate("keydown", event);
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith(mockcx, {
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith({
|
||||
column: undefined,
|
||||
sourceId: id,
|
||||
line: 0
|
||||
@ -479,7 +477,7 @@ describe("QuickOpenModal", () => {
|
||||
key: "Enter"
|
||||
};
|
||||
wrapper.find("SearchInput").simulate("keydown", event);
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith(mockcx, {
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith({
|
||||
column: undefined,
|
||||
line: 0,
|
||||
sourceId: ""
|
||||
@ -509,7 +507,7 @@ describe("QuickOpenModal", () => {
|
||||
key: "Enter"
|
||||
};
|
||||
wrapper.find("SearchInput").simulate("keydown", event);
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith(mockcx, {
|
||||
expect(props.selectSpecificLocation).toHaveBeenCalledWith({
|
||||
column: 4,
|
||||
line: 3,
|
||||
sourceId: id
|
||||
|
@ -44,11 +44,6 @@ exports[`ProjectSearch found search results 1`] = `
|
||||
activeSearch="project"
|
||||
clearSearch={[MockFunction]}
|
||||
closeProjectSearch={[MockFunction]}
|
||||
cx={
|
||||
Object {
|
||||
"navigateCounter": 0,
|
||||
}
|
||||
}
|
||||
doSearchForHighlight={[MockFunction]}
|
||||
query="match"
|
||||
results={
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user