Bug 1546202 - Part 2: Change parser worker to work with a trimmed-down AstSource instead of the full Source. r=jlast
authorLogan Smyth <loganfsmyth@gmail.com>
Tue, 23 Apr 2019 16:51:11 +0000
changeset 470542 d99fa29130d5e1f5a03a13b70ea3460e462d1344
parent 470541 1c38471c164e3cad23fcc6ef3ff88c0cfdacce2a
child 470543 800d67478a31025bf0c61a6d41af87ece51c75cb
push id83816
push userlsmyth@mozilla.com
push dateTue, 23 Apr 2019 18:22:02 +0000
treeherderautoland@f81c7ca6d292 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1546202
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546202 - Part 2: Change parser worker to work with a trimmed-down AstSource instead of the full Source. r=jlast Depends on D28408 Differential Revision: https://phabricator.services.mozilla.com/D28409
devtools/client/debugger/bin/module-manifest.json
devtools/client/debugger/dist/parser-worker.js
devtools/client/debugger/src/utils/breakpoint/tests/astBreakpointLocation.spec.js
devtools/client/debugger/src/utils/tests/ast.spec.js
devtools/client/debugger/src/utils/tests/function.spec.js
devtools/client/debugger/src/workers/parser/index.js
devtools/client/debugger/src/workers/parser/sources.js
devtools/client/debugger/src/workers/parser/tests/findOutOfScopeLocations.spec.js
devtools/client/debugger/src/workers/parser/tests/framework.spec.js
devtools/client/debugger/src/workers/parser/tests/getScopes.spec.js
devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js
devtools/client/debugger/src/workers/parser/tests/helpers/index.js
devtools/client/debugger/src/workers/parser/tests/steps.spec.js
devtools/client/debugger/src/workers/parser/types.js
devtools/client/debugger/src/workers/parser/utils/formatSymbols.js
devtools/client/debugger/src/workers/parser/utils/tests/ast.spec.js
--- a/devtools/client/debugger/bin/module-manifest.json
+++ b/devtools/client/debugger/bin/module-manifest.json
@@ -10,17 +10,17 @@
           "0": 0,
           "1": 1
         }
       },
       "chunks": {
         "byName": {},
         "byBlocks": {},
         "usedIds": {
-          "0": 0
+          "1": 1
         }
       }
     }
   ],
   "extract-text-webpack-plugin ../../extract-text-webpack-plugin/dist ../../css-loader/index.js??ref--3-1!../../postcss-loader/lib/index.js!../../react-aria-components/src/tabs/tab.css": [
     {
       "modules": {
         "byIdentifier": {
@@ -31,17 +31,17 @@
           "0": 0,
           "1": 1
         }
       },
       "chunks": {
         "byName": {},
         "byBlocks": {},
         "usedIds": {
-          "0": 0
+          "1": 1
         }
       }
     }
   ],
   "extract-text-webpack-plugin ../../extract-text-webpack-plugin/dist ../../css-loader/index.js??ref--3-1!../../postcss-loader/lib/index.js!../../react-aria-components/src/tabs/tab-list.css": [
     {
       "modules": {
         "byIdentifier": {
@@ -52,17 +52,17 @@
           "0": 0,
           "1": 1
         }
       },
       "chunks": {
         "byName": {},
         "byBlocks": {},
         "usedIds": {
-          "0": 0
+          "1": 1
         }
       }
     }
   ],
   "extract-text-webpack-plugin ../../extract-text-webpack-plugin/dist ../../css-loader/index.js??ref--3-1!../../postcss-loader/lib/index.js!../../devtools-contextmenu/menu.css": [
     {
       "modules": {
         "byIdentifier": {
@@ -73,17 +73,17 @@
           "0": 0,
           "1": 1
         }
       },
       "chunks": {
         "byName": {},
         "byBlocks": {},
         "usedIds": {
-          "0": 0
+          "1": 1
         }
       }
     }
   ],
   "extract-text-webpack-plugin ../../extract-text-webpack-plugin/dist ../../css-loader/index.js??ref--3-1!../../postcss-loader/lib/index.js!../../../packages/devtools-components/src/tree.css": [
     {
       "modules": {
         "byIdentifier": {
@@ -94,17 +94,17 @@
           "0": 0,
           "1": 1
         }
       },
       "chunks": {
         "byName": {},
         "byBlocks": {},
         "usedIds": {
-          "0": 0
+          "1": 1
         }
       }
     }
   ],
   "extract-text-webpack-plugin ../../extract-text-webpack-plugin/dist ../../css-loader/index.js??ref--3-1!../../postcss-loader/lib/index.js!../../../packages/devtools-reps/src/object-inspector/components/ObjectInspector.css": [
     {
       "modules": {
         "byIdentifier": {
@@ -115,17 +115,17 @@
           "0": 0,
           "1": 1
         }
       },
       "chunks": {
         "byName": {},
         "byBlocks": {},
         "usedIds": {
-          "0": 0
+          "1": 1
         }
       }
     }
   ],
   "extract-text-webpack-plugin ../../extract-text-webpack-plugin/dist ../../css-loader/index.js??ref--3-1!../../postcss-loader/lib/index.js!../../../packages/devtools-reps/src/reps/reps.css": [
     {
       "modules": {
         "byIdentifier": {
@@ -136,17 +136,17 @@
           "0": 0,
           "1": 1
         }
       },
       "chunks": {
         "byName": {},
         "byBlocks": {},
         "usedIds": {
-          "0": 0
+          "1": 1
         }
       }
     }
   ],
   "modules": {
     "byIdentifier": {
       "external \"devtools/client/shared/vendor/react-prop-types\"": 0,
       "external \"devtools/client/shared/vendor/react-dom-factories\"": 1,
--- a/devtools/client/debugger/dist/parser-worker.js
+++ b/devtools/client/debugger/dist/parser-worker.js
@@ -16990,34 +16990,35 @@ module.exports = isEmpty;
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.setSource = setSource;
 exports.getSource = getSource;
 exports.clearSources = clearSources;
 
 
-let cachedSources = new Map(); /* 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/>. */
+const cachedSources = new Map(); /* 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/>. */
 
 function setSource(source) {
   cachedSources.set(source.id, source);
 }
 
 function getSource(sourceId) {
-  if (!cachedSources.has(sourceId)) {
+  const source = cachedSources.get(sourceId);
+  if (!source) {
     throw new Error(`Parser: source ${sourceId} was not provided.`);
   }
 
-  return cachedSources.get(sourceId);
+  return source;
 }
 
 function clearSources() {
-  cachedSources = new Map();
+  cachedSources.clear();
 }
 
 /***/ }),
 /* 156 */
 /***/ (function(module, exports, __webpack_require__) {
 
 "use strict";
 
--- a/devtools/client/debugger/src/utils/breakpoint/tests/astBreakpointLocation.spec.js
+++ b/devtools/client/debugger/src/utils/breakpoint/tests/astBreakpointLocation.spec.js
@@ -1,27 +1,25 @@
 /* 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 { getASTLocation } from "../astBreakpointLocation.js";
 import {
-  getSource,
-  getOriginalSource
+  populateSource,
+  populateOriginalSource
 } from "../../../workers/parser/tests/helpers";
-import { setSource } from "../../../workers/parser/sources";
 import { getSymbols } from "../../../workers/parser/getSymbols";
 import cases from "jest-in-case";
 
 async function setup({ file, location, functionName, original }) {
-  const source = original ? getOriginalSource(file) : getSource(file);
+  const source = original ? populateOriginalSource(file) : populateSource(file);
 
-  setSource(source);
   const symbols = getSymbols(source.id);
 
   const astLocation = getASTLocation(source, symbols, location);
   expect(astLocation.name).toBe(functionName);
   expect(astLocation).toMatchSnapshot();
 }
 
 describe("ast", () => {
--- a/devtools/client/debugger/src/utils/tests/ast.spec.js
+++ b/devtools/client/debugger/src/utils/tests/ast.spec.js
@@ -2,23 +2,21 @@
  * 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 { findBestMatchExpression } from "../ast";
 
 import { getSymbols } from "../../workers/parser/getSymbols";
-import { getSource } from "../../workers/parser/tests/helpers";
-import { setSource } from "../../workers/parser/sources";
+import { populateSource } from "../../workers/parser/tests/helpers";
 
 describe("find the best expression for the token", () => {
-  const source = getSource("computed-props");
-  setSource(source);
-  const symbols = getSymbols("computed-props");
+  const source = populateSource("computed-props");
+  const symbols = getSymbols(source.id);
 
   it("should find the identifier", () => {
     const expression = findBestMatchExpression(symbols, {
       line: 1,
       column: 13
     });
     expect(expression).toMatchSnapshot();
   });
--- a/devtools/client/debugger/src/utils/tests/function.spec.js
+++ b/devtools/client/debugger/src/utils/tests/function.spec.js
@@ -2,69 +2,62 @@
  * 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 { findFunctionText } from "../function";
 
 import { getSymbols } from "../../workers/parser/getSymbols";
-import { getOriginalSource } from "../../workers/parser/tests/helpers";
-import { setSource } from "../../workers/parser/sources";
+import { populateOriginalSource } from "../../workers/parser/tests/helpers";
 
 describe("function", () => {
   describe("findFunctionText", () => {
     it("finds function", () => {
-      const source = getOriginalSource("func");
-      setSource(source);
+      const source = populateOriginalSource("func");
       const symbols = getSymbols(source.id);
       const text = findFunctionText(14, source, symbols);
       expect(text).toMatchSnapshot();
     });
 
     it("finds function signature", () => {
-      const source = getOriginalSource("func");
-      setSource(source);
+      const source = populateOriginalSource("func");
       const symbols = getSymbols(source.id);
 
       const text = findFunctionText(13, source, symbols);
       expect(text).toMatchSnapshot();
     });
 
     it("misses function closing brace", () => {
-      const source = getOriginalSource("func");
-      setSource(source);
+      const source = populateOriginalSource("func");
       const symbols = getSymbols(source.id);
 
       const text = findFunctionText(15, source, symbols);
 
       // TODO: we should try and match the closing bracket.
       expect(text).toEqual(null);
     });
 
     it("finds property function", () => {
-      const source = getOriginalSource("func");
-      setSource(source);
+      const source = populateOriginalSource("func");
       const symbols = getSymbols(source.id);
 
       const text = findFunctionText(29, source, symbols);
       expect(text).toMatchSnapshot();
     });
 
     it("finds class function", () => {
-      const source = getOriginalSource("func");
-      setSource(source);
+      const source = populateOriginalSource("func");
       const symbols = getSymbols(source.id);
 
       const text = findFunctionText(33, source, symbols);
       expect(text).toMatchSnapshot();
     });
 
     it("cant find function", () => {
-      const source = getOriginalSource("func");
-      setSource(source);
+      const source = populateOriginalSource("func");
       const symbols = getSymbols(source.id);
 
       const text = findFunctionText(20, source, symbols);
       expect(text).toEqual(null);
     });
   });
 });
--- a/devtools/client/debugger/src/workers/parser/index.js
+++ b/devtools/client/debugger/src/workers/parser/index.js
@@ -2,17 +2,17 @@
  * 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 { workerUtils } from "devtools-utils";
 const { WorkerDispatcher } = workerUtils;
 
-import type { AstLocation, AstPosition } from "./types";
+import type { AstSource, AstLocation, AstPosition } from "./types";
 import type { SourceLocation, Source, SourceId } from "../../types";
 import type { SourceScope } from "./getScopes/visitor";
 import type { SymbolDeclarations } from "./getSymbols";
 
 const dispatcher = new WorkerDispatcher();
 export const start = (url: string, win: any = window) =>
   dispatcher.start(url, win);
 export const stop = () => dispatcher.stop();
@@ -41,18 +41,26 @@ export const clearScopes = async (): Pro
 
 export const clearSymbols = async (): Promise<void> =>
   dispatcher.invoke("clearSymbols");
 
 export const getSymbols = async (
   sourceId: string
 ): Promise<SymbolDeclarations> => dispatcher.invoke("getSymbols", sourceId);
 
-export const setSource = async (source: Source): Promise<void> =>
-  dispatcher.invoke("setSource", source);
+export const setSource = async (source: Source): Promise<void> => {
+  const astSource: AstSource = {
+    id: source.id,
+    text: source.isWasm ? "" : source.text || "",
+    contentType: source.contentType || null,
+    isWasm: source.isWasm
+  };
+
+  await dispatcher.invoke("setSource", astSource);
+};
 
 export const clearSources = async (): Promise<void> =>
   dispatcher.invoke("clearSources");
 
 export const hasSyntaxError = async (input: string): Promise<string | false> =>
   dispatcher.invoke("hasSyntaxError", input);
 
 export const mapExpression = async (
--- a/devtools/client/debugger/src/workers/parser/sources.js
+++ b/devtools/client/debugger/src/workers/parser/sources.js
@@ -1,25 +1,26 @@
 /* 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 type { Source, SourceId } from "../../types";
+import type { SourceId, AstSource } from "./types";
 
-let cachedSources = new Map();
+const cachedSources: Map<SourceId, AstSource> = new Map();
 
-export function setSource(source: Source) {
+export function setSource(source: AstSource) {
   cachedSources.set(source.id, source);
 }
 
-export function getSource(sourceId: SourceId): Source {
-  if (!cachedSources.has(sourceId)) {
+export function getSource(sourceId: SourceId): AstSource {
+  const source = cachedSources.get(sourceId);
+  if (!source) {
     throw new Error(`Parser: source ${sourceId} was not provided.`);
   }
 
-  return ((cachedSources.get(sourceId): any): Source);
+  return source;
 }
 
 export function clearSources() {
-  cachedSources = new Map();
+  cachedSources.clear();
 }
--- a/devtools/client/debugger/src/workers/parser/tests/findOutOfScopeLocations.spec.js
+++ b/devtools/client/debugger/src/workers/parser/tests/findOutOfScopeLocations.spec.js
@@ -2,77 +2,71 @@
 /* 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 findOutOfScopeLocations from "../findOutOfScopeLocations";
 
-import { getSource } from "./helpers";
-import { setSource } from "../sources";
+import { populateSource } from "./helpers";
 
 function formatLines(actual) {
   return actual
     .map(
       ({ start, end }) =>
         `(${start.line}, ${start.column}) -> (${end.line}, ${end.column})`
     )
     .join("\n");
 }
 
 describe("Parser.findOutOfScopeLocations", () => {
   it("should exclude non-enclosing function blocks", () => {
-    const source = getSource("outOfScope");
-    setSource(source);
-    const actual = findOutOfScopeLocations("outOfScope", {
+    const source = populateSource("outOfScope");
+    const actual = findOutOfScopeLocations(source.id, {
       line: 5,
       column: 5
     });
 
     expect(formatLines(actual)).toMatchSnapshot();
   });
 
   it("should roll up function blocks", () => {
-    const source = getSource("outOfScope");
-    setSource(source);
-    const actual = findOutOfScopeLocations("outOfScope", {
+    const source = populateSource("outOfScope");
+    const actual = findOutOfScopeLocations(source.id, {
       line: 24,
       column: 0
     });
 
     expect(formatLines(actual)).toMatchSnapshot();
   });
 
   it("should exclude function for locations on declaration", () => {
-    const source = getSource("outOfScope");
-    setSource(source);
-    const actual = findOutOfScopeLocations("outOfScope", {
+    const source = populateSource("outOfScope");
+    const actual = findOutOfScopeLocations(source.id, {
       line: 3,
       column: 12
     });
 
     expect(formatLines(actual)).toMatchSnapshot();
   });
 
   it("should treat comments as out of scope", () => {
-    const source = getSource("outOfScopeComment");
-    setSource(source);
-    const actual = findOutOfScopeLocations("outOfScopeComment", {
+    const source = populateSource("outOfScopeComment");
+    const actual = findOutOfScopeLocations(source.id, {
       line: 3,
       column: 2
     });
 
     expect(actual).toEqual([
       { end: { column: 15, line: 1 }, start: { column: 0, line: 1 } }
     ]);
   });
 
   it("should not exclude in-scope inner locations", () => {
-    const source = getSource("outOfScope");
-    setSource(source);
-    const actual = findOutOfScopeLocations("outOfScope", {
+    const source = populateSource("outOfScope");
+    const actual = findOutOfScopeLocations(source.id, {
       line: 61,
       column: 0
     });
     expect(formatLines(actual)).toMatchSnapshot();
   });
 });
--- a/devtools/client/debugger/src/workers/parser/tests/framework.spec.js
+++ b/devtools/client/debugger/src/workers/parser/tests/framework.spec.js
@@ -1,24 +1,22 @@
 /* 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 { getSymbols } from "../getSymbols";
-import { getOriginalSource } from "./helpers";
-import { setSource } from "../sources";
+import { populateOriginalSource } from "./helpers";
 import cases from "jest-in-case";
 
 cases(
   "Parser.getFramework",
   ({ name, file, value }) => {
-    const source = getOriginalSource("frameworks/plainJavascript");
-    setSource(source);
+    const source = populateOriginalSource("frameworks/plainJavascript");
     const symbols = getSymbols(source.id);
     expect(symbols.framework).toBeUndefined();
   },
   [
     {
       name: "is undefined when no framework",
       file: "frameworks/plainJavascript",
       value: undefined
--- a/devtools/client/debugger/src/workers/parser/tests/getScopes.spec.js
+++ b/devtools/client/debugger/src/workers/parser/tests/getScopes.spec.js
@@ -1,25 +1,23 @@
 /* eslint max-nested-callbacks: ["error", 4]*/
 /* 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 getScopes from "../getScopes";
-import { setSource } from "../sources";
-import { getOriginalSource } from "./helpers";
+import { populateOriginalSource } from "./helpers";
 import cases from "jest-in-case";
 
 cases(
   "Parser.getScopes",
   ({ name, file, type, locations }) => {
-    const source = getOriginalSource(file, type);
-    setSource(source);
+    const source = populateOriginalSource(file, type);
 
     locations.forEach(([line, column]) => {
       const scopes = getScopes({
         sourceId: source.id,
         line,
         column
       });
 
--- a/devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js
+++ b/devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js
@@ -1,27 +1,27 @@
 /* eslint max-nested-callbacks: ["error", 4]*/
 /* 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 { formatSymbols } from "../utils/formatSymbols";
-import { getSource, getOriginalSource } from "./helpers";
+import { populateSource, populateOriginalSource } from "./helpers";
 import cases from "jest-in-case";
 
 cases(
   "Parser.getSymbols",
   ({ name, file, original, type }) => {
     const source = original
-      ? getOriginalSource(file, type)
-      : getSource(file, type);
+      ? populateOriginalSource(file, type)
+      : populateSource(file, type);
 
-    expect(formatSymbols(source)).toMatchSnapshot();
+    expect(formatSymbols(source.id)).toMatchSnapshot();
   },
   [
     { name: "es6", file: "es6", original: true },
     { name: "func", file: "func", original: true },
     { name: "function names", file: "functionNames", original: true },
     { name: "math", file: "math" },
     { name: "proto", file: "proto" },
     { name: "class", file: "class", original: true },
--- a/devtools/client/debugger/src/workers/parser/tests/helpers/index.js
+++ b/devtools/client/debugger/src/workers/parser/tests/helpers/index.js
@@ -2,37 +2,61 @@
  * 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 fs from "fs";
 import path from "path";
 
+import type { Source } from "../../../../types";
 import { makeMockSource } from "../../../../utils/test-mockup";
+import { setSource } from "../../sources";
 
 export function getFixture(name: string, type: string = "js") {
   return fs.readFileSync(
     path.join(__dirname, `../fixtures/${name}.${type}`),
     "utf8"
   );
 }
 
-export function getSource(name: string, type: string = "js") {
+export function getSource(name: string, type: string = "js"): Source {
   const text = getFixture(name, type);
   let contentType = "text/javascript";
   if (type === "html") {
     contentType = "text/html";
   } else if (type === "vue") {
     contentType = "text/vue";
   } else if (type === "ts") {
     contentType = "text/typescript";
   } else if (type === "tsx") {
     contentType = "text/typescript-jsx";
   }
 
   return makeMockSource(undefined, name, contentType, text);
 }
 
-export function getOriginalSource(name: string, type: string = "js") {
+export function getOriginalSource(name: string, type: string = "js"): Source {
+  const source = getSource(name, type);
+  return ({ ...source, id: `${name}/originalSource-1` }: any);
+}
+
+export function populateSource(name: string, type?: string): Source {
   const source = getSource(name, type);
-  return { ...source, id: `${name}/originalSource-1` };
+  setSource({
+    id: source.id,
+    text: source.isWasm ? "" : source.text || "",
+    contentType: source.contentType,
+    isWasm: false
+  });
+  return source;
 }
+
+export function populateOriginalSource(name: string, type?: string): Source {
+  const source = getOriginalSource(name, type);
+  setSource({
+    id: source.id,
+    text: source.isWasm ? "" : source.text || "",
+    contentType: source.contentType,
+    isWasm: false
+  });
+  return source;
+}
--- a/devtools/client/debugger/src/workers/parser/tests/steps.spec.js
+++ b/devtools/client/debugger/src/workers/parser/tests/steps.spec.js
@@ -1,67 +1,60 @@
 /* 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 { getNextStep } from "../steps";
-import { getSource } from "./helpers";
-import { setSource } from "../sources";
+import { populateSource } from "./helpers";
 
 describe("getNextStep", () => {
   describe("await", () => {
     it("first await call", () => {
-      const source = getSource("async");
-      setSource(source);
-      const pausePosition = { line: 8, column: 2, sourceId: "async" };
-      expect(getNextStep("async", pausePosition)).toEqual({
+      const source = populateSource("async");
+      const pausePosition = { line: 8, column: 2, sourceId: source.id };
+      expect(getNextStep(source.id, pausePosition)).toEqual({
         ...pausePosition,
         line: 9
       });
     });
 
     it("first await call expression", () => {
-      const source = getSource("async");
-      setSource(source);
-      const pausePosition = { line: 8, column: 9, sourceId: "async" };
-      expect(getNextStep("async", pausePosition)).toEqual({
+      const source = populateSource("async");
+      const pausePosition = { line: 8, column: 9, sourceId: source.id };
+      expect(getNextStep(source.id, pausePosition)).toEqual({
         ...pausePosition,
         line: 9,
         column: 2
       });
     });
 
     it("second await call", () => {
-      const source = getSource("async");
-      setSource(source);
-      const pausePosition = { line: 9, column: 2, sourceId: "async" };
-      expect(getNextStep("async", pausePosition)).toEqual(null);
+      const source = populateSource("async");
+      const pausePosition = { line: 9, column: 2, sourceId: source.id };
+      expect(getNextStep(source.id, pausePosition)).toEqual(null);
     });
 
     it("second call expression", () => {
-      const source = getSource("async");
-      setSource(source);
-      const pausePosition = { line: 9, column: 9, sourceId: "async" };
-      expect(getNextStep("async", pausePosition)).toEqual(null);
+      const source = populateSource("async");
+      const pausePosition = { line: 9, column: 9, sourceId: source.id };
+      expect(getNextStep(source.id, pausePosition)).toEqual(null);
     });
   });
 
   describe("yield", () => {
     it("first yield call", () => {
-      const source = getSource("generators");
-      setSource(source);
-      const pausePosition = { line: 2, column: 2, sourceId: "generators" };
-      expect(getNextStep("generators", pausePosition)).toEqual({
+      const source = populateSource("generators");
+      const pausePosition = { line: 2, column: 2, sourceId: source.id };
+      expect(getNextStep(source.id, pausePosition)).toEqual({
         ...pausePosition,
         line: 3
       });
     });
 
     it("second yield call", () => {
-      const source = getSource("generators");
-      setSource(source);
-      const pausePosition = { line: 3, column: 2, sourceId: "generators" };
-      expect(getNextStep("generators", pausePosition)).toEqual(null);
+      const source = populateSource("generators");
+      const pausePosition = { line: 3, column: 2, sourceId: source.id };
+      expect(getNextStep(source.id, pausePosition)).toEqual(null);
     });
   });
 });
--- a/devtools/client/debugger/src/workers/parser/types.js
+++ b/devtools/client/debugger/src/workers/parser/types.js
@@ -1,8 +1,18 @@
 /* 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 type { SourceId } from "../../types";
+
+export type { SourceId };
+
+export type AstSource = {|
+  id: SourceId,
+  isWasm: boolean,
+  text: string,
+  contentType: ?string
+|};
 
 export type AstPosition = { +line: number, +column: number };
 export type AstLocation = { +end: AstPosition, +start: AstPosition };
--- a/devtools/client/debugger/src/workers/parser/utils/formatSymbols.js
+++ b/devtools/client/debugger/src/workers/parser/utils/formatSymbols.js
@@ -1,18 +1,17 @@
 /* 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 { getSymbols } from "../getSymbols";
-import { setSource } from "../sources";
 
-import type { Source } from "../../../types";
+import type { SourceId } from "../../../types";
 
 function formatLocation(loc) {
   if (!loc) {
     return "";
   }
 
   const { start, end } = loc;
   const startLoc = `(${start.line}, ${start.column})`;
@@ -56,17 +55,15 @@ function formatKey(name: string, symbols
 
   if (strings.includes(name)) {
     return formatString(name, symbols);
   }
 
   return `${name}:\n${symbols[name].map(summarize).join("\n")}`;
 }
 
-export function formatSymbols(source: Source) {
-  setSource(source);
-  const symbols = getSymbols(source.id);
+export function formatSymbols(sourceId: SourceId) {
+  const symbols = getSymbols(sourceId);
 
   return Object.keys(symbols)
-
     .map(name => formatKey(name, symbols))
     .join("\n\n");
 }
--- a/devtools/client/debugger/src/workers/parser/utils/tests/ast.spec.js
+++ b/devtools/client/debugger/src/workers/parser/utils/tests/ast.spec.js
@@ -23,17 +23,22 @@ const astKeys = [
   "comments",
   "tokens"
 ];
 
 cases(
   "ast.getAst",
   ({ name }) => {
     const source = createSource(name);
-    setSource(source);
+    setSource({
+      id: source.id,
+      text: source.text || "",
+      contentType: source.contentType,
+      isWasm: false
+    });
     const ast = getAst("foo");
     expect(ast && Object.keys(ast)).toEqual(astKeys);
   },
   [
     { name: "text/javascript" },
     { name: "application/javascript" },
     { name: "application/x-javascript" },
     { name: "text/jsx" }