Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit edf2ac1

Browse files
loganfsmythjasonLaster
authored andcommitted
[Scopes] Map original scopes to server scopes (#5215)
1 parent 6230028 commit edf2ac1

File tree

22 files changed

+1020
-476
lines changed

22 files changed

+1020
-476
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/workers/parser/tests/fixtures/functionNames.js

flow-typed/debugger-html.js

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -254,32 +254,6 @@ declare module "debugger-html" {
254254
loadedState: "unloaded" | "loading" | "loaded"
255255
};
256256

257-
/**
258-
* SourceScope
259-
* @memberof types
260-
* @static
261-
*/
262-
declare type SourceScope = {
263-
type: string,
264-
start: Location,
265-
end: Location,
266-
bindings: {
267-
[name: string]: Location[]
268-
}
269-
};
270-
271-
/*
272-
* MappedScopeBindings
273-
* @memberof types
274-
* @static
275-
*/
276-
declare type MappedScopeBindings = {
277-
type: string,
278-
bindings: {
279-
[originalName: string]: string
280-
}
281-
};
282-
283257
/**
284258
* Script
285259
* This describes scripts which are sent to the debug server to be eval'd
@@ -304,11 +278,6 @@ declare module "debugger-html" {
304278
[name: string]: BindingContents
305279
};
306280

307-
declare type SyntheticScope = {
308-
type: string,
309-
bindingsNames: string[]
310-
};
311-
312281
/**
313282
* Scope
314283
* @memberof types
@@ -321,22 +290,14 @@ declare module "debugger-html" {
321290
arguments: Array<ScopeBindings>,
322291
variables: ScopeBindings
323292
},
324-
sourceBindings?: {
325-
[originalName: string]: string
326-
},
327-
object: Object,
328-
function: {
293+
object: ?Object,
294+
function: ?{
329295
actor: ActorId,
330296
class: string,
331297
displayName: string,
332298
location: Location,
333299
parameterNames: string[]
334300
},
335-
syntheticScopes?: {
336-
scopes: SyntheticScope[],
337-
groupIndex: number,
338-
groupLength: number
339-
},
340301
type: string
341302
};
342303

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
"codemirror": "^5.28.0",
7474
"devtools-launchpad": "^0.0.115",
7575
"devtools-linters": "^0.0.4",
76-
"devtools-map-bindings": "^0.3.2",
7776
"devtools-reps": "^0.19.2",
7877
"devtools-source-map": "^0.14.7",
7978
"devtools-splitter": "^0.0.6",
@@ -141,7 +140,7 @@
141140
"mock-require": "^3.0.0",
142141
"node-emoji": "^1.8.1",
143142
"npm-run-all": "^4.0.2",
144-
"prettier": "^1.6.1",
143+
"prettier": "^1.10.2",
145144
"react-addons-perf": "^15.4.2",
146145
"react-test-renderer": "15.6.2",
147146
"remark-cli": "^5.0.0",

src/actions/expressions.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,5 @@ export async function getMappedExpression(
143143
generatedLocation: Location,
144144
expression: string
145145
): Promise<string> {
146-
const astScopes = await parser.getScopes(generatedLocation);
147-
148-
const generatedScopes = await sourceMaps.getLocationScopes(
149-
generatedLocation,
150-
astScopes
151-
);
152-
153-
if (!generatedScopes) {
154-
return expression;
155-
}
156-
157-
return parser.replaceOriginalVariableName(expression, generatedScopes);
146+
return expression;
158147
}

src/actions/pause/fetchScopes.js

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,10 @@
77
import { getSource, getSelectedFrame, getFrameScope } from "../../selectors";
88
import { features } from "../../utils/prefs";
99
import { isGeneratedId } from "devtools-source-map";
10-
import { loadSourceText } from "../sources/loadSourceText";
11-
import { getScopes } from "../../workers/parser";
12-
13-
// eslint-disable-next-line max-len
14-
import { updateScopeBindings } from "devtools-map-bindings/src/updateScopeBindings";
15-
16-
import type { Frame, Scope, SourceScope } from "debugger-html";
10+
import { mapScopes } from "./mapScopes";
1711

1812
import type { ThunkArgs } from "../types";
1913

20-
function mapScopes(scopes: Scope, frame: Frame) {
21-
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
22-
const mappedScopes = await updateScopeBindings(
23-
scopes,
24-
frame.generatedLocation,
25-
frame.location,
26-
{
27-
async getSourceMapsScopes(location) {
28-
const astScopes: ?(SourceScope[]) = await getScopes(location);
29-
return sourceMaps.getLocationScopes(location, astScopes);
30-
},
31-
async getOriginalSourceScopes(location) {
32-
const source = getSource(getState(), location.sourceId);
33-
await dispatch(loadSourceText(source));
34-
return getScopes(location);
35-
}
36-
}
37-
);
38-
39-
dispatch({
40-
type: "MAP_SCOPES",
41-
frame,
42-
scopes: mappedScopes
43-
});
44-
};
45-
}
46-
4714
export function fetchScopes() {
4815
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
4916
const frame = getSelectedFrame(getState());

0 commit comments

Comments
 (0)