Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/actions/breakpoints/addBreakpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ import { getTextAtPosition } from "../../utils/source";
import { recordEvent } from "../../utils/telemetry";
import { features } from "../../utils/prefs";

import type { SourceLocation, Breakpoint } from "../../types";
import type {
BreakpointOptions,
Breakpoint,
SourceLocation
} from "../../types";
import type { ThunkArgs } from "../types";
import type { addBreakpointOptions } from "./";

async function addBreakpointPromise(getState, client, sourceMaps, breakpoint) {
const state = getState();
Expand Down Expand Up @@ -62,7 +65,7 @@ async function addBreakpointPromise(getState, client, sourceMaps, breakpoint) {

const { id, actualLocation } = await client.setBreakpoint(
generatedLocation,
breakpoint.condition,
breakpoint.options,
isOriginalId(location.sourceId)
);

Expand All @@ -80,10 +83,8 @@ async function addBreakpointPromise(getState, client, sourceMaps, breakpoint) {
const newBreakpoint = {
id,
disabled: false,
hidden: breakpoint.hidden,
loading: false,
condition: breakpoint.condition,
log: breakpoint.log,
options: breakpoint.options,
location: newLocation,
astLocation,
generatedLocation: newGeneratedLocation,
Expand Down Expand Up @@ -126,9 +127,17 @@ export function enableBreakpoint(breakpoint: Breakpoint) {
};
}

/**
* Add a new breakpoint
*
* @memberof actions/breakpoints
* @static
* @param {BreakpointOptions} options Any options for the new breakpoint.
*/

export function addBreakpoint(
location: SourceLocation,
{ condition, hidden, log = false }: addBreakpointOptions = {}
options: BreakpointOptions = {}
) {
return async ({ dispatch, getState, sourceMaps, client }: ThunkArgs) => {
recordEvent("add_breakpoint");
Expand All @@ -137,7 +146,7 @@ export function addBreakpoint(
location = getFirstPausePointLocation(getState(), location);
}

const breakpoint = createBreakpoint(location, { condition, hidden, log });
const breakpoint = createBreakpoint(location, options);

return dispatch({
type: "ADD_BREAKPOINT",
Expand Down
28 changes: 11 additions & 17 deletions src/actions/breakpoints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,14 @@ import { isEmptyLineInSource } from "../../reducers/ast";
import type { ThunkArgs, Action } from "../types";
import type {
Breakpoint,
BreakpointOptions,
Source,
SourceLocation,
XHRBreakpoint
} from "../../types";

import { recordEvent } from "../../utils/telemetry";

export type addBreakpointOptions = {
condition?: string,
hidden?: boolean,
log?: boolean
};

/**
* Remove a single breakpoint
*
Expand Down Expand Up @@ -260,25 +255,24 @@ export function remapBreakpoints(sourceId: string) {
}

/**
* Update the condition of a breakpoint.
* Update the options of a breakpoint.
*
* @throws {Error} "not implemented"
* @memberof actions/breakpoints
* @static
* @param {SourceLocation} location
* @see DebuggerController.Breakpoints.addBreakpoint
* @param {string} condition
* The condition to set on the breakpoint
* @param {Boolean} $1.disabled Disable value for breakpoint value
* @param {Object} options
* Any options to set on the breakpoint
*/
export function setBreakpointCondition(
export function setBreakpointOptions(
location: SourceLocation,
{ condition, log = false }: addBreakpointOptions = {}
options: BreakpointOptions = {}
) {
return async ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
const bp = getBreakpoint(getState(), location);
if (!bp) {
return dispatch(addBreakpoint(location, { condition, log }));
return dispatch(addBreakpoint(location, options));
}

if (bp.loading) {
Expand All @@ -289,20 +283,20 @@ export function setBreakpointCondition(
await dispatch(enableBreakpoint(bp));
}

await client.setBreakpointCondition(
await client.setBreakpointOptions(
bp.id,
location,
condition,
options,
isOriginalId(bp.location.sourceId)
);

const newBreakpoint = { ...bp, disabled: false, condition, log };
const newBreakpoint = { ...bp, disabled: false, options };

assertBreakpoint(newBreakpoint);

return dispatch(
({
type: "SET_BREAKPOINT_CONDITION",
type: "SET_BREAKPOINT_OPTIONS",
breakpoint: newBreakpoint
}: Action)
);
Expand Down
4 changes: 2 additions & 2 deletions src/actions/breakpoints/syncBreakpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export async function syncBreakpointPromise(

const { id, actualLocation } = await client.setBreakpoint(
scopedGeneratedLocation,
pendingBreakpoint.condition,
isOriginalId(sourceId)
isOriginalId(sourceId),
pendingBreakpoint.options
);

// the breakpoint might have slid server side, so we want to get the location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ Object {
"sourceUrl": "http://localhost:8000/examples/a",
},
},
"condition": null,
"disabled": false,
"generatedLocation": Object {
"line": 7,
"sourceId": "a",
"sourceUrl": "http://localhost:8000/examples/a",
},
"hidden": false,
"id": "a:5:",
"loading": false,
"location": Object {
"line": 7,
"sourceId": "a",
"sourceUrl": "http://localhost:8000/examples/a",
},
"log": false,
"options": Object {
"condition": null,
"hidden": false,
"logValue": null,
},
"originalText": "",
"text": "",
}
Expand All @@ -46,22 +48,24 @@ Array [
"sourceUrl": "http://localhost:8000/examples/a",
},
},
"condition": null,
"disabled": false,
"generatedLocation": Object {
"line": 2,
"sourceId": "a",
"sourceUrl": "http://localhost:8000/examples/a",
},
"hidden": false,
"id": "hi",
"loading": false,
"location": Object {
"line": 2,
"sourceId": "a",
"sourceUrl": "http://localhost:8000/examples/a",
},
"log": false,
"options": Object {
"condition": null,
"hidden": false,
"logValue": null,
},
"originalText": "return a",
"text": "return a",
},
Expand Down Expand Up @@ -97,14 +101,12 @@ Object {
"sourceUrl": "http://localhost:8000/examples/a.js",
},
},
"condition": null,
"disabled": false,
"generatedLocation": Object {
"line": 1,
"sourceId": "a.js",
"sourceUrl": "http://localhost:8000/examples/a.js",
},
"hidden": false,
"id": "hi",
"loading": false,
"location": Object {
Expand All @@ -113,7 +115,11 @@ Object {
"sourceId": "a.js/originalSource-d6d70368d5c252598541e693a7ad6c27",
"sourceUrl": "http://localhost:8000/examples/a.js:formatted",
},
"log": false,
"options": Object {
"condition": null,
"hidden": false,
"logValue": null,
},
"originalText": "function a() {",
"text": "function a() {",
}
Expand All @@ -133,22 +139,24 @@ Array [
"sourceUrl": "http://localhost:8000/examples/a",
},
},
"condition": null,
"disabled": true,
"generatedLocation": Object {
"line": 5,
"sourceId": "a",
"sourceUrl": "http://localhost:8000/examples/a",
},
"hidden": false,
"id": "hi",
"loading": false,
"location": Object {
"line": 5,
"sourceId": "a",
"sourceUrl": "http://localhost:8000/examples/a",
},
"log": false,
"options": Object {
"condition": null,
"hidden": false,
"logValue": null,
},
"originalText": "",
"text": "",
},
Expand Down
Loading