summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/workers/parser
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/debugger/src/workers/parser
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/src/workers/parser')
-rw-r--r--devtools/client/debugger/src/workers/parser/findOutOfScopeLocations.js132
-rw-r--r--devtools/client/debugger/src/workers/parser/frameworks.js77
-rw-r--r--devtools/client/debugger/src/workers/parser/getScopes/index.js63
-rw-r--r--devtools/client/debugger/src/workers/parser/getScopes/visitor.js869
-rw-r--r--devtools/client/debugger/src/workers/parser/getSymbols.js473
-rw-r--r--devtools/client/debugger/src/workers/parser/index.js53
-rw-r--r--devtools/client/debugger/src/workers/parser/mapAwaitExpression.js199
-rw-r--r--devtools/client/debugger/src/workers/parser/mapBindings.js120
-rw-r--r--devtools/client/debugger/src/workers/parser/mapExpression.js50
-rw-r--r--devtools/client/debugger/src/workers/parser/mapOriginalExpression.js106
-rw-r--r--devtools/client/debugger/src/workers/parser/moz.build10
-rw-r--r--devtools/client/debugger/src/workers/parser/sources.js22
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/__snapshots__/findOutOfScopeLocations.spec.js.snap47
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/__snapshots__/getScopes.spec.js.snap18767
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap1522
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/__snapshots__/validate.spec.js.snap3
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/contains.spec.js250
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/findOutOfScopeLocations.spec.js75
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/allSymbols.js33
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/async.js10
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/call-sites.js4
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/callExpressions.js7
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/calls.js21
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/class.js28
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/component.js84
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/computed-props.js8
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/control-flow.js39
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/decorators.js2
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/destructuring.js16
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/es6.js1
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/expression.js25
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/flow.js5
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/angular1FalsePositive.js11
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/angular1Module.js4
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/plainJavascript.js8
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactComponent.js3
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactComponentEs5.js3
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactLibrary.js19
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reduxLibrary.js39
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/vueFileComponent.js3
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/vueFileDeclarative.js6
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/func.js50
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/functionNames.js50
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/generators.js4
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/jsx.js5
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/math.js15
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/modules.js10
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/object-expressions.js6
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/optional-chaining.js3
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/outOfScope.js62
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/outOfScopeComment.js4
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/parseScriptTags.html42
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/private-fields.js24
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/proto.js14
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/resolveToken.js40
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/arrow-function.js11
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/binding-types.js24
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/block-statement.js13
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-declaration.js14
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-expression.js11
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-property.js10
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/complex-nesting.js29
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/expressions.js6
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/flowtype-bindings.js11
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/fn-body-lex-and-nonlex.js23
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/for-loops.js13
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/function-declaration.js11
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/function-expression.js7
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/jsx-component.js6
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/out-of-order-declarations.js21
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/pattern-declarations.js2
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/simple-module.js11
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/switch-statement.js22
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/try-catch.js9
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/ts-sample.ts41
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/tsx-sample.tsx41
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/vue-sample.vue26
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/statements.js40
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/thisExpression.js11
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/fixtures/var.js21
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/framework.spec.js63
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/getScopes.spec.js227
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js49
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/helpers/index.js86
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/mapBindings.spec.js161
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/mapExpression.spec.js785
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/mapOriginalExpression.spec.js93
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/sources.spec.js14
-rw-r--r--devtools/client/debugger/src/workers/parser/tests/validate.spec.js15
-rw-r--r--devtools/client/debugger/src/workers/parser/utils/ast.js225
-rw-r--r--devtools/client/debugger/src/workers/parser/utils/contains.js29
-rw-r--r--devtools/client/debugger/src/workers/parser/utils/formatSymbols.js65
-rw-r--r--devtools/client/debugger/src/workers/parser/utils/getFunctionName.js96
-rw-r--r--devtools/client/debugger/src/workers/parser/utils/helpers.js230
-rw-r--r--devtools/client/debugger/src/workers/parser/utils/inferClassName.js93
-rw-r--r--devtools/client/debugger/src/workers/parser/utils/simple-path.js147
-rw-r--r--devtools/client/debugger/src/workers/parser/utils/tests/ast.spec.js41
-rw-r--r--devtools/client/debugger/src/workers/parser/validate.js14
-rw-r--r--devtools/client/debugger/src/workers/parser/worker.js30
99 files changed, 26443 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/workers/parser/findOutOfScopeLocations.js b/devtools/client/debugger/src/workers/parser/findOutOfScopeLocations.js
new file mode 100644
index 0000000000..642ec8b650
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/findOutOfScopeLocations.js
@@ -0,0 +1,132 @@
+/* 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 { containsLocation, containsPosition } from "./utils/contains";
+
+import { getSymbols } from "./getSymbols";
+
+function findSymbols(source) {
+ const { functions, comments } = getSymbols(source);
+ return { functions, comments };
+}
+
+/**
+ * Returns the location for a given function path. If the path represents a
+ * function declaration, the location will begin after the function identifier
+ * but before the function parameters.
+ */
+
+function getLocation(func) {
+ const location = { ...func.location };
+
+ // if the function has an identifier, start the block after it so the
+ // identifier is included in the "scope" of its parent
+ const identifierEnd = func?.identifier?.loc?.end;
+ if (identifierEnd) {
+ location.start = identifierEnd;
+ }
+
+ return location;
+}
+
+/**
+ * Find the nearest location containing the input position and
+ * return inner locations under that nearest location
+ *
+ * @param {Array<Object>} locations Notice! The locations MUST be sorted by `sortByStart`
+ * so that we can do linear time complexity operation.
+ * @returns {Array<Object>}
+ */
+function getInnerLocations(locations, position) {
+ // First, let's find the nearest position-enclosing function location,
+ // which is to find the last location enclosing the position.
+ let parentIndex;
+ for (let i = locations.length - 1; i >= 0; i--) {
+ const loc = locations[i];
+ if (containsPosition(loc, position)) {
+ parentIndex = i;
+ break;
+ }
+ }
+
+ if (parentIndex == undefined) {
+ return [];
+ }
+ const parentLoc = locations[parentIndex];
+
+ // Then, from the nearest location, loop locations again and put locations into
+ // the innerLocations array until we get to a location not enclosed by the nearest location.
+ const innerLocations = [];
+ for (let i = parentIndex + 1; i < locations.length; i++) {
+ const loc = locations[i];
+ if (!containsLocation(parentLoc, loc)) {
+ break;
+ }
+
+ innerLocations.push(loc);
+ }
+
+ return innerLocations;
+}
+
+/**
+ * Return an new locations array which excludes
+ * items that are completely enclosed by another location in the input locations
+ *
+ * @param locations Notice! The locations MUST be sorted by `sortByStart`
+ * so that we can do linear time complexity operation.
+ */
+function removeOverlaps(locations) {
+ if (!locations.length) {
+ return [];
+ }
+ const firstParent = locations[0];
+ return locations.reduce(deduplicateNode, [firstParent]);
+}
+
+function deduplicateNode(nodes, location) {
+ const parent = nodes[nodes.length - 1];
+ if (!containsLocation(parent, location)) {
+ nodes.push(location);
+ }
+ return nodes;
+}
+
+/**
+ * Sorts an array of locations by start position
+ */
+function sortByStart(a, b) {
+ if (a.start.line < b.start.line) {
+ return -1;
+ } else if (a.start.line === b.start.line) {
+ return a.start.column - b.start.column;
+ }
+
+ return 1;
+}
+
+/**
+ * Returns an array of locations that are considered out of scope for the given
+ * location.
+ */
+function findOutOfScopeLocations(location) {
+ const { functions, comments } = findSymbols(location.source.id);
+ const commentLocations = comments.map(c => c.location);
+ const locations = functions
+ .map(getLocation)
+ .concat(commentLocations)
+ .sort(sortByStart);
+
+ const innerLocations = getInnerLocations(locations, location);
+ const outerLocations = locations.filter(loc => {
+ if (innerLocations.includes(loc)) {
+ return false;
+ }
+
+ return !containsPosition(loc, location);
+ });
+ return removeOverlaps(outerLocations);
+}
+
+export default findOutOfScopeLocations;
diff --git a/devtools/client/debugger/src/workers/parser/frameworks.js b/devtools/client/debugger/src/workers/parser/frameworks.js
new file mode 100644
index 0000000000..85011c0780
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/frameworks.js
@@ -0,0 +1,77 @@
+/* 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 * as t from "@babel/types";
+
+export function getFramework(symbols) {
+ if (isReactComponent(symbols)) {
+ return "React";
+ }
+ if (isAngularComponent(symbols)) {
+ return "Angular";
+ }
+ if (isVueComponent(symbols)) {
+ return "Vue";
+ }
+
+ return null;
+}
+
+function isReactComponent({ imports, classes, callExpressions, identifiers }) {
+ return (
+ importsReact(imports) ||
+ requiresReact(callExpressions) ||
+ extendsReactComponent(classes) ||
+ isReact(identifiers) ||
+ isRedux(identifiers)
+ );
+}
+
+function importsReact(imports) {
+ return imports.some(
+ importObj =>
+ importObj.source === "react" &&
+ importObj.specifiers.some(specifier => specifier === "React")
+ );
+}
+
+function requiresReact(callExpressions) {
+ return callExpressions.some(
+ callExpression =>
+ callExpression.name === "require" &&
+ callExpression.values.some(value => value === "react")
+ );
+}
+
+function extendsReactComponent(classes) {
+ return classes.some(
+ classObj =>
+ t.isIdentifier(classObj.parent, { name: "Component" }) ||
+ t.isIdentifier(classObj.parent, { name: "PureComponent" }) ||
+ (t.isMemberExpression(classObj.parent, { computed: false }) &&
+ t.isIdentifier(classObj.parent, { name: "Component" }))
+ );
+}
+
+function isAngularComponent({ memberExpressions }) {
+ return memberExpressions.some(
+ item =>
+ item.expression == "angular.controller" ||
+ item.expression == "angular.module"
+ );
+}
+
+function isVueComponent({ identifiers }) {
+ return identifiers.some(identifier => identifier.name == "Vue");
+}
+
+/* This identifies the react lib file */
+function isReact(identifiers) {
+ return identifiers.some(identifier => identifier.name == "isReactComponent");
+}
+
+/* This identifies the redux lib file */
+function isRedux(identifiers) {
+ return identifiers.some(identifier => identifier.name == "Redux");
+}
diff --git a/devtools/client/debugger/src/workers/parser/getScopes/index.js b/devtools/client/debugger/src/workers/parser/getScopes/index.js
new file mode 100644
index 0000000000..cd2503791c
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/getScopes/index.js
@@ -0,0 +1,63 @@
+/* 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 { buildScopeList, parseSourceScopes } from "./visitor";
+
+let parsedScopesCache = new Map();
+
+export default function getScopes(location) {
+ const { sourceId } = location;
+ let parsedScopes = parsedScopesCache.get(sourceId);
+ if (!parsedScopes) {
+ parsedScopes = parseSourceScopes(sourceId);
+ parsedScopesCache.set(sourceId, parsedScopes);
+ }
+ return parsedScopes ? findScopes(parsedScopes, location) : [];
+}
+
+export function clearScopes() {
+ parsedScopesCache = new Map();
+}
+
+export { buildScopeList };
+
+/**
+ * Searches all scopes and their bindings at the specific location.
+ */
+function findScopes(scopes, location) {
+ // Find inner most in the tree structure.
+ let searchInScopes = scopes;
+ const found = [];
+ while (searchInScopes) {
+ const foundOne = searchInScopes.some(s => {
+ if (
+ compareLocations(s.start, location) <= 0 &&
+ compareLocations(location, s.end) < 0
+ ) {
+ // Found the next scope, trying to search recusevly in its children.
+ found.unshift(s);
+ searchInScopes = s.children;
+ return true;
+ }
+ return false;
+ });
+ if (!foundOne) {
+ break;
+ }
+ }
+ return found.map(i => ({
+ type: i.type,
+ scopeKind: i.scopeKind,
+ displayName: i.displayName,
+ start: i.start,
+ end: i.end,
+ bindings: i.bindings,
+ }));
+}
+
+function compareLocations(a, b) {
+ // According to type of Location.column can be undefined, if will not be the
+ // case here, ignoring flow error.
+ return a.line == b.line ? a.column - b.column : a.line - b.line;
+}
diff --git a/devtools/client/debugger/src/workers/parser/getScopes/visitor.js b/devtools/client/debugger/src/workers/parser/getScopes/visitor.js
new file mode 100644
index 0000000000..13c7f0bcfc
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/getScopes/visitor.js
@@ -0,0 +1,869 @@
+/* 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 * as t from "@babel/types";
+
+import getFunctionName from "../utils/getFunctionName";
+import { getAst } from "../utils/ast";
+
+/**
+ * "implicit"
+ * Variables added automaticly like "this" and "arguments"
+ *
+ * "var"
+ * Variables declared with "var" or non-block function declarations
+ *
+ * "let"
+ * Variables declared with "let".
+ *
+ * "const"
+ * Variables declared with "const", or added as const
+ * bindings like inner function expressions and inner class names.
+ *
+ * "import"
+ * Imported binding names exposed from other modules.
+ *
+ * "global"
+ * Variables that reference undeclared global values.
+ */
+
+// Location information about the expression immediartely surrounding a
+// given binding reference.
+
+function isGeneratedId(id) {
+ return !/\/originalSource/.test(id);
+}
+
+export function parseSourceScopes(sourceId) {
+ const ast = getAst(sourceId);
+ if (!ast || !Object.keys(ast).length) {
+ return null;
+ }
+
+ return buildScopeList(ast, sourceId);
+}
+
+export function buildScopeList(ast, sourceId) {
+ const { global, lexical } = createGlobalScope(ast, sourceId);
+
+ const state = {
+ sourceId,
+ freeVariables: new Map(),
+ freeVariableStack: [],
+ inType: null,
+ scope: lexical,
+ scopeStack: [],
+ declarationBindingIds: new Set(),
+ };
+ t.traverse(ast, scopeCollectionVisitor, state);
+
+ for (const [key, freeVariables] of state.freeVariables) {
+ let binding = global.bindings[key];
+ if (!binding) {
+ binding = {
+ type: "global",
+ refs: [],
+ };
+ global.bindings[key] = binding;
+ }
+
+ binding.refs = freeVariables.concat(binding.refs);
+ }
+
+ // TODO: This should probably check for ".mjs" extension on the
+ // original file, and should also be skipped if the the generated
+ // code is an ES6 module rather than a script.
+ if (
+ isGeneratedId(sourceId) ||
+ (ast.program.sourceType === "script" && !looksLikeCommonJS(global))
+ ) {
+ stripModuleScope(global);
+ }
+
+ return toParsedScopes([global], sourceId) || [];
+}
+
+function toParsedScopes(children, sourceId) {
+ if (!children || children.length === 0) {
+ return undefined;
+ }
+ return children.map(scope => ({
+ // Removing unneed information from TempScope such as parent reference.
+ // We also need to convert BabelLocation to the Location type.
+ start: scope.loc.start,
+ end: scope.loc.end,
+ type:
+ scope.type === "module" || scope.type === "function-body"
+ ? "block"
+ : scope.type,
+ scopeKind: "",
+ displayName: scope.displayName,
+ bindings: scope.bindings,
+ children: toParsedScopes(scope.children, sourceId),
+ }));
+}
+
+function createTempScope(type, displayName, parent, loc) {
+ const result = {
+ type,
+ displayName,
+ parent,
+ children: [],
+ loc,
+ bindings: Object.create(null),
+ };
+ if (parent) {
+ parent.children.push(result);
+ }
+ return result;
+}
+function pushTempScope(state, type, displayName, loc) {
+ const scope = createTempScope(type, displayName, state.scope, loc);
+
+ state.scope = scope;
+
+ state.freeVariableStack.push(state.freeVariables);
+ state.freeVariables = new Map();
+ return scope;
+}
+
+function isNode(node, type) {
+ return node ? node.type === type : false;
+}
+
+function getVarScope(scope) {
+ let s = scope;
+ while (s.type !== "function" && s.type !== "module") {
+ if (!s.parent) {
+ return s;
+ }
+ s = s.parent;
+ }
+ return s;
+}
+
+function fromBabelLocation(location, sourceId) {
+ return {
+ sourceId,
+ line: location.line,
+ column: location.column,
+ };
+}
+
+function parseDeclarator(
+ declaratorId,
+ targetScope,
+ type,
+ locationType,
+ declaration,
+ state
+) {
+ if (isNode(declaratorId, "Identifier")) {
+ let existing = targetScope.bindings[declaratorId.name];
+ if (!existing) {
+ existing = {
+ type,
+ refs: [],
+ };
+ targetScope.bindings[declaratorId.name] = existing;
+ }
+ state.declarationBindingIds.add(declaratorId);
+ existing.refs.push({
+ type: locationType,
+ start: fromBabelLocation(declaratorId.loc.start, state.sourceId),
+ end: fromBabelLocation(declaratorId.loc.end, state.sourceId),
+ declaration: {
+ start: fromBabelLocation(declaration.loc.start, state.sourceId),
+ end: fromBabelLocation(declaration.loc.end, state.sourceId),
+ },
+ });
+ } else if (isNode(declaratorId, "ObjectPattern")) {
+ declaratorId.properties.forEach(prop => {
+ parseDeclarator(
+ prop.value,
+ targetScope,
+ type,
+ locationType,
+ declaration,
+ state
+ );
+ });
+ } else if (isNode(declaratorId, "ArrayPattern")) {
+ declaratorId.elements.forEach(item => {
+ parseDeclarator(
+ item,
+ targetScope,
+ type,
+ locationType,
+ declaration,
+ state
+ );
+ });
+ } else if (isNode(declaratorId, "AssignmentPattern")) {
+ parseDeclarator(
+ declaratorId.left,
+ targetScope,
+ type,
+ locationType,
+ declaration,
+ state
+ );
+ } else if (isNode(declaratorId, "RestElement")) {
+ parseDeclarator(
+ declaratorId.argument,
+ targetScope,
+ type,
+ locationType,
+ declaration,
+ state
+ );
+ } else if (t.isTSParameterProperty(declaratorId)) {
+ parseDeclarator(
+ declaratorId.parameter,
+ targetScope,
+ type,
+ locationType,
+ declaration,
+ state
+ );
+ }
+}
+
+function isLetOrConst(node) {
+ return node.kind === "let" || node.kind === "const";
+}
+
+function hasLexicalDeclaration(node, parent) {
+ const nodes = [];
+ if (t.isSwitchStatement(node)) {
+ for (const caseNode of node.cases) {
+ nodes.push(...caseNode.consequent);
+ }
+ } else {
+ nodes.push(...node.body);
+ }
+
+ const isFunctionBody = t.isFunction(parent, { body: node });
+
+ return nodes.some(
+ child =>
+ isLexicalVariable(child) ||
+ t.isClassDeclaration(child) ||
+ (!isFunctionBody && t.isFunctionDeclaration(child))
+ );
+}
+function isLexicalVariable(node) {
+ return isNode(node, "VariableDeclaration") && isLetOrConst(node);
+}
+
+function createGlobalScope(ast, sourceId) {
+ const global = createTempScope("object", "Global", null, {
+ start: fromBabelLocation(ast.loc.start, sourceId),
+ end: fromBabelLocation(ast.loc.end, sourceId),
+ });
+
+ const lexical = createTempScope("block", "Lexical Global", global, {
+ start: fromBabelLocation(ast.loc.start, sourceId),
+ end: fromBabelLocation(ast.loc.end, sourceId),
+ });
+
+ return { global, lexical };
+}
+
+const scopeCollectionVisitor = {
+ // eslint-disable-next-line complexity
+ enter(node, ancestors, state) {
+ state.scopeStack.push(state.scope);
+
+ const parentNode =
+ ancestors.length === 0 ? null : ancestors[ancestors.length - 1].node;
+
+ if (state.inType) {
+ return;
+ }
+
+ if (t.isProgram(node)) {
+ const scope = pushTempScope(state, "module", "Module", {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+ scope.bindings.this = {
+ type: "implicit",
+ refs: [],
+ };
+ } else if (t.isFunction(node)) {
+ let { scope } = state;
+ if (t.isFunctionExpression(node) && isNode(node.id, "Identifier")) {
+ scope = pushTempScope(state, "block", "Function Expression", {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+ state.declarationBindingIds.add(node.id);
+ scope.bindings[node.id.name] = {
+ type: "const",
+ refs: [
+ {
+ type: "fn-expr",
+ start: fromBabelLocation(node.id.loc.start, state.sourceId),
+ end: fromBabelLocation(node.id.loc.end, state.sourceId),
+ declaration: {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ },
+ },
+ ],
+ };
+ }
+
+ if (t.isFunctionDeclaration(node) && isNode(node.id, "Identifier")) {
+ // This ignores Annex B function declaration hoisting, which
+ // is probably a fine assumption.
+ state.declarationBindingIds.add(node.id);
+ const refs = [
+ {
+ type: "fn-decl",
+ start: fromBabelLocation(node.id.loc.start, state.sourceId),
+ end: fromBabelLocation(node.id.loc.end, state.sourceId),
+ declaration: {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ },
+ },
+ ];
+
+ if (scope.type === "block") {
+ scope.bindings[node.id.name] = {
+ type: "let",
+ refs,
+ };
+ } else {
+ getVarScope(scope).bindings[node.id.name] = {
+ type: "var",
+ refs,
+ };
+ }
+ }
+
+ scope = pushTempScope(
+ state,
+ "function",
+ getFunctionName(node, parentNode),
+ {
+ // Being at the start of a function doesn't count as
+ // being inside of it.
+ start: fromBabelLocation(
+ node.params[0] ? node.params[0].loc.start : node.loc.start,
+ state.sourceId
+ ),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ }
+ );
+
+ node.params.forEach(param =>
+ parseDeclarator(param, scope, "var", "fn-param", node, state)
+ );
+
+ if (!t.isArrowFunctionExpression(node)) {
+ scope.bindings.this = {
+ type: "implicit",
+ refs: [],
+ };
+ scope.bindings.arguments = {
+ type: "implicit",
+ refs: [],
+ };
+ }
+
+ if (
+ t.isBlockStatement(node.body) &&
+ hasLexicalDeclaration(node.body, node)
+ ) {
+ scope = pushTempScope(state, "function-body", "Function Body", {
+ start: fromBabelLocation(node.body.loc.start, state.sourceId),
+ end: fromBabelLocation(node.body.loc.end, state.sourceId),
+ });
+ }
+ } else if (t.isClass(node)) {
+ if (t.isIdentifier(node.id)) {
+ // For decorated classes, the AST considers the first the decorator
+ // to be the start of the class. For the purposes of mapping class
+ // declarations however, we really want to look for the "class Foo"
+ // piece. To achieve that, we estimate the location of the declaration
+ // instead.
+ let declStart = node.loc.start;
+ if (node.decorators && node.decorators.length) {
+ // Estimate the location of the "class" keyword since it
+ // is unlikely to be a different line than the class name.
+ declStart = {
+ line: node.id.loc.start.line,
+ column: node.id.loc.start.column - "class ".length,
+ };
+ }
+
+ const declaration = {
+ start: fromBabelLocation(declStart, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ };
+
+ if (t.isClassDeclaration(node)) {
+ state.declarationBindingIds.add(node.id);
+ state.scope.bindings[node.id.name] = {
+ type: "let",
+ refs: [
+ {
+ type: "class-decl",
+ start: fromBabelLocation(node.id.loc.start, state.sourceId),
+ end: fromBabelLocation(node.id.loc.end, state.sourceId),
+ declaration,
+ },
+ ],
+ };
+ }
+
+ const scope = pushTempScope(state, "block", "Class", {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+
+ state.declarationBindingIds.add(node.id);
+ scope.bindings[node.id.name] = {
+ type: "const",
+ refs: [
+ {
+ type: "class-inner",
+ start: fromBabelLocation(node.id.loc.start, state.sourceId),
+ end: fromBabelLocation(node.id.loc.end, state.sourceId),
+ declaration,
+ },
+ ],
+ };
+ }
+ } else if (t.isForXStatement(node) || t.isForStatement(node)) {
+ const init = node.init || node.left;
+ if (isNode(init, "VariableDeclaration") && isLetOrConst(init)) {
+ // Debugger will create new lexical environment for the for.
+ pushTempScope(state, "block", "For", {
+ // Being at the start of a for loop doesn't count as
+ // being inside it.
+ start: fromBabelLocation(init.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+ }
+ } else if (t.isCatchClause(node)) {
+ const scope = pushTempScope(state, "block", "Catch", {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+ parseDeclarator(node.param, scope, "var", "catch", node, state);
+ } else if (
+ t.isBlockStatement(node) &&
+ // Function body's are handled in the function logic above.
+ !t.isFunction(parentNode) &&
+ hasLexicalDeclaration(node, parentNode)
+ ) {
+ // Debugger will create new lexical environment for the block.
+ pushTempScope(state, "block", "Block", {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+ } else if (
+ t.isVariableDeclaration(node) &&
+ (node.kind === "var" ||
+ // Lexical declarations in for statements are handled above.
+ !t.isForStatement(parentNode, { init: node }) ||
+ !t.isForXStatement(parentNode, { left: node }))
+ ) {
+ // Finds right lexical environment
+ const hoistAt = !isLetOrConst(node)
+ ? getVarScope(state.scope)
+ : state.scope;
+ node.declarations.forEach(declarator => {
+ parseDeclarator(
+ declarator.id,
+ hoistAt,
+ node.kind,
+ node.kind,
+ node,
+ state
+ );
+ });
+ } else if (
+ t.isImportDeclaration(node) &&
+ (!node.importKind || node.importKind === "value")
+ ) {
+ node.specifiers.forEach(spec => {
+ if (spec.importKind && spec.importKind !== "value") {
+ return;
+ }
+
+ if (t.isImportNamespaceSpecifier(spec)) {
+ state.declarationBindingIds.add(spec.local);
+
+ state.scope.bindings[spec.local.name] = {
+ // Imported namespaces aren't live import bindings, they are
+ // just normal const bindings.
+ type: "const",
+ refs: [
+ {
+ type: "import-ns-decl",
+ start: fromBabelLocation(spec.local.loc.start, state.sourceId),
+ end: fromBabelLocation(spec.local.loc.end, state.sourceId),
+ declaration: {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ },
+ },
+ ],
+ };
+ } else {
+ state.declarationBindingIds.add(spec.local);
+
+ state.scope.bindings[spec.local.name] = {
+ type: "import",
+ refs: [
+ {
+ type: "import-decl",
+ start: fromBabelLocation(spec.local.loc.start, state.sourceId),
+ end: fromBabelLocation(spec.local.loc.end, state.sourceId),
+ importName: t.isImportDefaultSpecifier(spec)
+ ? "default"
+ : spec.imported.name,
+ declaration: {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ },
+ },
+ ],
+ };
+ }
+ });
+ } else if (t.isTSEnumDeclaration(node)) {
+ state.declarationBindingIds.add(node.id);
+ state.scope.bindings[node.id.name] = {
+ type: "const",
+ refs: [
+ {
+ type: "ts-enum-decl",
+ start: fromBabelLocation(node.id.loc.start, state.sourceId),
+ end: fromBabelLocation(node.id.loc.end, state.sourceId),
+ declaration: {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ },
+ },
+ ],
+ };
+ } else if (t.isTSModuleDeclaration(node)) {
+ state.declarationBindingIds.add(node.id);
+ state.scope.bindings[node.id.name] = {
+ type: "const",
+ refs: [
+ {
+ type: "ts-namespace-decl",
+ start: fromBabelLocation(node.id.loc.start, state.sourceId),
+ end: fromBabelLocation(node.id.loc.end, state.sourceId),
+ declaration: {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ },
+ },
+ ],
+ };
+ } else if (t.isTSModuleBlock(node)) {
+ pushTempScope(state, "block", "TypeScript Namespace", {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+ } else if (
+ t.isIdentifier(node) &&
+ t.isReferenced(node, parentNode) &&
+ // Babel doesn't cover this in 'isReferenced' yet, but it should
+ // eventually.
+ !t.isTSEnumMember(parentNode, { id: node }) &&
+ !t.isTSModuleDeclaration(parentNode, { id: node }) &&
+ // isReferenced above fails to see `var { foo } = ...` as a non-reference
+ // because the direct parent is not enough to know that the pattern is
+ // used within a variable declaration.
+ !state.declarationBindingIds.has(node)
+ ) {
+ let freeVariables = state.freeVariables.get(node.name);
+ if (!freeVariables) {
+ freeVariables = [];
+ state.freeVariables.set(node.name, freeVariables);
+ }
+
+ freeVariables.push({
+ type: "ref",
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ meta: buildMetaBindings(state.sourceId, node, ancestors),
+ });
+ } else if (isOpeningJSXIdentifier(node, ancestors)) {
+ let freeVariables = state.freeVariables.get(node.name);
+ if (!freeVariables) {
+ freeVariables = [];
+ state.freeVariables.set(node.name, freeVariables);
+ }
+
+ freeVariables.push({
+ type: "ref",
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ meta: buildMetaBindings(state.sourceId, node, ancestors),
+ });
+ } else if (t.isThisExpression(node)) {
+ let freeVariables = state.freeVariables.get("this");
+ if (!freeVariables) {
+ freeVariables = [];
+ state.freeVariables.set("this", freeVariables);
+ }
+
+ freeVariables.push({
+ type: "ref",
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ meta: buildMetaBindings(state.sourceId, node, ancestors),
+ });
+ } else if (t.isClassProperty(parentNode, { value: node })) {
+ const scope = pushTempScope(state, "function", "Class Field", {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+ scope.bindings.this = {
+ type: "implicit",
+ refs: [],
+ };
+ scope.bindings.arguments = {
+ type: "implicit",
+ refs: [],
+ };
+ } else if (
+ t.isSwitchStatement(node) &&
+ hasLexicalDeclaration(node, parentNode)
+ ) {
+ pushTempScope(state, "block", "Switch", {
+ start: fromBabelLocation(node.loc.start, state.sourceId),
+ end: fromBabelLocation(node.loc.end, state.sourceId),
+ });
+ }
+
+ if (
+ // In general Flow expressions are deleted, so they can't contain
+ // runtime bindings, but typecasts are the one exception there.
+ (t.isFlow(node) && !t.isTypeCastExpression(node)) ||
+ // In general TS items are deleted, but TS has a few wrapper node
+ // types that can contain general JS expressions.
+ (node.type.startsWith("TS") &&
+ !t.isTSTypeAssertion(node) &&
+ !t.isTSAsExpression(node) &&
+ !t.isTSNonNullExpression(node) &&
+ !t.isTSModuleDeclaration(node) &&
+ !t.isTSModuleBlock(node) &&
+ !t.isTSParameterProperty(node) &&
+ !t.isTSExportAssignment(node))
+ ) {
+ // Flag this node as a root "type" node. All items inside of this
+ // will be skipped entirely.
+ state.inType = node;
+ }
+ },
+ exit(node, ancestors, state) {
+ const currentScope = state.scope;
+ const parentScope = state.scopeStack.pop();
+ if (!parentScope) {
+ throw new Error("Assertion failure - unsynchronized pop");
+ }
+ state.scope = parentScope;
+
+ // It is possible, as in the case of function expressions, that a single
+ // node has added multiple scopes, so we need to traverse upward here
+ // rather than jumping stright to 'parentScope'.
+ for (
+ let scope = currentScope;
+ scope && scope !== parentScope;
+ scope = scope.parent
+ ) {
+ const { freeVariables } = state;
+ state.freeVariables = state.freeVariableStack.pop();
+ const parentFreeVariables = state.freeVariables;
+
+ // Match up any free variables that match this scope's bindings and
+ // merge then into the refs.
+ for (const key of Object.keys(scope.bindings)) {
+ const binding = scope.bindings[key];
+
+ const freeVars = freeVariables.get(key);
+ if (freeVars) {
+ binding.refs.push(...freeVars);
+ freeVariables.delete(key);
+ }
+ }
+
+ // Move any undeclared references in this scope into the parent for
+ // processing in higher scopes.
+ for (const [key, value] of freeVariables) {
+ let refs = parentFreeVariables.get(key);
+ if (!refs) {
+ refs = [];
+ parentFreeVariables.set(key, refs);
+ }
+
+ refs.push(...value);
+ }
+ }
+
+ if (state.inType === node) {
+ state.inType = null;
+ }
+ },
+};
+
+function isOpeningJSXIdentifier(node, ancestors) {
+ if (!t.isJSXIdentifier(node)) {
+ return false;
+ }
+
+ for (let i = ancestors.length - 1; i >= 0; i--) {
+ const { node: parent, key } = ancestors[i];
+
+ if (t.isJSXOpeningElement(parent) && key === "name") {
+ return true;
+ } else if (!t.isJSXMemberExpression(parent) || key !== "object") {
+ break;
+ }
+ }
+
+ return false;
+}
+
+function buildMetaBindings(
+ sourceId,
+ node,
+ ancestors,
+ parentIndex = ancestors.length - 1
+) {
+ if (parentIndex <= 1) {
+ return null;
+ }
+ const parent = ancestors[parentIndex].node;
+ const grandparent = ancestors[parentIndex - 1].node;
+
+ // Consider "0, foo" to be equivalent to "foo".
+ if (
+ t.isSequenceExpression(parent) &&
+ parent.expressions.length === 2 &&
+ t.isNumericLiteral(parent.expressions[0]) &&
+ parent.expressions[1] === node
+ ) {
+ let { start, end } = parent.loc;
+
+ if (t.isCallExpression(grandparent, { callee: parent })) {
+ // Attempt to expand the range around parentheses, e.g.
+ // (0, foo.bar)()
+ start = grandparent.loc.start;
+ end = Object.assign({}, end);
+ end.column += 1;
+ }
+
+ return {
+ type: "inherit",
+ start: fromBabelLocation(start, sourceId),
+ end: fromBabelLocation(end, sourceId),
+ parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1),
+ };
+ }
+
+ // Consider "Object(foo)", and "__webpack_require__.i(foo)" to be
+ // equivalent to "foo" since they are essentially identity functions.
+ if (
+ t.isCallExpression(parent) &&
+ (t.isIdentifier(parent.callee, { name: "Object" }) ||
+ (t.isMemberExpression(parent.callee, { computed: false }) &&
+ t.isIdentifier(parent.callee.object, { name: "__webpack_require__" }) &&
+ t.isIdentifier(parent.callee.property, { name: "i" }))) &&
+ parent.arguments.length === 1 &&
+ parent.arguments[0] === node
+ ) {
+ return {
+ type: "inherit",
+ start: fromBabelLocation(parent.loc.start, sourceId),
+ end: fromBabelLocation(parent.loc.end, sourceId),
+ parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1),
+ };
+ }
+
+ if (t.isMemberExpression(parent, { object: node })) {
+ if (parent.computed) {
+ if (t.isStringLiteral(parent.property)) {
+ return {
+ type: "member",
+ start: fromBabelLocation(parent.loc.start, sourceId),
+ end: fromBabelLocation(parent.loc.end, sourceId),
+ property: parent.property.value,
+ parent: buildMetaBindings(
+ sourceId,
+ parent,
+ ancestors,
+ parentIndex - 1
+ ),
+ };
+ }
+ } else {
+ return {
+ type: "member",
+ start: fromBabelLocation(parent.loc.start, sourceId),
+ end: fromBabelLocation(parent.loc.end, sourceId),
+ property: parent.property.name,
+ parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1),
+ };
+ }
+ }
+ if (
+ t.isCallExpression(parent, { callee: node }) &&
+ !parent.arguments.length
+ ) {
+ return {
+ type: "call",
+ start: fromBabelLocation(parent.loc.start, sourceId),
+ end: fromBabelLocation(parent.loc.end, sourceId),
+ parent: buildMetaBindings(sourceId, parent, ancestors, parentIndex - 1),
+ };
+ }
+
+ return null;
+}
+
+function looksLikeCommonJS(rootScope) {
+ const hasRefs = name =>
+ rootScope.bindings[name] && !!rootScope.bindings[name].refs.length;
+
+ return (
+ hasRefs("__dirname") ||
+ hasRefs("__filename") ||
+ hasRefs("require") ||
+ hasRefs("exports") ||
+ hasRefs("module")
+ );
+}
+
+function stripModuleScope(rootScope) {
+ const rootLexicalScope = rootScope.children[0];
+ const moduleScope = rootLexicalScope.children[0];
+ if (moduleScope.type !== "module") {
+ throw new Error("Assertion failure - should be module");
+ }
+
+ Object.keys(moduleScope.bindings).forEach(name => {
+ const binding = moduleScope.bindings[name];
+ if (binding.type === "let" || binding.type === "const") {
+ rootLexicalScope.bindings[name] = binding;
+ } else {
+ rootScope.bindings[name] = binding;
+ }
+ });
+ rootLexicalScope.children = moduleScope.children;
+ rootLexicalScope.children.forEach(child => {
+ child.parent = rootLexicalScope;
+ });
+}
diff --git a/devtools/client/debugger/src/workers/parser/getSymbols.js b/devtools/client/debugger/src/workers/parser/getSymbols.js
new file mode 100644
index 0000000000..f9ba3be73a
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/getSymbols.js
@@ -0,0 +1,473 @@
+/* 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 * as t from "@babel/types";
+
+import createSimplePath from "./utils/simple-path";
+import { traverseAst } from "./utils/ast";
+import {
+ isFunction,
+ isObjectShorthand,
+ isComputedExpression,
+ getObjectExpressionValue,
+ getPatternIdentifiers,
+ getComments,
+ getSpecifiers,
+ getCode,
+ nodeLocationKey,
+ getFunctionParameterNames,
+} from "./utils/helpers";
+
+import { inferClassName } from "./utils/inferClassName";
+import getFunctionName from "./utils/getFunctionName";
+import { getFramework } from "./frameworks";
+
+let symbolDeclarations = new Map();
+
+function extractFunctionSymbol(path, state, symbols) {
+ const name = getFunctionName(path.node, path.parent);
+
+ if (!state.fnCounts[name]) {
+ state.fnCounts[name] = 0;
+ }
+ const index = state.fnCounts[name]++;
+ symbols.functions.push({
+ name,
+ klass: inferClassName(path),
+ location: path.node.loc,
+ parameterNames: getFunctionParameterNames(path),
+ identifier: path.node.id,
+ // indicates the occurence of the function in a file
+ // e.g { name: foo, ... index: 4 } is the 4th foo function
+ // in the file
+ index,
+ });
+}
+
+function extractSymbol(path, symbols, state) {
+ if (isFunction(path)) {
+ extractFunctionSymbol(path, state, symbols);
+ }
+
+ if (t.isJSXElement(path)) {
+ symbols.hasJsx = true;
+ }
+
+ if (t.isGenericTypeAnnotation(path)) {
+ symbols.hasTypes = true;
+ }
+
+ if (t.isClassDeclaration(path)) {
+ symbols.classes.push(getClassDeclarationSymbol(path.node));
+ }
+
+ if (t.isImportDeclaration(path)) {
+ symbols.imports.push(getImportDeclarationSymbol(path.node));
+ }
+
+ if (t.isObjectProperty(path)) {
+ symbols.objectProperties.push(getObjectPropertySymbol(path));
+ }
+
+ if (t.isMemberExpression(path) || t.isOptionalMemberExpression(path)) {
+ symbols.memberExpressions.push(getMemberExpressionSymbol(path));
+ }
+
+ if (
+ (t.isStringLiteral(path) || t.isNumericLiteral(path)) &&
+ t.isMemberExpression(path.parentPath)
+ ) {
+ // We only need literals that are part of computed memeber expressions
+ const { start, end } = path.node.loc;
+ symbols.literals.push({
+ name: path.node.value,
+ location: { start, end },
+ expression: getSnippet(path.parentPath),
+ });
+ }
+
+ if (t.isCallExpression(path)) {
+ symbols.callExpressions.push(getCallExpressionSymbol(path.node));
+ }
+
+ symbols.identifiers.push(...getIdentifierSymbols(path));
+}
+
+function extractSymbols(sourceId) {
+ const symbols = {
+ functions: [],
+ callExpressions: [],
+ memberExpressions: [],
+ objectProperties: [],
+ comments: [],
+ identifiers: [],
+ classes: [],
+ imports: [],
+ literals: [],
+ hasJsx: false,
+ hasTypes: false,
+ framework: undefined,
+ };
+
+ const state = {
+ fnCounts: Object.create(null),
+ };
+
+ const ast = traverseAst(sourceId, {
+ enter(node, ancestors) {
+ try {
+ const path = createSimplePath(ancestors);
+ if (path) {
+ extractSymbol(path, symbols, state);
+ }
+ } catch (e) {
+ console.error(e);
+ }
+ },
+ });
+
+ // comments are extracted separately from the AST
+ symbols.comments = getComments(ast);
+ symbols.identifiers = getUniqueIdentifiers(symbols.identifiers);
+ symbols.framework = getFramework(symbols);
+
+ return symbols;
+}
+
+function extendSnippet(name, expression, path, prevPath) {
+ const computed = path?.node.computed;
+ const optional = path?.node.optional;
+ const prevComputed = prevPath?.node.computed;
+ const prevArray = t.isArrayExpression(prevPath);
+ const array = t.isArrayExpression(path);
+ const value = path?.node.property?.extra?.raw || "";
+
+ if (expression === "") {
+ if (computed) {
+ return name === undefined ? `[${value}]` : `[${name}]`;
+ }
+ return name;
+ }
+
+ if (computed || array) {
+ if (prevComputed || prevArray) {
+ return `[${name}]${expression}`;
+ }
+ return `[${name === undefined ? value : name}].${expression}`;
+ }
+
+ if (prevComputed || prevArray) {
+ return `${name}${expression}`;
+ }
+
+ if (isComputedExpression(expression) && name !== undefined) {
+ return `${name}${expression}`;
+ }
+
+ if (optional) {
+ return `${name}?.${expression}`;
+ }
+
+ return `${name}.${expression}`;
+}
+
+function getMemberSnippet(node, expression = "", optional = false) {
+ if (t.isMemberExpression(node) || t.isOptionalMemberExpression(node)) {
+ const name = t.isPrivateName(node.property)
+ ? `#${node.property.id.name}`
+ : node.property.name;
+ const snippet = getMemberSnippet(
+ node.object,
+ extendSnippet(name, expression, { node }),
+ node.optional
+ );
+ return snippet;
+ }
+
+ if (t.isCallExpression(node)) {
+ return "";
+ }
+
+ if (t.isThisExpression(node)) {
+ return `this.${expression}`;
+ }
+
+ if (t.isIdentifier(node)) {
+ if (isComputedExpression(expression)) {
+ return `${node.name}${expression}`;
+ }
+ if (optional) {
+ return `${node.name}?.${expression}`;
+ }
+ return `${node.name}.${expression}`;
+ }
+
+ return expression;
+}
+
+function getObjectSnippet(path, prevPath, expression = "") {
+ if (!path) {
+ return expression;
+ }
+
+ const { name } = path.node.key;
+
+ const extendedExpression = extendSnippet(name, expression, path, prevPath);
+
+ const nextPrevPath = path;
+ const nextPath = path.parentPath && path.parentPath.parentPath;
+
+ return getSnippet(nextPath, nextPrevPath, extendedExpression);
+}
+
+function getArraySnippet(path, prevPath, expression) {
+ if (!prevPath.parentPath) {
+ throw new Error("Assertion failure - path should exist");
+ }
+
+ const index = `${prevPath.parentPath.containerIndex}`;
+ const extendedExpression = extendSnippet(index, expression, path, prevPath);
+
+ const nextPrevPath = path;
+ const nextPath = path.parentPath && path.parentPath.parentPath;
+
+ return getSnippet(nextPath, nextPrevPath, extendedExpression);
+}
+
+function getSnippet(path, prevPath, expression = "") {
+ if (!path) {
+ return expression;
+ }
+
+ if (t.isVariableDeclaration(path)) {
+ const node = path.node.declarations[0];
+ const { name } = node.id;
+ return extendSnippet(name, expression, path, prevPath);
+ }
+
+ if (t.isVariableDeclarator(path)) {
+ const node = path.node.id;
+ if (t.isObjectPattern(node)) {
+ return expression;
+ }
+
+ const prop = extendSnippet(node.name, expression, path, prevPath);
+ return prop;
+ }
+
+ if (t.isAssignmentExpression(path)) {
+ const node = path.node.left;
+ const name = t.isMemberExpression(node)
+ ? getMemberSnippet(node)
+ : node.name;
+
+ const prop = extendSnippet(name, expression, path, prevPath);
+ return prop;
+ }
+
+ if (isFunction(path)) {
+ return expression;
+ }
+
+ if (t.isIdentifier(path)) {
+ return `${path.node.name}.${expression}`;
+ }
+
+ if (t.isObjectProperty(path)) {
+ return getObjectSnippet(path, prevPath, expression);
+ }
+
+ if (t.isObjectExpression(path)) {
+ const parentPath = prevPath?.parentPath;
+ return getObjectSnippet(parentPath, prevPath, expression);
+ }
+
+ if (t.isMemberExpression(path) || t.isOptionalMemberExpression(path)) {
+ return getMemberSnippet(path.node, expression);
+ }
+
+ if (t.isArrayExpression(path)) {
+ if (!prevPath) {
+ throw new Error("Assertion failure - path should exist");
+ }
+
+ return getArraySnippet(path, prevPath, expression);
+ }
+
+ return "";
+}
+
+export function clearSymbols() {
+ symbolDeclarations = new Map();
+}
+
+export function getSymbols(sourceId) {
+ if (symbolDeclarations.has(sourceId)) {
+ const symbols = symbolDeclarations.get(sourceId);
+ if (symbols) {
+ return symbols;
+ }
+ }
+
+ const symbols = extractSymbols(sourceId);
+
+ symbolDeclarations.set(sourceId, symbols);
+ return symbols;
+}
+
+function getUniqueIdentifiers(identifiers) {
+ const newIdentifiers = [];
+ const locationKeys = new Set();
+ for (const newId of identifiers) {
+ const key = nodeLocationKey(newId);
+ if (!locationKeys.has(key)) {
+ locationKeys.add(key);
+ newIdentifiers.push(newId);
+ }
+ }
+
+ return newIdentifiers;
+}
+
+function getMemberExpressionSymbol(path) {
+ const { start, end } = path.node.property.loc;
+ return {
+ name: t.isPrivateName(path.node.property)
+ ? `#${path.node.property.id.name}`
+ : path.node.property.name,
+ location: { start, end },
+ expression: getSnippet(path),
+ computed: path.node.computed,
+ };
+}
+
+function getImportDeclarationSymbol(node) {
+ return {
+ source: node.source.value,
+ location: node.loc,
+ specifiers: getSpecifiers(node.specifiers),
+ };
+}
+
+function getObjectPropertySymbol(path) {
+ const { start, end, identifierName } = path.node.key.loc;
+ return {
+ name: identifierName,
+ location: { start, end },
+ expression: getSnippet(path),
+ };
+}
+
+function getCallExpressionSymbol(node) {
+ const { callee, arguments: args } = node;
+ const values = args.filter(arg => arg.value).map(arg => arg.value);
+ if (t.isMemberExpression(callee)) {
+ const {
+ property: { name, loc },
+ } = callee;
+ return {
+ name,
+ values,
+ location: loc,
+ };
+ }
+ const { start, end, identifierName } = callee.loc;
+ return {
+ name: identifierName,
+ values,
+ location: { start, end },
+ };
+}
+
+function getClassParentName(superClass) {
+ return t.isMemberExpression(superClass)
+ ? getCode(superClass)
+ : superClass.name;
+}
+
+function getClassParentSymbol(superClass) {
+ if (!superClass) {
+ return null;
+ }
+ return {
+ name: getClassParentName(superClass),
+ location: superClass.loc,
+ };
+}
+
+function getClassDeclarationSymbol(node) {
+ const { loc, superClass } = node;
+ return {
+ name: node.id.name,
+ parent: getClassParentSymbol(superClass),
+ location: loc,
+ };
+}
+
+/**
+ * Get a list of identifiers that are part of the given path.
+ *
+ * @param {Object} path
+ * @returns {Array.<Object>} a list of identifiers
+ */
+function getIdentifierSymbols(path) {
+ if (t.isStringLiteral(path) && t.isProperty(path.parentPath)) {
+ const { start, end } = path.node.loc;
+ return [
+ {
+ name: path.node.value,
+ expression: getObjectExpressionValue(path.parent),
+ location: { start, end },
+ },
+ ];
+ }
+
+ const identifiers = [];
+ if (t.isIdentifier(path) && !t.isGenericTypeAnnotation(path.parent)) {
+ // We want to include function params, but exclude the function name
+ if (t.isClassMethod(path.parent) && !path.inList) {
+ return [];
+ }
+
+ if (t.isProperty(path.parentPath) && !isObjectShorthand(path.parent)) {
+ const { start, end } = path.node.loc;
+ return [
+ {
+ name: path.node.name,
+ expression: getObjectExpressionValue(path.parent),
+ location: { start, end },
+ },
+ ];
+ }
+
+ let { start, end } = path.node.loc;
+ if (path.node.typeAnnotation) {
+ const { column } = path.node.typeAnnotation.loc.start;
+ end = { ...end, column };
+ }
+
+ identifiers.push({
+ name: path.node.name,
+ expression: path.node.name,
+ location: { start, end },
+ });
+ }
+
+ if (t.isThisExpression(path.node)) {
+ const { start, end } = path.node.loc;
+ identifiers.push({
+ name: "this",
+ location: { start, end },
+ expression: "this",
+ });
+ }
+
+ if (t.isVariableDeclarator(path)) {
+ const nodeId = path.node.id;
+
+ identifiers.push(...getPatternIdentifiers(nodeId));
+ }
+
+ return identifiers;
+}
diff --git a/devtools/client/debugger/src/workers/parser/index.js b/devtools/client/debugger/src/workers/parser/index.js
new file mode 100644
index 0000000000..5f038179d3
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/index.js
@@ -0,0 +1,53 @@
+/* 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 { WorkerDispatcher } from "devtools/client/shared/worker-utils";
+
+const WORKER_URL = "resource://devtools/client/debugger/dist/parser-worker.js";
+
+export class ParserDispatcher extends WorkerDispatcher {
+ constructor(jestUrl) {
+ super(jestUrl || WORKER_URL);
+ }
+
+ findOutOfScopeLocations = this.task("findOutOfScopeLocations");
+
+ getScopes = this.task("getScopes");
+
+ getSymbols = this.task("getSymbols");
+
+ async setSource(sourceId, content) {
+ const astSource = {
+ id: sourceId,
+ text: content.type === "wasm" ? "" : content.value,
+ contentType: content.contentType || null,
+ isWasm: content.type === "wasm",
+ };
+
+ return this.invoke("setSource", astSource);
+ }
+
+ hasSyntaxError = this.task("hasSyntaxError");
+
+ mapExpression = this.task("mapExpression");
+
+ clear = this.task("clearState");
+
+ /**
+ * Reports if the location's source can be parsed by this worker.
+ *
+ * @param {Object} location
+ * A debugger frontend location object. See createLocation().
+ * @return {Boolean}
+ * True, if the worker may be able to parse this source.
+ */
+ isLocationSupported(location) {
+ // There might be more sources that the worker doesn't support,
+ // like original sources which aren't JavaScript.
+ // But we can only know with the source's content type,
+ // which isn't available right away.
+ // These source will be ignored from within the worker.
+ return !location.source.isWasm;
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/mapAwaitExpression.js b/devtools/client/debugger/src/workers/parser/mapAwaitExpression.js
new file mode 100644
index 0000000000..d9f99169c0
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/mapAwaitExpression.js
@@ -0,0 +1,199 @@
+/* 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 generate from "@babel/generator";
+import * as t from "@babel/types";
+
+import { hasNode, replaceNode } from "./utils/ast";
+import { isTopLevel } from "./utils/helpers";
+
+function hasTopLevelAwait(ast) {
+ const hasAwait = hasNode(
+ ast,
+ (node, ancestors, b) => t.isAwaitExpression(node) && isTopLevel(ancestors)
+ );
+
+ return hasAwait;
+}
+
+// translates new bindings `var a = 3` into `a = 3`.
+function translateDeclarationIntoAssignment(node) {
+ return node.declarations.reduce((acc, declaration) => {
+ // Don't translate declaration without initial assignment (e.g. `var a;`)
+ if (!declaration.init) {
+ return acc;
+ }
+ acc.push(
+ t.expressionStatement(
+ t.assignmentExpression("=", declaration.id, declaration.init)
+ )
+ );
+ return acc;
+ }, []);
+}
+
+/**
+ * Given an AST, compute its last statement and replace it with a
+ * return statement.
+ */
+function addReturnNode(ast) {
+ const statements = ast.program.body;
+ const lastStatement = statements.pop();
+
+ // if the last expression is an awaitExpression, strip the `await` part and directly
+ // return the argument to avoid calling the argument's `then` function twice when the
+ // mapped expression gets evaluated (See Bug 1771428)
+ if (t.isAwaitExpression(lastStatement.expression)) {
+ lastStatement.expression = lastStatement.expression.argument;
+ }
+ statements.push(t.returnStatement(lastStatement.expression));
+ return statements;
+}
+
+function getDeclarations(node) {
+ const { kind, declarations } = node;
+ const declaratorNodes = declarations.reduce((acc, d) => {
+ const declarators = getVariableDeclarators(d.id);
+ return acc.concat(declarators);
+ }, []);
+
+ // We can't declare const variables outside of the async iife because we
+ // wouldn't be able to re-assign them. As a workaround, we transform them
+ // to `let` which should be good enough for those case.
+ return t.variableDeclaration(
+ kind === "const" ? "let" : kind,
+ declaratorNodes
+ );
+}
+
+function getVariableDeclarators(node) {
+ if (t.isIdentifier(node)) {
+ return t.variableDeclarator(t.identifier(node.name));
+ }
+
+ if (t.isObjectProperty(node)) {
+ return getVariableDeclarators(node.value);
+ }
+ if (t.isRestElement(node)) {
+ return getVariableDeclarators(node.argument);
+ }
+
+ if (t.isAssignmentPattern(node)) {
+ return getVariableDeclarators(node.left);
+ }
+
+ if (t.isArrayPattern(node)) {
+ return node.elements.reduce(
+ (acc, element) => acc.concat(getVariableDeclarators(element)),
+ []
+ );
+ }
+ if (t.isObjectPattern(node)) {
+ return node.properties.reduce(
+ (acc, property) => acc.concat(getVariableDeclarators(property)),
+ []
+ );
+ }
+ return [];
+}
+
+/**
+ * Given an AST and an array of variableDeclaration nodes, return a new AST with
+ * all the declarations at the top of the AST.
+ */
+function addTopDeclarationNodes(ast, declarationNodes) {
+ const statements = [];
+ declarationNodes.forEach(declarationNode => {
+ statements.push(getDeclarations(declarationNode));
+ });
+ statements.push(ast);
+ return t.program(statements);
+}
+
+/**
+ * Given an AST, return an object of the following shape:
+ * - newAst: {AST} the AST where variable declarations were transformed into
+ * variable assignments
+ * - declarations: {Array<Node>} An array of all the declaration nodes needed
+ * outside of the async iife.
+ */
+function translateDeclarationsIntoAssignment(ast) {
+ const declarations = [];
+ t.traverse(ast, (node, ancestors) => {
+ const parent = ancestors[ancestors.length - 1];
+
+ if (
+ t.isWithStatement(node) ||
+ !isTopLevel(ancestors) ||
+ t.isAssignmentExpression(node) ||
+ !t.isVariableDeclaration(node) ||
+ t.isForStatement(parent.node) ||
+ t.isForXStatement(parent.node) ||
+ !Array.isArray(node.declarations) ||
+ node.declarations.length === 0
+ ) {
+ return;
+ }
+
+ const newNodes = translateDeclarationIntoAssignment(node);
+ replaceNode(ancestors, newNodes);
+ declarations.push(node);
+ });
+
+ return {
+ newAst: ast,
+ declarations,
+ };
+}
+
+/**
+ * Given an AST, wrap its body in an async iife, transform variable declarations
+ * in assignments and move the variable declarations outside of the async iife.
+ * Example: With the AST for the following expression: `let a = await 123`, the
+ * function will return:
+ * let a;
+ * (async => {
+ * return a = await 123;
+ * })();
+ */
+function wrapExpressionFromAst(ast) {
+ // Transform let and var declarations into assignments, and get back an array
+ // of variable declarations.
+ let { newAst, declarations } = translateDeclarationsIntoAssignment(ast);
+ const body = addReturnNode(newAst);
+
+ // Create the async iife.
+ newAst = t.expressionStatement(
+ t.callExpression(
+ t.arrowFunctionExpression([], t.blockStatement(body), true),
+ []
+ )
+ );
+
+ // Now let's put all the variable declarations at the top of the async iife.
+ newAst = addTopDeclarationNodes(newAst, declarations);
+
+ return generate(newAst).code;
+}
+
+export default function mapTopLevelAwait(expression, ast) {
+ if (!ast) {
+ // If there's no ast this means the expression is malformed. And if the
+ // expression contains the await keyword, we still want to wrap it in an
+ // async iife in order to get a meaningful message (without this, the
+ // engine will throw an Error stating that await keywords are only valid
+ // in async functions and generators).
+ if (expression.includes("await ")) {
+ return `(async () => { ${expression} })();`;
+ }
+
+ return expression;
+ }
+
+ if (!hasTopLevelAwait(ast)) {
+ return expression;
+ }
+
+ return wrapExpressionFromAst(ast);
+}
diff --git a/devtools/client/debugger/src/workers/parser/mapBindings.js b/devtools/client/debugger/src/workers/parser/mapBindings.js
new file mode 100644
index 0000000000..f8260787f1
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/mapBindings.js
@@ -0,0 +1,120 @@
+/* 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 { replaceNode } from "./utils/ast";
+import { isTopLevel } from "./utils/helpers";
+
+import generate from "@babel/generator";
+import * as t from "@babel/types";
+
+function getAssignmentTarget(node, bindings) {
+ if (t.isObjectPattern(node)) {
+ for (const property of node.properties) {
+ if (t.isRestElement(property)) {
+ property.argument = getAssignmentTarget(property.argument, bindings);
+ } else {
+ property.value = getAssignmentTarget(property.value, bindings);
+ }
+ }
+
+ return node;
+ }
+
+ if (t.isArrayPattern(node)) {
+ for (const [i, element] of node.elements.entries()) {
+ node.elements[i] = getAssignmentTarget(element, bindings);
+ }
+
+ return node;
+ }
+
+ if (t.isAssignmentPattern(node)) {
+ node.left = getAssignmentTarget(node.left, bindings);
+
+ return node;
+ }
+
+ if (t.isRestElement(node)) {
+ node.argument = getAssignmentTarget(node.argument, bindings);
+
+ return node;
+ }
+
+ if (t.isIdentifier(node)) {
+ return bindings.includes(node.name)
+ ? node
+ : t.memberExpression(t.identifier("self"), node);
+ }
+
+ return node;
+}
+
+// translates new bindings `var a = 3` into `self.a = 3`
+// and existing bindings `var a = 3` into `a = 3` for re-assignments
+function globalizeDeclaration(node, bindings) {
+ return node.declarations.map(declaration =>
+ t.expressionStatement(
+ t.assignmentExpression(
+ "=",
+ getAssignmentTarget(declaration.id, bindings),
+ declaration.init || t.unaryExpression("void", t.numericLiteral(0))
+ )
+ )
+ );
+}
+
+// translates new bindings `a = 3` into `self.a = 3`
+// and keeps assignments the same for existing bindings.
+function globalizeAssignment(node, bindings) {
+ return t.assignmentExpression(
+ node.operator,
+ getAssignmentTarget(node.left, bindings),
+ node.right
+ );
+}
+
+export default function mapExpressionBindings(expression, ast, bindings = []) {
+ let isMapped = false;
+ let shouldUpdate = true;
+
+ t.traverse(ast, (node, ancestors) => {
+ const parent = ancestors[ancestors.length - 1];
+
+ if (t.isWithStatement(node)) {
+ shouldUpdate = false;
+ return;
+ }
+
+ if (!isTopLevel(ancestors)) {
+ return;
+ }
+
+ if (t.isAssignmentExpression(node)) {
+ if (t.isIdentifier(node.left) || t.isPattern(node.left)) {
+ const newNode = globalizeAssignment(node, bindings);
+ isMapped = true;
+ replaceNode(ancestors, newNode);
+ return;
+ }
+
+ return;
+ }
+
+ if (!t.isVariableDeclaration(node)) {
+ return;
+ }
+
+ if (!t.isForStatement(parent.node)) {
+ const newNodes = globalizeDeclaration(node, bindings);
+ isMapped = true;
+ replaceNode(ancestors, newNodes);
+ }
+ });
+
+ if (!shouldUpdate || !isMapped) {
+ return expression;
+ }
+
+ return generate(ast).code;
+}
diff --git a/devtools/client/debugger/src/workers/parser/mapExpression.js b/devtools/client/debugger/src/workers/parser/mapExpression.js
new file mode 100644
index 0000000000..71f3b016fc
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/mapExpression.js
@@ -0,0 +1,50 @@
+/* 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 { parseConsoleScript } from "./utils/ast";
+import mapOriginalExpression from "./mapOriginalExpression";
+import mapExpressionBindings from "./mapBindings";
+import mapTopLevelAwait from "./mapAwaitExpression";
+
+export default function mapExpression(
+ expression,
+ mappings,
+ bindings,
+ shouldMapBindings = true,
+ shouldMapAwait = true
+) {
+ const mapped = {
+ await: false,
+ bindings: false,
+ originalExpression: false,
+ };
+
+ const ast = parseConsoleScript(expression);
+ try {
+ if (mappings && ast) {
+ const beforeOriginalExpression = expression;
+ expression = mapOriginalExpression(expression, ast, mappings);
+ mapped.originalExpression = beforeOriginalExpression !== expression;
+ }
+
+ if (shouldMapBindings && ast) {
+ const beforeBindings = expression;
+ expression = mapExpressionBindings(expression, ast, bindings);
+ mapped.bindings = beforeBindings !== expression;
+ }
+
+ if (shouldMapAwait) {
+ const beforeAwait = expression;
+ expression = mapTopLevelAwait(expression, ast);
+ mapped.await = beforeAwait !== expression;
+ }
+ } catch (e) {
+ console.warn(`Error when mapping ${expression} expression:`, e);
+ }
+
+ return {
+ expression,
+ mapped,
+ };
+}
diff --git a/devtools/client/debugger/src/workers/parser/mapOriginalExpression.js b/devtools/client/debugger/src/workers/parser/mapOriginalExpression.js
new file mode 100644
index 0000000000..1724db9838
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/mapOriginalExpression.js
@@ -0,0 +1,106 @@
+/* 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 { parseScript } from "./utils/ast";
+import { buildScopeList } from "./getScopes";
+import generate from "@babel/generator";
+import * as t from "@babel/types";
+
+// NOTE: this will only work if we are replacing an original identifier
+function replaceNode(ancestors, node) {
+ const ancestor = ancestors[ancestors.length - 1];
+
+ if (typeof ancestor.index === "number") {
+ ancestor.node[ancestor.key][ancestor.index] = node;
+ } else {
+ ancestor.node[ancestor.key] = node;
+ }
+}
+
+function getFirstExpression(ast) {
+ const statements = ast.program.body;
+ if (!statements.length) {
+ return null;
+ }
+
+ return statements[0].expression;
+}
+
+function locationKey(start) {
+ return `${start.line}:${start.column}`;
+}
+
+export default function mapOriginalExpression(expression, ast, mappings) {
+ const scopes = buildScopeList(ast, "");
+ let shouldUpdate = false;
+
+ const nodes = new Map();
+ const replacements = new Map();
+
+ // The ref-only global bindings are the ones that are accessed, but not
+ // declared anywhere in the parsed code, meaning they are either global,
+ // or declared somewhere in a scope outside the parsed code, so we
+ // rewrite all of those specifically to avoid rewritting declarations that
+ // shadow outer mappings.
+ for (const name of Object.keys(scopes[0].bindings)) {
+ const { refs } = scopes[0].bindings[name];
+ const mapping = mappings[name];
+
+ if (
+ !refs.every(ref => ref.type === "ref") ||
+ !mapping ||
+ mapping === name
+ ) {
+ continue;
+ }
+
+ let node = nodes.get(name);
+ if (!node) {
+ node = getFirstExpression(parseScript(mapping));
+ nodes.set(name, node);
+ }
+
+ for (const ref of refs) {
+ let { line, column } = ref.start;
+
+ // This shouldn't happen, just keeping Flow happy.
+ if (typeof column !== "number") {
+ column = 0;
+ }
+
+ replacements.set(locationKey({ line, column }), node);
+ }
+ }
+
+ if (replacements.size === 0) {
+ // Avoid the extra code generation work and also avoid potentially
+ // reformatting the user's code unnecessarily.
+ return expression;
+ }
+
+ t.traverse(ast, (node, ancestors) => {
+ if (!t.isIdentifier(node) && !t.isThisExpression(node)) {
+ return;
+ }
+
+ const ancestor = ancestors[ancestors.length - 1];
+ // Shorthand properties can have a key and value with `node.loc.start` value
+ // and we only want to replace the value.
+ if (t.isObjectProperty(ancestor.node) && ancestor.key !== "value") {
+ return;
+ }
+
+ const replacement = replacements.get(locationKey(node.loc.start));
+ if (replacement) {
+ replaceNode(ancestors, t.cloneNode(replacement));
+ shouldUpdate = true;
+ }
+ });
+
+ if (shouldUpdate) {
+ return generate(ast).code;
+ }
+
+ return expression;
+}
diff --git a/devtools/client/debugger/src/workers/parser/moz.build b/devtools/client/debugger/src/workers/parser/moz.build
new file mode 100644
index 0000000000..b7223ac81a
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/moz.build
@@ -0,0 +1,10 @@
+# vim: set filetype=python:
+# 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/.
+
+DIRS += []
+
+CompiledModules(
+ "index.js",
+)
diff --git a/devtools/client/debugger/src/workers/parser/sources.js b/devtools/client/debugger/src/workers/parser/sources.js
new file mode 100644
index 0000000000..59293c9e0a
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/sources.js
@@ -0,0 +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/>. */
+
+const cachedSources = new Map();
+
+export function setSource(source) {
+ cachedSources.set(source.id, source);
+}
+
+export function getSource(sourceId) {
+ const source = cachedSources.get(sourceId);
+ if (!source) {
+ throw new Error(`Parser: source ${sourceId} was not provided.`);
+ }
+
+ return source;
+}
+
+export function clearSources() {
+ cachedSources.clear();
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/__snapshots__/findOutOfScopeLocations.spec.js.snap b/devtools/client/debugger/src/workers/parser/tests/__snapshots__/findOutOfScopeLocations.spec.js.snap
new file mode 100644
index 0000000000..4689f0c824
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/__snapshots__/findOutOfScopeLocations.spec.js.snap
@@ -0,0 +1,47 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Parser.findOutOfScopeLocations should exclude function for locations on declaration 1`] = `
+"(1, 0) -> (1, 16)
+(3, 14) -> (27, 1)
+(29, 16) -> (33, 1)
+(35, 20) -> (37, 1)
+(39, 26) -> (41, 1)
+(43, 20) -> (45, 1)
+(47, 31) -> (49, 1)
+(51, 19) -> (62, 1)"
+`;
+
+exports[`Parser.findOutOfScopeLocations should exclude non-enclosing function blocks 1`] = `
+"(1, 0) -> (1, 16)
+(8, 16) -> (10, 3)
+(12, 22) -> (14, 3)
+(16, 16) -> (18, 3)
+(20, 27) -> (22, 3)
+(24, 9) -> (26, 3)
+(29, 16) -> (33, 1)
+(35, 20) -> (37, 1)
+(39, 26) -> (41, 1)
+(43, 20) -> (45, 1)
+(47, 31) -> (49, 1)
+(51, 19) -> (62, 1)"
+`;
+
+exports[`Parser.findOutOfScopeLocations should not exclude in-scope inner locations 1`] = `
+"(1, 0) -> (1, 16)
+(3, 14) -> (27, 1)
+(29, 16) -> (33, 1)
+(35, 20) -> (37, 1)
+(39, 26) -> (41, 1)
+(43, 20) -> (45, 1)
+(47, 31) -> (49, 1)"
+`;
+
+exports[`Parser.findOutOfScopeLocations should roll up function blocks 1`] = `
+"(1, 0) -> (1, 16)
+(29, 16) -> (33, 1)
+(35, 20) -> (37, 1)
+(39, 26) -> (41, 1)
+(43, 20) -> (45, 1)
+(47, 31) -> (49, 1)
+(51, 19) -> (62, 1)"
+`;
diff --git a/devtools/client/debugger/src/workers/parser/tests/__snapshots__/getScopes.spec.js.snap b/devtools/client/debugger/src/workers/parser/tests/__snapshots__/getScopes.spec.js.snap
new file mode 100644
index 0000000000..f1ea6c9d15
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/__snapshots__/getScopes.spec.js.snap
@@ -0,0 +1,18767 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Parser.getScopes finds scope bindings and exclude Flowtype: getScopes finds scope bindings and exclude Flowtype at line 8 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "aConst": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 39,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 9,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "start": Object {
+ "column": 24,
+ "line": 9,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 22,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings and exclude Flowtype: getScopes finds scope bindings and exclude Flowtype at line 10 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "root",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "aConst": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 39,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 9,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "start": Object {
+ "column": 24,
+ "line": 9,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 22,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 7,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/flowtype-bindings/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for arrow functions: getScopes finds scope bindings for arrow functions at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 18,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 13,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 17,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for arrow functions: getScopes finds scope bindings for arrow functions at line 4 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "p1": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 13,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "outer",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 13,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 18,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 13,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 17,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for arrow functions: getScopes finds scope bindings for arrow functions at line 7 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 6,
+ "line": 9,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 22,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 18,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "anonymous",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 3,
+ "line": 6,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "p1": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 13,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "outer",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 13,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 18,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 13,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 17,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for arrow functions: getScopes finds scope bindings for arrow functions at line 8 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "p2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 16,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 19,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 17,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "inner",
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 17,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 6,
+ "line": 9,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 22,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 18,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "anonymous",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 3,
+ "line": 6,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "p1": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 13,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "outer",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 13,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 18,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 13,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 17,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/arrow-function/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for block statements: getScopes finds scope bindings for block statements at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "first": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "second": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 6,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 6,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seventh": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 13,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 13,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for block statements: getScopes finds scope bindings for block statements at line 6 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Fourth": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 17,
+ "line": 8,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 8,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 8,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "fifth": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 9,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 9,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 9,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "sixth": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 18,
+ "line": 10,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 10,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ "third": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 21,
+ "line": 7,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 7,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 16,
+ "line": 7,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Block",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "first": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "second": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 6,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 6,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seventh": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 13,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 13,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/block-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class declarations: getScopes finds scope bindings for class declarations at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "Second": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 15,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 15,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 19,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "decorator": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 10,
+ "line": 13,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 13,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class declarations: getScopes finds scope bindings for class declarations at line 5 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Function Body",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 11,
+ "line": 4,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "method",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "Second": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 15,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 15,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 19,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "decorator": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 10,
+ "line": 13,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 13,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class declarations: getScopes finds scope bindings for class declarations at line 7 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 24,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 20,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "m",
+ "end": Object {
+ "column": 7,
+ "line": 8,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 5,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Function Body",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 11,
+ "line": 4,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "method",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "Second": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 15,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 14,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 15,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 19,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "decorator": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 10,
+ "line": 13,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 13,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-declaration/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class expressions: getScopes finds scope bindings for class expressions at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 15,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 19,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class expressions: getScopes finds scope bindings for class expressions at line 5 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 6,
+ "line": 9,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "method",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 23,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 18,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 15,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 19,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class expressions: getScopes finds scope bindings for class expressions at line 7 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 24,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 20,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "m",
+ "end": Object {
+ "column": 7,
+ "line": 8,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 6,
+ "line": 9,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "method",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 23,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 18,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 15,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 19,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-expression/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class properties: getScopes finds scope bindings for class properties at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class properties: getScopes finds scope bindings for class properties at line 4 column 16 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 4,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 18,
+ "line": 4,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 20,
+ "line": 4,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "parent": null,
+ "start": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "call",
+ },
+ "property": "init",
+ "start": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Class Field",
+ "end": Object {
+ "column": 20,
+ "line": 4,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class properties: getScopes finds scope bindings for class properties at line 6 column 12 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Class Field",
+ "end": Object {
+ "column": 3,
+ "line": 9,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 10,
+ "line": 6,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for class properties: getScopes finds scope bindings for class properties at line 7 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 8,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 8,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 8,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 8,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Block",
+ "end": Object {
+ "column": 3,
+ "line": 9,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 13,
+ "line": 6,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Class Field",
+ "end": Object {
+ "column": 3,
+ "line": 9,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 10,
+ "line": 6,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 10,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/class-property/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for complex binding nesting: getScopes finds scope bindings for complex binding nesting at line 16 column 4 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "_arguments": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 31,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "var",
+ },
+ Object {
+ "end": Object {
+ "column": 35,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 25,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "_this": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 31,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "var",
+ },
+ Object {
+ "end": Object {
+ "column": 23,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 18,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "arg": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 23,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 17,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "arguments": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 30,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 21,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 31,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 22,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "arrow": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 6,
+ "line": 21,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "var",
+ },
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 22,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 20,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 20,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn",
+ "end": Object {
+ "column": 3,
+ "line": 23,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 23,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 32,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 30,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 34,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 32,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 4,
+ "line": 25,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 9,
+ "line": 25,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "call",
+ "start": Object {
+ "column": 2,
+ "line": 25,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 25,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "root",
+ "end": Object {
+ "column": 1,
+ "line": 26,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "__webpack_require__": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 51,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 32,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "exports": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 30,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 23,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ Object {
+ "end": Object {
+ "column": 29,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 22,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "default",
+ "start": Object {
+ "column": 0,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 24,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 35,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "default",
+ "start": Object {
+ "column": 17,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 17,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "module": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 21,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 14,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "exports",
+ "start": Object {
+ "column": 0,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 26,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 10,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 22,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 18,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 38,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 34,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 40,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 36,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "named",
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 30,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Object": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 21,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "defineProperty",
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 17,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 6,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 17,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 6,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "named": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 30,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for complex binding nesting: getScopes finds scope bindings for complex binding nesting at line 20 column 6 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "argArrow": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 5,
+ "line": 21,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 16,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 39,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 31,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "arrow",
+ "end": Object {
+ "column": 5,
+ "line": 21,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 31,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "arrow": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 5,
+ "line": 21,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 16,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 30,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 25,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-expr",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Function Expression",
+ "end": Object {
+ "column": 5,
+ "line": 21,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 16,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "_arguments": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 31,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "var",
+ },
+ Object {
+ "end": Object {
+ "column": 35,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 25,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "_this": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 31,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "var",
+ },
+ Object {
+ "end": Object {
+ "column": 23,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 18,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "arg": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 23,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 17,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "arguments": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 30,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 21,
+ "line": 13,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 31,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 22,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "arrow": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 6,
+ "line": 21,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 18,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "var",
+ },
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 22,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 20,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 12,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 20,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn",
+ "end": Object {
+ "column": 3,
+ "line": 23,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 23,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 11,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 32,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 30,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 34,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 32,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 4,
+ "line": 25,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 9,
+ "line": 25,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "call",
+ "start": Object {
+ "column": 2,
+ "line": 25,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 25,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "root",
+ "end": Object {
+ "column": 1,
+ "line": 26,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "__webpack_require__": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 51,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 32,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "exports": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 30,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 23,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ Object {
+ "end": Object {
+ "column": 29,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 22,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "default",
+ "start": Object {
+ "column": 0,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 24,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 35,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "default",
+ "start": Object {
+ "column": 17,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 17,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "module": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 21,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 14,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "exports",
+ "start": Object {
+ "column": 0,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 27,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 26,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 10,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 22,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 18,
+ "line": 9,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 38,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 34,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 40,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 36,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "named",
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 30,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Object": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 21,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "defineProperty",
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 15,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 16,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 17,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 6,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 19,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 13,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 17,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 6,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 20,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "named": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 29,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 30,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/complex-nesting/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for declarations with patterns: getScopes finds scope bindings for declarations with patterns at line 1 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 23,
+ "line": 1,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 1,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 1,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 17,
+ "line": 2,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 2,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 2,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/pattern-declarations/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 3 column 17 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 4 column 17 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 4,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "For",
+ "end": Object {
+ "column": 18,
+ "line": 4,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 5,
+ "line": 4,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 5 column 25 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "three": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 20,
+ "line": 5,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 5,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 16,
+ "line": 5,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 5,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "For",
+ "end": Object {
+ "column": 26,
+ "line": 5,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 5,
+ "line": 5,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 7 column 22 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 8 column 22 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "five": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 8,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 8,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 8,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 8,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "For",
+ "end": Object {
+ "column": 23,
+ "line": 8,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 5,
+ "line": 8,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 9 column 23 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "six": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 9,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 9,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 9,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "For",
+ "end": Object {
+ "column": 24,
+ "line": 9,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 5,
+ "line": 9,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 11 column 23 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 12 column 23 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "eight": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 12,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 12,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 12,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 12,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "For",
+ "end": Object {
+ "column": 24,
+ "line": 12,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 5,
+ "line": 12,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for for loops: getScopes finds scope bindings for for loops at line 13 column 24 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "nine": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 15,
+ "line": 13,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 13,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 13,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 13,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "For",
+ "end": Object {
+ "column": 25,
+ "line": 13,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 5,
+ "line": 13,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "four": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "seven": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 11,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/for-loops/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for function declarations: getScopes finds scope bindings for function declarations at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 21,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for function declarations: getScopes finds scope bindings for function declarations at line 3 column 20 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "p1": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 21,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 17,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "outer",
+ "end": Object {
+ "column": 21,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 21,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for function declarations: getScopes finds scope bindings for function declarations at line 5 column 1 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "middle": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 17,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Block",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 21,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for function declarations: getScopes finds scope bindings for function declarations at line 9 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 25,
+ "line": 7,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 7,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 13,
+ "line": 7,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "p2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 20,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 18,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 20,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "middle",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 18,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "middle": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 17,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 6,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Block",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "outer": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 21,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-declaration/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for function expressions: getScopes finds scope bindings for function expressions at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 25,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "fn2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 7,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 13,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for function expressions: getScopes finds scope bindings for function expressions at line 3 column 23 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "p1": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 24,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 20,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 18,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn",
+ "end": Object {
+ "column": 24,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 18,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 25,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "fn2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 7,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 13,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for function expressions: getScopes finds scope bindings for function expressions at line 6 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "p2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 7,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 30,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 28,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 18,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "withName",
+ "end": Object {
+ "column": 1,
+ "line": 7,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 28,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "withName": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 7,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 27,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 19,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "fn-expr",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Function Expression",
+ "end": Object {
+ "column": 1,
+ "line": 7,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 10,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 25,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "fn2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 2,
+ "line": 7,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 13,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/function-expression/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for out of order declarations: getScopes finds scope bindings for out of order declarations at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "aDefault": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 33,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 39,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 35,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 8,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for out of order declarations: getScopes finds scope bindings for out of order declarations at line 5 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "callback": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 16,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 19,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 33,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 25,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 10,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 12,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "call",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 10,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "root",
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "aDefault": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 33,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 39,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 35,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 8,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for out of order declarations: getScopes finds scope bindings for out of order declarations at line 11 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 19,
+ "line": 15,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 15,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 15,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 13,
+ "line": 15,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 23,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 21,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 45,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 41,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 13,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 13,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "callback",
+ "end": Object {
+ "column": 3,
+ "line": 16,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "callback": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 16,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 19,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 33,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 25,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 10,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 12,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "call",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 10,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "root",
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "aDefault": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 33,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 39,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 35,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 8,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for out of order declarations: getScopes finds scope bindings for out of order declarations at line 14 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 19,
+ "line": 15,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 15,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 15,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 13,
+ "line": 15,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 23,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 21,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 45,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 41,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 13,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 13,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 16,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "callback",
+ "end": Object {
+ "column": 3,
+ "line": 16,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "callback": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 16,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 19,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 33,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 25,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 10,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 12,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "call",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 10,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "root",
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "aDefault": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 33,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 39,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 35,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 8,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for out of order declarations: getScopes finds scope bindings for out of order declarations at line 17 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "callback": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 16,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 19,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 10,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 33,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 25,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 10,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 12,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "call",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 6,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 10,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "root",
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "aDefault": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 33,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 21,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "root": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 39,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 35,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "val": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 8,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 15,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/out-of-order-declarations/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for switch statements: getScopes finds scope bindings for switch statements at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "zero": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for switch statements: getScopes finds scope bindings for switch statements at line 5 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Switch",
+ "end": Object {
+ "column": 1,
+ "line": 13,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "zero": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for switch statements: getScopes finds scope bindings for switch statements at line 7 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Switch",
+ "end": Object {
+ "column": 1,
+ "line": 13,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "zero": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for switch statements: getScopes finds scope bindings for switch statements at line 9 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Switch",
+ "end": Object {
+ "column": 1,
+ "line": 13,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "zero": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for switch statements: getScopes finds scope bindings for switch statements at line 11 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "three": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 14,
+ "line": 11,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 11,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 11,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Block",
+ "end": Object {
+ "column": 3,
+ "line": 12,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 16,
+ "line": 10,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 9,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Switch",
+ "end": Object {
+ "column": 1,
+ "line": 13,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "zero": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for switch statements: getScopes finds scope bindings for switch statements at line 17 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 20,
+ "line": 17,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 17,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 16,
+ "line": 17,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 13,
+ "line": 17,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Switch",
+ "end": Object {
+ "column": 1,
+ "line": 18,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "zero": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for switch statements: getScopes finds scope bindings for switch statements at line 21 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "three": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 18,
+ "line": 21,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 21,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 21,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 21,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Switch",
+ "end": Object {
+ "column": 1,
+ "line": 22,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "zero": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 5,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 15,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 8,
+ "line": 19,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 23,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/switch-statement/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for try..catch: getScopes finds scope bindings for try..catch at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "first": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "third": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for try..catch: getScopes finds scope bindings for try..catch at line 4 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "second": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 5,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 5,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Block",
+ "end": Object {
+ "column": 1,
+ "line": 6,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "first": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "third": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings for try..catch: getScopes finds scope bindings for try..catch at line 7 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "fourth": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 8,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 8,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 8,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Block",
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 14,
+ "line": 6,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "err": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 6,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "catch",
+ },
+ ],
+ "type": "var",
+ },
+ },
+ "displayName": "Catch",
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 6,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "first": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "third": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/try-catch/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a JSX element: getScopes finds scope bindings in a JSX element at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "SomeComponent": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 29,
+ "line": 1,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 20,
+ "line": 1,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 14,
+ "line": 3,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 3,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 14,
+ "line": 4,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 4,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 14,
+ "line": 5,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 5,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 14,
+ "line": 6,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 6,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "import",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/jsx-component/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a module: getScopes finds scope bindings in a module at line 7 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 16,
+ "line": 9,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 9,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 9,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 9,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 22,
+ "line": 1,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 15,
+ "line": 3,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "import",
+ },
+ "one": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 5,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 5,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 5,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 4,
+ "line": 11,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 0,
+ "line": 11,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "three": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 16,
+ "line": 7,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 7,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ "two": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 12,
+ "line": 6,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 6,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 6,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "console": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 3,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "parent": null,
+ "property": "log",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 12,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/simple-module/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a typescript file: getScopes finds scope bindings in a typescript file at line 9 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Color": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 8,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ts-enum-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 16,
+ "line": 41,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 9,
+ "line": 41,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "let",
+ },
+ "TheSpace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ts-namespace-decl",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Error": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 17,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 17,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 22,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 21,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 15,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 25,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 25,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 28,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 28,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a typescript file: getScopes finds scope bindings in a typescript file at line 13 column 4 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 14,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 12,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 24,
+ "line": 12,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 21,
+ "line": 12,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "constructor",
+ "end": Object {
+ "column": 3,
+ "line": 14,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 14,
+ "line": 12,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Color": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 8,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ts-enum-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 16,
+ "line": 41,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 9,
+ "line": 41,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "let",
+ },
+ "TheSpace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ts-namespace-decl",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Error": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 17,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 17,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 22,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 21,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 15,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 25,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 25,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 28,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 28,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a typescript file: getScopes finds scope bindings in a typescript file at line 17 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "method",
+ "end": Object {
+ "column": 3,
+ "line": 18,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 16,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Color": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 8,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ts-enum-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 16,
+ "line": 41,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 9,
+ "line": 41,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "let",
+ },
+ "TheSpace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ts-namespace-decl",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Error": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 17,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 17,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 22,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 21,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 15,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 25,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 25,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 28,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 28,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a typescript file: getScopes finds scope bindings in a typescript file at line 33 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn",
+ "end": Object {
+ "column": 3,
+ "line": 34,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 32,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 34,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 32,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 32,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 32,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "TypeScript Namespace",
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 19,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Color": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 8,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ts-enum-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 16,
+ "line": 41,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 9,
+ "line": 41,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "let",
+ },
+ "TheSpace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 31,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ts-namespace-decl",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Error": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 17,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 17,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 22,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 21,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 15,
+ "line": 22,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 25,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 25,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 28,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 28,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/ts-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a typescript-jsx file: getScopes finds scope bindings in a typescript-jsx file at line 9 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Color": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 8,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ts-enum-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 16,
+ "line": 41,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 9,
+ "line": 41,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "let",
+ },
+ "TheSpace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ts-namespace-decl",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Error": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 17,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 17,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "any": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 14,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 11,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 28,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 25,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 25,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 28,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 28,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a typescript-jsx file: getScopes finds scope bindings in a typescript-jsx file at line 13 column 4 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 14,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 12,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 24,
+ "line": 12,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 21,
+ "line": 12,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "fn-param",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "constructor",
+ "end": Object {
+ "column": 3,
+ "line": 14,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 14,
+ "line": 12,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Color": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 8,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ts-enum-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 16,
+ "line": 41,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 9,
+ "line": 41,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "let",
+ },
+ "TheSpace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ts-namespace-decl",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Error": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 17,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 17,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "any": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 14,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 11,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 28,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 25,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 25,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 28,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 28,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a typescript-jsx file: getScopes finds scope bindings in a typescript-jsx file at line 17 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "method",
+ "end": Object {
+ "column": 3,
+ "line": 18,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 16,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Color": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 8,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ts-enum-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 16,
+ "line": 41,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 9,
+ "line": 41,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "let",
+ },
+ "TheSpace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ts-namespace-decl",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Error": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 17,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 17,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "any": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 14,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 11,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 28,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 25,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 25,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 28,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 28,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a typescript-jsx file: getScopes finds scope bindings in a typescript-jsx file at line 33 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn",
+ "end": Object {
+ "column": 3,
+ "line": 34,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 32,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 3,
+ "line": 34,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 32,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 32,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 32,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "TypeScript Namespace",
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 19,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Color": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 8,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ts-enum-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "Example": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 19,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 10,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ Object {
+ "end": Object {
+ "column": 16,
+ "line": 41,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 9,
+ "line": 41,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "let",
+ },
+ "TheSpace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 35,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 31,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ts-namespace-decl",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Error": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 17,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 14,
+ "line": 17,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "any": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 14,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 11,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 28,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 7,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 22,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "window": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 25,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 25,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 28,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 1,
+ "line": 28,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 42,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/tsx-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in a vue file: getScopes finds scope bindings in a vue file at line 14 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "fnVar": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 18,
+ "line": 13,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 13,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "data",
+ "end": Object {
+ "column": 3,
+ "line": 18,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 12,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "moduleVar": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 23,
+ "line": 8,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 8,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 8,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 8,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 1,
+ "line": 27,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 1,
+ "line": 27,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 1,
+ "line": 27,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/vue-sample/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in fn body with both lex and non-lex items: getScopes finds scope bindings in fn body with both lex and non-lex items at line 4 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "lex": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 10,
+ "line": 3,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 3,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Function Body",
+ "end": Object {
+ "column": 1,
+ "line": 5,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 14,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "nonlex": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 2,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 2,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 2,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn",
+ "end": Object {
+ "column": 1,
+ "line": 5,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 24,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 5,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn3": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn4": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 23,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 24,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in fn body with both lex and non-lex items: getScopes finds scope bindings in fn body with both lex and non-lex items at line 10 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "lex": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 10,
+ "line": 9,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 9,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 9,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 9,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Function Body",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "nonlex": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 21,
+ "line": 8,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 17,
+ "line": 8,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 8,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn2",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 24,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 5,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn3": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn4": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 23,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 24,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in fn body with both lex and non-lex items: getScopes finds scope bindings in fn body with both lex and non-lex items at line 16 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Thing": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 16,
+ "line": 15,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 15,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 15,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 15,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Function Body",
+ "end": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "nonlex": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 13,
+ "line": 14,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 14,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 14,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 14,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn3",
+ "end": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 24,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 5,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn3": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn4": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 23,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 24,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings in fn body with both lex and non-lex items: getScopes finds scope bindings in fn body with both lex and non-lex items at line 22 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "Thing": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 16,
+ "line": 21,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 21,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 13,
+ "line": 21,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 8,
+ "line": 21,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Function Body",
+ "end": Object {
+ "column": 1,
+ "line": 23,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 15,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "nonlex": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 21,
+ "line": 20,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 20,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 17,
+ "line": 20,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 20,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "fn4",
+ "end": Object {
+ "column": 1,
+ "line": 23,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 24,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 5,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn2": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn3": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 13,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "fn4": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 23,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 19,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 24,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/fn-body-lex-and-nonlex/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings with expression metadata: getScopes finds scope bindings with expression metadata at line 2 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "foo": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 15,
+ "line": 1,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 1,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "const",
+ },
+ Object {
+ "end": Object {
+ "column": 3,
+ "line": 3,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 7,
+ "line": 3,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 13,
+ "line": 3,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": null,
+ "property": "baz",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "call",
+ },
+ "property": "bar",
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 7,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 11,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 14,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 18,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": null,
+ "property": "baz",
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "call",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "inherit",
+ },
+ "property": "bar",
+ "start": Object {
+ "column": 4,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 4,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 10,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 14,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 15,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 17,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 21,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": null,
+ "property": "baz",
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "call",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "inherit",
+ },
+ "property": "bar",
+ "start": Object {
+ "column": 7,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 7,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "ref",
+ },
+ Object {
+ "end": Object {
+ "column": 25,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 29,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 30,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 32,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": Object {
+ "end": Object {
+ "column": 36,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": null,
+ "property": "baz",
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "call",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "inherit",
+ },
+ "property": "bar",
+ "start": Object {
+ "column": 22,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 22,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "Object": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "__webpack_require__": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 19,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "meta": Object {
+ "end": Object {
+ "column": 21,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "parent": null,
+ "property": "i",
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "member",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "global",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/expressions/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings with proper types: getScopes finds scope bindings with proper types at line 5 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "aConst": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 18,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ "aLet": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "aVar": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "cls": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "def": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 19,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 16,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "named": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 25,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "named",
+ "start": Object {
+ "column": 9,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "namespace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 30,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 21,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-ns-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "otherNamed": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 39,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "thing",
+ "start": Object {
+ "column": 18,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings with proper types: getScopes finds scope bindings with proper types at line 9 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "method",
+ "end": Object {
+ "column": 3,
+ "line": 10,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "cls": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "class-inner",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Class",
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "aConst": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 18,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ "aLet": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "aVar": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "cls": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "def": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 19,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 16,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "named": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 25,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "named",
+ "start": Object {
+ "column": 9,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "namespace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 30,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 21,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-ns-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "otherNamed": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 39,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "thing",
+ "start": Object {
+ "column": 18,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings with proper types: getScopes finds scope bindings with proper types at line 18 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "arguments": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 11,
+ "line": 19,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 2,
+ "line": 19,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ "this": Object {
+ "refs": Array [
+ Object {
+ "end": Object {
+ "column": 6,
+ "line": 18,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "meta": null,
+ "start": Object {
+ "column": 2,
+ "line": 18,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "ref",
+ },
+ ],
+ "type": "implicit",
+ },
+ },
+ "displayName": "inner",
+ "end": Object {
+ "column": 1,
+ "line": 20,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "function",
+ },
+ Object {
+ "bindings": Object {
+ "inner": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 20,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 15,
+ "line": 17,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 10,
+ "line": 17,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "fn-expr",
+ },
+ ],
+ "type": "const",
+ },
+ },
+ "displayName": "Function Expression",
+ "end": Object {
+ "column": 1,
+ "line": 20,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 1,
+ "line": 17,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "aConst": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 18,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ "aLet": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "aVar": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "cls": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "def": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 19,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 16,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "named": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 25,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "named",
+ "start": Object {
+ "column": 9,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "namespace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 30,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 21,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-ns-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "otherNamed": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 39,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "thing",
+ "start": Object {
+ "column": 18,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
+
+exports[`Parser.getScopes finds scope bindings with proper types: getScopes finds scope bindings with proper types at line 23 column 0 1`] = `
+Array [
+ Object {
+ "bindings": Object {
+ "blockFn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 22,
+ "line": 23,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 2,
+ "line": 23,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 18,
+ "line": 23,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 11,
+ "line": 23,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "let",
+ },
+ },
+ "displayName": "Block",
+ "end": Object {
+ "column": 1,
+ "line": 24,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 22,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {
+ "aConst": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 18,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 12,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 15,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "const",
+ },
+ ],
+ "type": "const",
+ },
+ "aLet": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 14,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "let",
+ },
+ ],
+ "type": "let",
+ },
+ "aVar": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 9,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 8,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 4,
+ "line": 13,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "var",
+ },
+ ],
+ "type": "var",
+ },
+ "cls": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 1,
+ "line": 11,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 9,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "class-decl",
+ },
+ ],
+ "type": "let",
+ },
+ "def": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 19,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "default",
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "fn": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 16,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 11,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 9,
+ "line": 6,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "fn-decl",
+ },
+ ],
+ "type": "var",
+ },
+ "named": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 25,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "named",
+ "start": Object {
+ "column": 9,
+ "line": 2,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "namespace": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 30,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 21,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 12,
+ "line": 4,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-ns-decl",
+ },
+ ],
+ "type": "const",
+ },
+ "otherNamed": Object {
+ "refs": Array [
+ Object {
+ "declaration": Object {
+ "end": Object {
+ "column": 39,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ },
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "importName": "thing",
+ "start": Object {
+ "column": 18,
+ "line": 3,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "import-decl",
+ },
+ ],
+ "type": "import",
+ },
+ "this": Object {
+ "refs": Array [],
+ "type": "implicit",
+ },
+ },
+ "displayName": "Module",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Lexical Global",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "block",
+ },
+ Object {
+ "bindings": Object {},
+ "displayName": "Global",
+ "end": Object {
+ "column": 0,
+ "line": 25,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "scopeKind": "",
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ "sourceId": "scopes/binding-types/originalSource-1",
+ },
+ "type": "object",
+ },
+]
+`;
diff --git a/devtools/client/debugger/src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap b/devtools/client/debugger/src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap
new file mode 100644
index 0000000000..aa1a79686b
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap
@@ -0,0 +1,1522 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Parser.getSymbols allSymbols 1`] = `
+"functions:
+[(4, 0), (6, 1)] incrementCounter(counter)
+[(8, 12), (8, 27)] sum(a, b)
+[(12, 2), (14, 3)] doThing()
+[(15, 16), (17, 3)] doOtherThing()
+[(20, 15), (20, 23)] property()
+[(24, 2), (26, 3)] constructor() Ultra
+[(28, 2), (30, 3)] beAwesome(person) Ultra
+
+callExpressions:
+[(13, 12), (13, 15)] log hey
+[(29, 12), (29, 15)] log
+[(33, 19), (33, 23)] push
+
+memberExpressions:
+[(13, 12), (13, 15)] console.log log
+[(20, 4), (20, 12)] Obj.property property
+[(21, 4), (21, 17)] Obj.otherProperty otherProperty
+[(25, 9), (25, 16)] this.awesome awesome
+[(29, 12), (29, 15)] console.log log
+[(33, 19), (33, 23)] this.props.history.push push
+[(33, 11), (33, 18)] this.props.history history
+[(33, 5), (33, 10)] this.props props
+[(33, 48), (33, 50)] this.props.dac.id id
+[(33, 44), (33, 47)] this.props.dac dac
+[(33, 38), (33, 43)] this.props props
+
+objectProperties:
+[(11, 2), (11, 5)] Obj.foo foo
+[(15, 2), (15, 14)] Obj.doOtherThing doOtherThing
+
+comments:
+
+
+identifiers:
+[(1, 6), (1, 10)] TIME TIME
+[(2, 4), (2, 9)] count count
+[(4, 9), (4, 25)] incrementCounter incrementCounter
+[(4, 26), (4, 33)] counter counter
+[(5, 9), (5, 16)] counter counter
+[(8, 6), (8, 9)] sum sum
+[(8, 13), (8, 14)] a a
+[(8, 16), (8, 17)] b b
+[(8, 22), (8, 23)] a a
+[(8, 26), (8, 27)] b b
+[(10, 6), (10, 9)] Obj Obj
+[(11, 2), (11, 5)] 1 foo
+[(12, 2), (12, 9)] doThing doThing
+[(13, 4), (13, 11)] console console
+[(13, 12), (13, 15)] log log
+[(15, 2), (15, 14)] doOtherThing
+[(20, 0), (20, 3)] Obj Obj
+[(20, 4), (20, 12)] property property
+[(21, 0), (21, 3)] Obj Obj
+[(21, 4), (21, 17)] otherProperty otherProperty
+[(23, 6), (23, 11)] Ultra Ultra
+[(25, 4), (25, 8)] this this
+[(25, 9), (25, 16)] awesome awesome
+[(28, 12), (28, 18)] person person
+[(29, 4), (29, 11)] console console
+[(29, 12), (29, 15)] log log
+[(29, 19), (29, 25)] person person
+[(33, 0), (33, 4)] this this
+[(33, 5), (33, 10)] props props
+[(33, 11), (33, 18)] history history
+[(33, 19), (33, 23)] push push
+[(33, 33), (33, 37)] this this
+[(33, 38), (33, 43)] props props
+[(33, 44), (33, 47)] dac dac
+[(33, 48), (33, 50)] id id
+
+classes:
+[(23, 0), (31, 1)] Ultra
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols call expression 1`] = `
+"functions:
+[(2, 0), (2, 70)] evaluate(script, , )
+
+callExpressions:
+[(1, 0), (1, 8)] dispatch
+[(4, 0), (4, 1)] a
+[(4, 2), (4, 3)] b
+[(4, 4), (4, 5)] c
+[(6, 6), (6, 7)] c
+[(6, 2), (6, 3)] b
+[(7, 6), (7, 7)] d
+
+memberExpressions:
+[(6, 6), (6, 7)] c
+[(6, 2), (6, 3)] a.b b
+[(7, 6), (7, 7)] a.b.c.d d
+[(7, 4), (7, 5)] a.b.c c
+[(7, 2), (7, 3)] a.b b
+
+objectProperties:
+[(1, 11), (1, 12)] d
+[(2, 28), (2, 35)] frameId
+[(2, 41), (2, 48)] frameId
+[(2, 55), (2, 56)] c
+[(2, 61), (2, 62)] c
+
+comments:
+
+
+identifiers:
+[(1, 0), (1, 8)] dispatch dispatch
+[(1, 11), (1, 12)] d d
+[(2, 9), (2, 17)] evaluate evaluate
+[(2, 18), (2, 24)] script script
+[(2, 28), (2, 35)] frameId frameId
+[(2, 41), (2, 48)] 3 frameId
+[(2, 55), (2, 56)] c c
+[(2, 61), (2, 62)] 2 c
+[(4, 0), (4, 1)] a a
+[(4, 2), (4, 3)] b b
+[(4, 4), (4, 5)] c c
+[(6, 0), (6, 1)] a a
+[(6, 2), (6, 3)] b b
+[(6, 6), (6, 7)] c c
+[(7, 0), (7, 1)] a a
+[(7, 2), (7, 3)] b b
+[(7, 4), (7, 5)] c c
+[(7, 6), (7, 7)] d d
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols call sites 1`] = `
+"functions:
+
+
+callExpressions:
+[(1, 0), (1, 3)] aaa
+[(1, 4), (1, 7)] bbb
+[(1, 11), (1, 14)] ccc
+[(4, 3), (4, 7)] ffff
+[(3, 3), (3, 6)] eee
+[(2, 0), (2, 4)] dddd
+
+memberExpressions:
+[(4, 3), (4, 7)] ffff
+[(3, 3), (3, 6)] eee
+
+objectProperties:
+
+
+comments:
+
+
+identifiers:
+[(1, 0), (1, 3)] aaa aaa
+[(1, 4), (1, 7)] bbb bbb
+[(1, 11), (1, 14)] ccc ccc
+[(2, 0), (2, 4)] dddd dddd
+[(3, 3), (3, 6)] eee eee
+[(4, 3), (4, 7)] ffff ffff
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols class 1`] = `
+"functions:
+[(5, 2), (7, 3)] hello() Test
+[(12, 2), (15, 3)] constructor() Test
+[(17, 2), (19, 3)] bar(a) Test
+[(21, 8), (23, 3)] baz(b) Test
+
+callExpressions:
+[(18, 12), (18, 15)] log bar
+
+memberExpressions:
+[(6, 27), (6, 35)] this.myStatic myStatic
+[(9, 19), (9, 27)] this.myStatic myStatic
+[(13, 9), (13, 23)] this.publicProperty publicProperty
+[(14, 9), (14, 25)] this.#privateProperty #privateProperty
+[(18, 12), (18, 15)] console.log log
+
+objectProperties:
+
+
+comments:
+
+
+identifiers:
+[(1, 6), (1, 10)] Test Test
+[(2, 2), (2, 16)] publicProperty
+[(3, 3), (3, 18)] privateProperty privateProperty
+[(3, 21), (3, 30)] \\"default\\" default
+[(4, 9), (4, 17)] \\"static\\" myStatic
+[(4, 20), (4, 28)] \\"static\\" static
+[(6, 22), (6, 26)] this this
+[(6, 27), (6, 35)] myStatic myStatic
+[(9, 10), (9, 11)] x x
+[(9, 14), (9, 18)] this this
+[(9, 19), (9, 27)] myStatic myStatic
+[(13, 4), (13, 8)] this this
+[(13, 9), (13, 23)] publicProperty publicProperty
+[(14, 4), (14, 8)] this this
+[(14, 10), (14, 25)] privateProperty privateProperty
+[(17, 6), (17, 7)] a a
+[(18, 4), (18, 11)] console console
+[(18, 12), (18, 15)] log log
+[(18, 23), (18, 24)] a a
+[(21, 2), (21, 5)] b => {
+ return b * 2;
+} baz
+[(21, 8), (21, 9)] b b
+[(22, 11), (22, 12)] b b
+[(26, 6), (26, 11)] Test2 Test2
+[(28, 4), (28, 19)] expressiveClass expressiveClass
+
+classes:
+[(1, 0), (24, 1)] Test
+[(26, 0), (26, 14)] Test2
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols component 1`] = `
+"functions:
+[(6, 2), (9, 3)] constructor(props) Punny
+[(11, 2), (11, 24)] componentDidMount() Punny
+[(13, 2), (13, 14)] onClick() Punny
+[(15, 2), (17, 3)] renderMe() Punny
+[(19, 2), (19, 13)] render() Punny
+[(29, 10), (31, 3)] render() TodoView 1
+[(37, 10), (39, 3)] render() TodoClass 2
+[(45, 10), (47, 3)] render() createClass 3
+[(53, 10), (55, 3)] render() TodoClass 4
+[(62, 0), (66, 1)] Button()
+[(70, 8), (70, 21)] x()
+[(72, 33), (79, 1)] createElement(color)
+[(82, 26), (84, 1)] update(newColor)
+
+callExpressions:
+[(7, 4), (7, 9)]
+[(8, 32), (8, 36)] bind
+[(26, 31), (26, 37)] extend
+[(30, 12), (30, 15)] log yo
+[(34, 18), (34, 29)] createClass
+[(38, 12), (38, 15)] log yo
+[(42, 12), (42, 23)] createClass
+[(46, 12), (46, 15)] log yo
+[(50, 16), (50, 27)] createClass
+[(54, 12), (54, 15)] log yo
+[(65, 16), (65, 20)] call
+[(68, 26), (68, 32)] create
+
+memberExpressions:
+[(8, 9), (8, 16)] this.onClick onClick
+[(8, 32), (8, 36)] this.onClick.bind bind
+[(8, 24), (8, 31)] this.onClick onClick
+[(16, 30), (16, 37)] this.onClick onClick
+[(26, 31), (26, 37)] Backbone.View.extend extend
+[(26, 26), (26, 30)] Backbone.View View
+[(30, 12), (30, 15)] console.log log
+[(38, 12), (38, 15)] console.log log
+[(46, 12), (46, 15)] console.log log
+[(50, 4), (50, 13)] app.TodoClass TodoClass
+[(54, 12), (54, 15)] console.log log
+[(64, 7), (64, 12)] this.color color
+[(65, 16), (65, 20)] Nanocomponent.call call
+[(68, 7), (68, 16)] Button.prototype prototype
+[(68, 26), (68, 32)] Object.create create
+[(68, 47), (68, 56)] Nanocomponent.prototype prototype
+[(72, 17), (72, 30)] Button.prototype.createElement createElement
+[(72, 7), (72, 16)] Button.prototype prototype
+[(73, 7), (73, 12)] this.color color
+[(82, 17), (82, 23)] Button.prototype.update update
+[(82, 7), (82, 16)] Button.prototype prototype
+[(83, 27), (83, 32)] this.color color
+
+objectProperties:
+[(27, 2), (27, 9)] tagName
+[(29, 2), (29, 8)] render
+[(35, 2), (35, 9)] tagName
+[(37, 2), (37, 8)] render
+[(43, 2), (43, 9)] tagName
+[(45, 2), (45, 8)] render
+[(51, 2), (51, 9)] tagName
+[(53, 2), (53, 8)] render
+
+comments:
+[(1, 0), (3, 3)]
+[(22, 0), (24, 3)]
+[(58, 0), (60, 3)]
+[(81, 0), (81, 34)]
+
+identifiers:
+[(5, 6), (5, 11)] Punny Punny
+[(6, 14), (6, 19)] props props
+[(8, 4), (8, 8)] this this
+[(8, 9), (8, 16)] onClick onClick
+[(8, 19), (8, 23)] this this
+[(8, 24), (8, 31)] onClick onClick
+[(8, 32), (8, 36)] bind bind
+[(8, 37), (8, 41)] this this
+[(16, 25), (16, 29)] this this
+[(16, 30), (16, 37)] onClick onClick
+[(5, 20), (5, 29)] Component Component
+[(26, 6), (26, 14)] TodoView TodoView
+[(26, 17), (26, 25)] Backbone Backbone
+[(26, 26), (26, 30)] View View
+[(26, 31), (26, 37)] extend extend
+[(27, 2), (27, 9)] \\"li\\" tagName
+[(27, 11), (27, 15)] \\"li\\" li
+[(29, 2), (29, 8)] render
+[(30, 4), (30, 11)] console console
+[(30, 12), (30, 15)] log log
+[(34, 6), (34, 15)] TodoClass TodoClass
+[(34, 18), (34, 29)] createClass createClass
+[(35, 2), (35, 9)] \\"li\\" tagName
+[(35, 11), (35, 15)] \\"li\\" li
+[(37, 2), (37, 8)] render
+[(38, 4), (38, 11)] console console
+[(38, 12), (38, 15)] log log
+[(42, 0), (42, 9)] TodoClass TodoClass
+[(42, 12), (42, 23)] createClass createClass
+[(43, 2), (43, 9)] \\"li\\" tagName
+[(43, 11), (43, 15)] \\"li\\" li
+[(45, 2), (45, 8)] render
+[(46, 4), (46, 11)] console console
+[(46, 12), (46, 15)] log log
+[(50, 0), (50, 3)] app app
+[(50, 4), (50, 13)] TodoClass TodoClass
+[(50, 16), (50, 27)] createClass createClass
+[(51, 2), (51, 9)] \\"li\\" tagName
+[(51, 11), (51, 15)] \\"li\\" li
+[(53, 2), (53, 8)] render
+[(54, 4), (54, 11)] console console
+[(54, 12), (54, 15)] log log
+[(62, 9), (62, 15)] Button Button
+[(63, 8), (63, 12)] this this
+[(63, 24), (63, 30)] Button Button
+[(63, 44), (63, 50)] Button Button
+[(64, 2), (64, 6)] this this
+[(64, 7), (64, 12)] color color
+[(65, 2), (65, 15)] Nanocomponent Nanocomponent
+[(65, 16), (65, 20)] call call
+[(65, 21), (65, 25)] this this
+[(68, 0), (68, 6)] Button Button
+[(68, 7), (68, 16)] prototype prototype
+[(68, 19), (68, 25)] Object Object
+[(68, 26), (68, 32)] create create
+[(68, 33), (68, 46)] Nanocomponent Nanocomponent
+[(68, 47), (68, 56)] prototype prototype
+[(70, 4), (70, 5)] x x
+[(72, 0), (72, 6)] Button Button
+[(72, 7), (72, 16)] prototype prototype
+[(72, 17), (72, 30)] createElement createElement
+[(72, 42), (72, 47)] color color
+[(73, 2), (73, 6)] this this
+[(73, 7), (73, 12)] color color
+[(73, 15), (73, 20)] color color
+[(74, 9), (74, 13)] html html
+[(75, 39), (75, 44)] color color
+[(82, 0), (82, 6)] Button Button
+[(82, 7), (82, 16)] prototype prototype
+[(82, 17), (82, 23)] update update
+[(82, 35), (82, 43)] newColor newColor
+[(83, 9), (83, 17)] newColor newColor
+[(83, 22), (83, 26)] this this
+[(83, 27), (83, 32)] color color
+
+classes:
+[(5, 0), (20, 1)] Punny
+
+imports:
+
+
+literals:
+
+
+hasJsx: true
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols destruct 1`] = `
+"functions:
+
+
+callExpressions:
+[(1, 21), (1, 28)] compute
+[(4, 21), (4, 28)] compute
+[(7, 35), (7, 42)] entries
+[(8, 10), (8, 13)] log
+
+memberExpressions:
+[(7, 35), (7, 42)] arr.entries entries
+[(8, 10), (8, 13)] console.log log
+[(16, 34), (16, 46)] prefsBlueprint[accessorName] accessorName
+
+objectProperties:
+[(1, 8), (1, 9)] b b
+[(1, 11), (1, 16)] resty resty
+[(2, 8), (2, 13)] first first
+[(2, 18), (2, 22)] last last
+[(11, 8), (11, 9)] a a
+[(11, 20), (11, 21)] b b
+[(11, 36), (11, 37)] a a
+[(12, 8), (12, 12)] temp temp
+[(12, 17), (12, 20)] foo
+[(14, 7), (14, 10)] [key] key
+[(14, 23), (14, 24)] z z
+
+comments:
+
+
+identifiers:
+[(1, 8), (1, 9)] b b
+[(1, 11), (1, 16)] resty resty
+[(1, 21), (1, 28)] compute compute
+[(1, 29), (1, 34)] stuff stuff
+[(2, 15), (2, 16)] f f
+[(2, 24), (2, 25)] l l
+[(2, 8), (2, 13)] f first
+[(2, 18), (2, 22)] l last
+[(2, 30), (2, 33)] obj obj
+[(4, 7), (4, 8)] a a
+[(4, 13), (4, 17)] rest rest
+[(4, 21), (4, 28)] compute compute
+[(4, 29), (4, 34)] stuff stuff
+[(5, 7), (5, 8)] x x
+[(7, 12), (7, 17)] index index
+[(7, 19), (7, 26)] element element
+[(7, 31), (7, 34)] arr arr
+[(7, 35), (7, 42)] entries entries
+[(8, 2), (8, 9)] console console
+[(8, 10), (8, 13)] log log
+[(8, 14), (8, 19)] index index
+[(8, 21), (8, 28)] element element
+[(11, 8), (11, 9)] a a
+[(11, 11), (11, 13)] aa aa
+[(11, 20), (11, 21)] b b
+[(11, 23), (11, 25)] bb bb
+[(11, 36), (11, 37)] 3 a
+[(12, 22), (12, 27)] foooo foooo
+[(12, 8), (12, 12)] [{
+ foo: foooo
+}] temp
+[(12, 17), (12, 20)] foooo foo
+[(12, 35), (12, 38)] obj obj
+[(14, 13), (14, 16)] foo foo
+[(14, 7), (14, 10)] foo key
+[(14, 23), (14, 24)] \\"bar\\" z
+[(14, 26), (14, 31)] \\"bar\\" bar
+[(16, 7), (16, 15)] prefName prefName
+[(16, 19), (16, 33)] prefsBlueprint prefsBlueprint
+[(16, 34), (16, 46)] accessorName accessorName
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols es6 1`] = `
+"functions:
+
+
+callExpressions:
+[(1, 0), (1, 8)] dispatch
+
+memberExpressions:
+
+
+objectProperties:
+[(1, 23), (1, 30)] PROMISE
+
+comments:
+
+
+identifiers:
+[(1, 0), (1, 8)] dispatch dispatch
+[(1, 14), (1, 20)] action action
+[(1, 23), (1, 30)] promise PROMISE
+[(1, 33), (1, 40)] promise promise
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols expression 1`] = `
+"functions:
+[(10, 10), (10, 23)] render() TodoView
+[(23, 0), (23, 28)] params()
+[(24, 11), (24, 32)] pars()
+
+callExpressions:
+[(9, 24), (9, 30)] extend
+[(25, 18), (25, 24)] doEvil
+
+memberExpressions:
+[(2, 19), (2, 33)] obj2.c.secondProperty secondProperty
+[(2, 17), (2, 18)] obj2.c c
+[(6, 40), (6, 46)] collection.books[1].author author
+[(6, 37), (6, 38)] collection.books[1]
+[(6, 31), (6, 36)] collection.books books
+[(7, 66), (7, 74)] collection.genres[\\"sci-fi\\"].movies[0].director director
+[(7, 63), (7, 64)] collection.genres[\\"sci-fi\\"].movies[0]
+[(7, 56), (7, 62)] collection.genres[\\"sci-fi\\"].movies movies
+[(7, 46), (7, 54)] collection.genres[\\"sci-fi\\"]
+[(7, 39), (7, 45)] collection.genres genres
+[(9, 4), (9, 12)] app.TodoView TodoView
+[(9, 24), (9, 30)] Backbone.extend extend
+[(14, 4), (14, 7)] obj.foo foo
+[(21, 40), (21, 41)] a.b.c.v.d d
+[(21, 38), (21, 39)] a.b.c.v v
+[(21, 36), (21, 37)] a.b.c c
+[(21, 34), (21, 35)] a.b b
+[(25, 29), (25, 43)] secondProperty
+[(25, 27), (25, 28)] c
+[(25, 18), (25, 24)] obj2.doEvil doEvil
+
+objectProperties:
+[(1, 14), (1, 15)] obj.a a
+[(1, 19), (1, 20)] obj.a.b b
+[(5, 15), (5, 16)] com[a] a
+[(5, 21), (5, 22)] com[a].b b
+[(5, 30), (5, 31)] com[a][d] d
+[(5, 42), (5, 43)] com[b] b
+[(10, 2), (10, 8)] render
+[(14, 12), (14, 13)] obj.foo.a a
+[(14, 17), (14, 18)] obj.foo.a.b b
+[(14, 27), (14, 28)] obj.foo.b b
+[(15, 8), (15, 9)] com.a a
+[(15, 13), (15, 14)] com.a.b b
+[(15, 23), (15, 24)] com.b b
+[(18, 15), (18, 16)] res[0].a a
+[(18, 25), (18, 26)] res[1].b b
+[(19, 15), (19, 16)] res2.a a
+[(19, 21), (19, 22)] res2.a[0].b b
+[(20, 15), (20, 16)] res3.a a
+[(20, 21), (20, 22)] res3.a[0].b b
+[(20, 30), (20, 31)] res3.b b
+[(20, 36), (20, 37)] res3.b[0].c c
+[(21, 17), (21, 18)] res4[0].a a
+[(21, 29), (21, 30)] res4[0].b b
+[(23, 18), (23, 19)] a a
+[(23, 21), (23, 22)] b b
+[(24, 22), (24, 23)] a a
+[(24, 25), (24, 26)] b b
+
+comments:
+[(1, 29), (1, 44)]
+[(2, 35), (2, 68)]
+[(4, 0), (4, 22)]
+[(5, 51), (5, 67)]
+[(13, 0), (13, 14)]
+[(14, 35), (14, 54)]
+[(15, 31), (15, 46)]
+[(17, 0), (17, 9)]
+[(18, 34), (18, 50)]
+[(19, 32), (19, 50)]
+[(20, 47), (20, 65)]
+[(21, 47), (21, 66)]
+[(23, 29), (23, 38)]
+[(25, 45), (25, 70)]
+
+identifiers:
+[(1, 6), (1, 9)] obj obj
+[(1, 14), (1, 15)] ({
+ b: 2
+}) a
+[(1, 19), (1, 20)] 2 b
+[(2, 6), (2, 9)] foo foo
+[(2, 12), (2, 16)] obj2 obj2
+[(2, 17), (2, 18)] c c
+[(2, 19), (2, 33)] secondProperty secondProperty
+[(5, 6), (5, 9)] com com
+[(5, 15), (5, 16)] ({
+ b: \\"c\\",
+ [d]: \\"e\\"
+}) a
+[(5, 21), (5, 22)] \\"c\\" b
+[(5, 24), (5, 27)] \\"c\\" c
+[(5, 30), (5, 31)] \\"e\\" d
+[(5, 34), (5, 37)] \\"e\\" e
+[(5, 42), (5, 43)] 3 b
+[(6, 6), (6, 17)] firstAuthor firstAuthor
+[(6, 20), (6, 30)] collection collection
+[(6, 31), (6, 36)] books books
+[(6, 40), (6, 46)] author author
+[(7, 6), (7, 25)] firstActionDirector firstActionDirector
+[(7, 28), (7, 38)] collection collection
+[(7, 39), (7, 45)] genres genres
+[(7, 56), (7, 62)] movies movies
+[(7, 66), (7, 74)] director director
+[(9, 0), (9, 3)] app app
+[(9, 4), (9, 12)] TodoView TodoView
+[(9, 15), (9, 23)] Backbone Backbone
+[(9, 24), (9, 30)] extend extend
+[(10, 2), (10, 8)] render
+[(14, 0), (14, 3)] obj obj
+[(14, 4), (14, 7)] foo foo
+[(14, 12), (14, 13)] ({
+ b: \\"c\\"
+}) a
+[(14, 17), (14, 18)] \\"c\\" b
+[(14, 20), (14, 23)] \\"c\\" c
+[(14, 27), (14, 28)] 3 b
+[(15, 0), (15, 3)] com com
+[(15, 8), (15, 9)] ({
+ b: \\"c\\"
+}) a
+[(15, 13), (15, 14)] \\"c\\" b
+[(15, 16), (15, 19)] \\"c\\" c
+[(15, 23), (15, 24)] 3 b
+[(18, 6), (18, 9)] res res
+[(18, 15), (18, 16)] 2 a
+[(18, 25), (18, 26)] 3 b
+[(19, 6), (19, 10)] res2 res2
+[(19, 15), (19, 16)] [{
+ b: 2
+}] a
+[(19, 21), (19, 22)] 2 b
+[(20, 6), (20, 10)] res3 res3
+[(20, 15), (20, 16)] [{
+ b: 2
+}] a
+[(20, 21), (20, 22)] 2 b
+[(20, 30), (20, 31)] [{
+ c: 3
+}] b
+[(20, 36), (20, 37)] 3 c
+[(21, 6), (21, 10)] res4 res4
+[(21, 17), (21, 18)] 3 a
+[(21, 29), (21, 30)] a.b.c.v.d b
+[(21, 32), (21, 33)] a a
+[(21, 34), (21, 35)] b b
+[(21, 36), (21, 37)] c c
+[(21, 38), (21, 39)] v v
+[(21, 40), (21, 41)] d d
+[(23, 9), (23, 15)] params params
+[(23, 18), (23, 19)] a a
+[(23, 21), (23, 22)] b b
+[(24, 4), (24, 8)] pars pars
+[(24, 22), (24, 23)] a a
+[(24, 25), (24, 26)] b b
+[(25, 6), (25, 10)] evil evil
+[(25, 13), (25, 17)] obj2 obj2
+[(25, 18), (25, 24)] doEvil doEvil
+[(25, 27), (25, 28)] c c
+[(25, 29), (25, 43)] secondProperty secondProperty
+
+classes:
+
+
+imports:
+
+
+literals:
+[(6, 37), (6, 38)] collection.books[1] 1
+[(7, 46), (7, 54)] collection.genres[\\"sci-fi\\"] sci-fi
+[(7, 63), (7, 64)] collection.genres[\\"sci-fi\\"].movies[0] 0
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols finds symbols in an html file 1`] = `
+"functions:
+[(8, 2), (10, 3)] sayHello(name)
+[(22, 21), (24, 3)] capitalize(name)
+[(36, 3), (39, 3)] iife()
+
+callExpressions:
+[(23, 18), (23, 29)] toUpperCase
+[(23, 39), (23, 48)] substring 1
+[(28, 4), (28, 8)] join
+[(27, 4), (27, 7)] map
+[(26, 4), (26, 7)] map
+[(36, 3), (39, 3)]
+[(37, 20), (37, 28)] sayHello Ryan
+[(38, 11), (38, 14)] log
+
+memberExpressions:
+[(23, 18), (23, 29)] name[0].toUpperCase toUpperCase
+[(23, 15), (23, 16)] name[0]
+[(23, 39), (23, 48)] name.substring substring
+[(28, 4), (28, 8)] join
+[(27, 4), (27, 7)] map
+[(26, 4), (26, 7)] map map
+[(30, 15), (30, 24)] globalObject.greetings greetings
+[(38, 11), (38, 14)] console.log log
+
+objectProperties:
+[(5, 3), (5, 8)] globalObject.first first
+[(6, 3), (6, 7)] globalObject.last last
+
+comments:
+
+
+identifiers:
+[(4, 6), (4, 18)] globalObject globalObject
+[(5, 3), (5, 8)] \\"name\\" first
+[(5, 10), (5, 16)] \\"name\\" name
+[(6, 3), (6, 7)] \\"words\\" last
+[(6, 9), (6, 16)] \\"words\\" words
+[(8, 11), (8, 19)] sayHello sayHello
+[(8, 21), (8, 25)] name name
+[(9, 20), (9, 24)] name name
+[(22, 8), (22, 18)] capitalize capitalize
+[(22, 21), (22, 25)] name name
+[(23, 10), (23, 14)] name name
+[(23, 18), (23, 29)] toUpperCase toUpperCase
+[(23, 34), (23, 38)] name name
+[(23, 39), (23, 48)] substring substring
+[(25, 8), (25, 16)] greetAll greetAll
+[(26, 4), (26, 7)] map map
+[(26, 8), (26, 18)] capitalize capitalize
+[(27, 4), (27, 7)] map map
+[(27, 8), (27, 16)] sayHello sayHello
+[(28, 4), (28, 8)] join join
+[(30, 2), (30, 14)] globalObject globalObject
+[(30, 15), (30, 24)] greetings greetings
+[(30, 27), (30, 35)] greetAll greetAll
+[(36, 12), (36, 16)] iife iife
+[(37, 9), (37, 17)] greeting greeting
+[(37, 20), (37, 28)] sayHello sayHello
+[(38, 3), (38, 10)] console console
+[(38, 11), (38, 14)] log log
+[(38, 15), (38, 23)] greeting greeting
+
+classes:
+
+
+imports:
+
+
+literals:
+[(23, 15), (23, 16)] name[0] 0
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols flow 1`] = `
+"functions:
+[(2, 2), (4, 3)] renderHello(name, action, ) App
+
+callExpressions:
+
+
+memberExpressions:
+
+
+objectProperties:
+[(2, 51), (2, 56)] todos todos
+
+comments:
+
+
+identifiers:
+[(1, 6), (1, 9)] App App
+[(2, 14), (2, 18)] name name
+[(2, 28), (2, 34)] action action
+[(2, 51), (2, 56)] todos todos
+[(3, 20), (3, 24)] name name
+[(1, 18), (1, 27)] Component Component
+
+classes:
+[(1, 0), (5, 1)] App
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: true
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols func 1`] = `
+"functions:
+[(1, 0), (3, 1)] square(n)
+[(5, 7), (7, 1)] exFoo()
+[(9, 0), (11, 1)] slowFoo()
+[(13, 7), (15, 1)] exSlowFoo()
+[(17, 0), (19, 1)] ret()
+[(21, 8), (21, 21)] child()
+[(23, 1), (25, 1)] anonymous()
+[(28, 7), (30, 3)] name()
+[(32, 2), (34, 3)] bar()
+[(37, 15), (38, 1)] root()
+[(40, 0), (42, 1)] test(a1, , )
+[(44, 0), (44, 13)] anonymous() 1
+[(46, 0), (50, 1)] ret2()
+
+callExpressions:
+[(18, 9), (18, 12)] foo
+[(23, 1), (25, 1)]
+[(41, 10), (41, 13)] log pause next here
+[(48, 4), (48, 7)] foo
+
+memberExpressions:
+[(41, 10), (41, 13)] console.log log
+
+objectProperties:
+[(28, 2), (28, 5)] obj.foo foo
+[(40, 29), (40, 31)] a3
+[(40, 33), (40, 35)] a4
+[(40, 37), (40, 39)] a5
+[(40, 43), (40, 45)] a6
+
+comments:
+
+
+identifiers:
+[(1, 9), (1, 15)] square square
+[(1, 16), (1, 17)] n n
+[(2, 9), (2, 10)] n n
+[(2, 13), (2, 14)] n n
+[(5, 16), (5, 21)] exFoo exFoo
+[(9, 15), (9, 22)] slowFoo slowFoo
+[(13, 22), (13, 31)] exSlowFoo exSlowFoo
+[(17, 9), (17, 12)] ret ret
+[(18, 9), (18, 12)] foo foo
+[(21, 0), (21, 5)] child child
+[(27, 6), (27, 9)] obj obj
+[(28, 2), (28, 5)] foo
+[(28, 16), (28, 20)] name name
+[(32, 2), (32, 5)] bar bar
+[(37, 24), (37, 28)] root root
+[(40, 9), (40, 13)] test test
+[(40, 14), (40, 16)] a1 a1
+[(40, 18), (40, 20)] a2 a2
+[(40, 29), (40, 31)] a3 a3
+[(40, 33), (40, 35)] a4 a4
+[(40, 37), (40, 39)] {
+ a6: a7
+} = {} a5
+[(40, 43), (40, 45)] a7 a6
+[(40, 47), (40, 49)] a7 a7
+[(41, 2), (41, 9)] console console
+[(41, 10), (41, 13)] log log
+[(44, 7), (44, 8)] x x
+[(46, 9), (46, 13)] ret2 ret2
+[(48, 4), (48, 7)] foo foo
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols function names 1`] = `
+"functions:
+[(4, 7), (4, 20)] foo()
+[(5, 9), (5, 22)] foo() 1
+[(6, 6), (6, 19)] 42()
+[(8, 2), (8, 10)] foo() 2
+[(9, 2), (9, 12)] foo() 3
+[(10, 2), (10, 9)] 42() 1
+[(13, 6), (13, 19)] foo() 4
+[(14, 10), (14, 23)] foo() 5
+[(16, 10), (16, 22)] foo() 6
+[(17, 11), (17, 23)] foo() 7
+[(18, 11), (18, 23)] foo() 8
+[(20, 7), (20, 19)] foo() 9
+[(21, 8), (21, 20)] foo() 10
+[(22, 13), (22, 25)] foo() 11
+[(24, 0), (24, 35)] fn()
+[(24, 19), (24, 31)] foo() 12
+[(25, 0), (25, 40)] f2()
+[(25, 19), (25, 31)] foo() 13
+[(26, 0), (26, 45)] f3()
+[(26, 24), (26, 36)] foo() 14
+[(29, 8), (29, 21)] foo() Cls 15
+[(30, 10), (30, 23)] foo() Cls 16
+[(31, 7), (31, 20)] 42() Cls 2
+[(33, 2), (33, 10)] foo() Cls 17
+[(34, 2), (34, 12)] foo() Cls 18
+[(35, 2), (35, 9)] 42() Cls 3
+[(38, 1), (38, 13)] anonymous()
+[(40, 15), (40, 28)] default()
+[(44, 0), (44, 27)] a(first, second)
+[(45, 0), (45, 35)] b(first = bla, second)
+[(46, 0), (46, 32)] c(first = {}, second)
+[(47, 0), (47, 32)] d(first = [], second)
+[(48, 0), (48, 40)] e(first = defaultObj, second)
+[(49, 0), (49, 40)] f(first = defaultArr, second)
+[(50, 0), (50, 34)] g(first = null, second)
+
+callExpressions:
+
+
+memberExpressions:
+[(14, 4), (14, 7)] obj.foo foo
+
+objectProperties:
+[(4, 2), (4, 5)] foo
+[(5, 2), (5, 7)]
+[(6, 2), (6, 4)]
+[(18, 5), (18, 8)] foo foo
+[(21, 2), (21, 5)] undefined.foo foo
+[(22, 2), (22, 5)] undefined.bar bar
+[(25, 13), (25, 16)] foo
+[(26, 13), (26, 16)] bar
+[(42, 20), (42, 21)] defaultObj.a a
+
+comments:
+[(1, 0), (1, 20)]
+
+identifiers:
+[(4, 2), (4, 5)] foo
+[(5, 2), (5, 7)] foo
+[(8, 2), (8, 5)] foo foo
+[(13, 0), (13, 3)] foo foo
+[(14, 0), (14, 3)] obj obj
+[(14, 4), (14, 7)] foo foo
+[(16, 4), (16, 7)] foo foo
+[(17, 5), (17, 8)] foo foo
+[(18, 5), (18, 8)] foo foo
+[(20, 1), (20, 4)] foo foo
+[(21, 2), (21, 5)] foo foo
+[(22, 2), (22, 5)] bar bar
+[(22, 7), (22, 10)] foo foo
+[(24, 9), (24, 11)] fn fn
+[(24, 13), (24, 16)] foo foo
+[(25, 9), (25, 11)] f2 f2
+[(25, 13), (25, 16)] foo foo
+[(26, 9), (26, 11)] f3 f3
+[(26, 13), (26, 16)] bar bar
+[(26, 18), (26, 21)] foo foo
+[(28, 6), (28, 9)] Cls Cls
+[(29, 2), (29, 5)] foo
+[(30, 2), (30, 7)] foo
+[(42, 6), (42, 16)] defaultObj defaultObj
+[(42, 20), (42, 21)] 1 a
+[(43, 6), (43, 16)] defaultArr defaultArr
+[(44, 9), (44, 10)] a a
+[(44, 11), (44, 16)] first first
+[(44, 18), (44, 24)] second second
+[(45, 9), (45, 10)] b b
+[(45, 11), (45, 16)] first first
+[(45, 26), (45, 32)] second second
+[(46, 9), (46, 10)] c c
+[(46, 11), (46, 16)] first first
+[(46, 23), (46, 29)] second second
+[(47, 9), (47, 10)] d d
+[(47, 11), (47, 16)] first first
+[(47, 23), (47, 29)] second second
+[(48, 9), (48, 10)] e e
+[(48, 11), (48, 16)] first first
+[(48, 19), (48, 29)] defaultObj defaultObj
+[(48, 31), (48, 37)] second second
+[(49, 9), (49, 10)] f f
+[(49, 11), (49, 16)] first first
+[(49, 19), (49, 29)] defaultArr defaultArr
+[(49, 31), (49, 37)] second second
+[(50, 9), (50, 10)] g g
+[(50, 11), (50, 16)] first first
+[(50, 25), (50, 31)] second second
+
+classes:
+[(28, 0), (36, 1)] Cls
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols jsx 1`] = `
+"functions:
+
+
+callExpressions:
+[(3, 17), (3, 20)] foo
+[(4, 9), (4, 12)] foo
+
+memberExpressions:
+
+
+objectProperties:
+
+
+comments:
+
+
+identifiers:
+[(1, 6), (1, 16)] jsxElement jsxElement
+[(3, 17), (3, 20)] foo foo
+[(4, 9), (4, 12)] foo foo
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: true
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols math 1`] = `
+"functions:
+[(1, 0), (12, 1)] math(n)
+[(2, 2), (5, 3)] square(n)
+[(14, 12), (14, 25)] child()
+[(15, 9), (15, 22)] child2()
+
+callExpressions:
+[(8, 14), (8, 20)] square 2
+[(10, 15), (10, 22)] squaare 4
+
+memberExpressions:
+
+
+objectProperties:
+
+
+comments:
+[(3, 4), (3, 21)]
+[(7, 2), (7, 24)]
+
+identifiers:
+[(1, 9), (1, 13)] math math
+[(1, 14), (1, 15)] n n
+[(2, 11), (2, 17)] square square
+[(2, 18), (2, 19)] n n
+[(4, 4), (4, 5)] n n
+[(4, 8), (4, 9)] n n
+[(8, 8), (8, 11)] two two
+[(8, 14), (8, 20)] square square
+[(10, 8), (10, 12)] four four
+[(10, 15), (10, 22)] squaare squaare
+[(11, 9), (11, 12)] two two
+[(11, 15), (11, 19)] four four
+[(14, 4), (14, 9)] child child
+[(15, 0), (15, 6)] child2 child2
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols object expressions 1`] = `
+"functions:
+
+
+callExpressions:
+[(3, 62), (3, 70)] getValue 2
+
+memberExpressions:
+
+
+objectProperties:
+[(1, 13), (1, 19)] y.params params
+[(2, 15), (2, 16)] foo.b b
+[(3, 14), (3, 15)] bar.x x
+[(3, 20), (3, 21)] bar.y y
+[(3, 30), (3, 31)] bar.z z
+[(3, 39), (3, 40)] bar.a a
+[(3, 48), (3, 49)] bar.s s
+[(3, 58), (3, 59)] bar.d d
+[(4, 27), (4, 37)] frameActor
+[(6, 20), (6, 26)] collection.genres genres
+[(6, 29), (6, 37)] collection.genres
+[(6, 40), (6, 46)] collection.genres.undefined.movies movies
+[(6, 50), (6, 58)] collection.genres.undefined.movies[0].director director
+
+comments:
+
+
+identifiers:
+[(1, 6), (1, 7)] y y
+[(1, 13), (1, 19)] params params
+[(2, 6), (2, 9)] foo foo
+[(2, 15), (2, 16)] b b
+[(3, 6), (3, 9)] bar bar
+[(3, 14), (3, 15)] 3 x
+[(3, 20), (3, 21)] \\"434\\" y
+[(3, 23), (3, 28)] \\"434\\" 434
+[(3, 30), (3, 31)] true z
+[(3, 39), (3, 40)] null a
+[(3, 48), (3, 49)] c * 2 s
+[(3, 51), (3, 52)] c c
+[(3, 58), (3, 59)] d
+[(3, 62), (3, 70)] getValue getValue
+[(4, 6), (4, 12)] params params
+[(4, 15), (4, 22)] frameId frameId
+[(4, 27), (4, 37)] frameId frameActor
+[(4, 39), (4, 46)] frameId frameId
+[(6, 6), (6, 16)] collection collection
+[(6, 20), (6, 26)] ({
+ \\"sci-fi\\": {
+ movies: [{
+ director: \\"yo\\"
+ }]
+ }
+}) genres
+[(6, 29), (6, 37)] ({
+ movies: [{
+ director: \\"yo\\"
+ }]
+}) sci-fi
+[(6, 40), (6, 46)] [{
+ director: \\"yo\\"
+}] movies
+[(6, 50), (6, 58)] \\"yo\\" director
+[(6, 60), (6, 64)] \\"yo\\" yo
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols optional chaining 1`] = `
+"functions:
+
+
+callExpressions:
+
+
+memberExpressions:
+[(2, 5), (2, 6)] obj?.a a
+[(3, 8), (3, 9)] obj?.a?.b b
+[(3, 5), (3, 6)] obj?.a a
+
+objectProperties:
+
+
+comments:
+
+
+identifiers:
+[(1, 6), (1, 9)] obj obj
+[(2, 0), (2, 3)] obj obj
+[(2, 5), (2, 6)] a a
+[(3, 0), (3, 3)] obj obj
+[(3, 5), (3, 6)] a a
+[(3, 8), (3, 9)] b b
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols private fields 1`] = `
+"functions:
+[(2, 2), (6, 3)] constructor(secret, ) MyClass
+[(13, 2), (15, 3)] #getSalt() MyClass
+[(17, 2), (23, 3)] debug() MyClass
+
+callExpressions:
+[(21, 22), (21, 30)]
+
+memberExpressions:
+[(4, 9), (4, 16)] this.#secret #secret
+[(5, 9), (5, 20)] self.#restParams #restParams
+[(14, 16), (14, 21)] this.#salt #salt
+[(19, 30), (19, 42)] this.creationDate creationDate
+[(20, 24), (20, 31)] this.#secret #secret
+[(21, 22), (21, 30)] self.#getSalt #getSalt
+
+objectProperties:
+
+
+comments:
+
+
+identifiers:
+[(1, 6), (1, 13)] MyClass MyClass
+[(2, 14), (2, 20)] secret secret
+[(2, 25), (2, 29)] rest rest
+[(3, 10), (3, 14)] self self
+[(3, 17), (3, 21)] this this
+[(4, 4), (4, 8)] this this
+[(4, 10), (4, 16)] secret secret
+[(4, 19), (4, 25)] secret secret
+[(5, 4), (5, 8)] self self
+[(5, 10), (5, 20)] restParams restParams
+[(5, 23), (5, 27)] rest rest
+[(8, 3), (8, 9)] secret secret
+[(9, 3), (9, 13)] restParams restParams
+[(10, 3), (10, 7)] salt salt
+[(10, 10), (10, 17)] \\"bloup\\" bloup
+[(11, 2), (11, 14)] new Date() creationDate
+[(11, 21), (11, 25)] Date Date
+[(13, 3), (13, 10)] getSalt getSalt
+[(14, 11), (14, 15)] this this
+[(14, 17), (14, 21)] salt salt
+[(18, 10), (18, 14)] self self
+[(18, 17), (18, 21)] this this
+[(19, 10), (19, 22)] creationDate creationDate
+[(19, 25), (19, 29)] this this
+[(19, 30), (19, 42)] creationDate creationDate
+[(20, 10), (20, 16)] secret secret
+[(20, 19), (20, 23)] this this
+[(20, 25), (20, 31)] secret secret
+[(21, 10), (21, 14)] salt salt
+[(21, 17), (21, 21)] self self
+[(21, 23), (21, 30)] getSalt getSalt
+[(22, 14), (22, 26)] creationDate creationDate
+[(22, 30), (22, 34)] salt salt
+[(22, 38), (22, 44)] secret secret
+
+classes:
+[(1, 0), (24, 1)] MyClass
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols proto 1`] = `
+"functions:
+[(1, 12), (1, 25)] foo()
+[(3, 12), (3, 20)] bar()
+[(7, 14), (7, 27)] initialize() TodoView
+[(8, 2), (10, 3)] doThing(b) TodoView
+[(11, 10), (13, 3)] render() TodoView
+
+callExpressions:
+[(5, 31), (5, 37)] extend
+[(9, 12), (9, 15)] log hi
+
+memberExpressions:
+[(5, 31), (5, 37)] Backbone.View.extend extend
+[(5, 26), (5, 30)] Backbone.View View
+[(9, 12), (9, 15)] console.log log
+
+objectProperties:
+[(6, 2), (6, 9)] tagName
+[(7, 2), (7, 12)] initialize
+[(11, 2), (11, 8)] render
+
+comments:
+
+
+identifiers:
+[(1, 6), (1, 9)] foo foo
+[(3, 6), (3, 9)] bar bar
+[(5, 6), (5, 14)] TodoView TodoView
+[(5, 17), (5, 25)] Backbone Backbone
+[(5, 26), (5, 30)] View View
+[(5, 31), (5, 37)] extend extend
+[(6, 2), (6, 9)] \\"li\\" tagName
+[(6, 11), (6, 15)] \\"li\\" li
+[(7, 2), (7, 12)] initialize
+[(8, 2), (8, 9)] doThing doThing
+[(8, 10), (8, 11)] b b
+[(9, 4), (9, 11)] console console
+[(9, 12), (9, 15)] log log
+[(9, 22), (9, 23)] b b
+[(11, 2), (11, 8)] render
+[(12, 11), (12, 15)] this this
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
+
+exports[`Parser.getSymbols react component 1`] = `
+"functions:
+
+
+callExpressions:
+
+
+memberExpressions:
+
+
+objectProperties:
+
+
+comments:
+
+
+identifiers:
+[(1, 7), (1, 12)] React React
+[(1, 16), (1, 25)] Component Component
+[(3, 6), (3, 18)] PrimaryPanes PrimaryPanes
+[(3, 27), (3, 36)] Component Component
+
+classes:
+[(3, 0), (3, 39)] PrimaryPanes
+
+imports:
+[(1, 0), (1, 41)] React, Component
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: React"
+`;
+
+exports[`Parser.getSymbols var 1`] = `
+"functions:
+
+
+callExpressions:
+
+
+memberExpressions:
+
+
+objectProperties:
+[(8, 6), (8, 9)] foo foo
+[(8, 13), (8, 16)] foo.baw baw
+[(9, 5), (9, 8)] bap bap
+[(10, 5), (10, 7)] ll ll
+[(15, 6), (15, 7)] a a
+[(17, 10), (17, 12)] my
+[(19, 13), (19, 15)] oy
+[(19, 17), (19, 20)] vey
+[(19, 28), (19, 35)] mitzvot
+
+comments:
+
+
+identifiers:
+[(1, 4), (1, 7)] foo foo
+[(2, 4), (2, 7)] bar bar
+[(3, 6), (3, 9)] baz baz
+[(4, 6), (4, 7)] a a
+[(5, 2), (5, 3)] b b
+[(6, 0), (6, 1)] a a
+[(8, 13), (8, 16)] baw baw
+[(8, 6), (8, 9)] {
+ baw
+} foo
+[(9, 5), (9, 8)] bap bap
+[(10, 5), (10, 7)] ll ll
+[(13, 5), (13, 10)] first first
+[(15, 9), (15, 11)] _a _a
+[(15, 6), (15, 7)] _a a
+[(17, 5), (17, 7)] oh oh
+[(17, 14), (17, 17)] god god
+[(17, 10), (17, 12)] god my
+[(19, 6), (19, 8)] oj oj
+[(19, 13), (19, 15)] oy oy
+[(19, 22), (19, 26)] _vey _vey
+[(19, 17), (19, 20)] _vey vey
+[(19, 28), (19, 35)] mitzvot mitzvot
+[(19, 37), (19, 42)] _mitz _mitz
+[(21, 5), (21, 8)] one one
+[(21, 13), (21, 18)] stuff stuff
+
+classes:
+
+
+imports:
+
+
+literals:
+
+
+hasJsx: false
+
+hasTypes: false
+
+framework: null"
+`;
diff --git a/devtools/client/debugger/src/workers/parser/tests/__snapshots__/validate.spec.js.snap b/devtools/client/debugger/src/workers/parser/tests/__snapshots__/validate.spec.js.snap
new file mode 100644
index 0000000000..a341538a5d
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/__snapshots__/validate.spec.js.snap
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`has syntax error should return the error object for the invalid expression 1`] = `"SyntaxError : Missing semicolon. (1:3)"`;
diff --git a/devtools/client/debugger/src/workers/parser/tests/contains.spec.js b/devtools/client/debugger/src/workers/parser/tests/contains.spec.js
new file mode 100644
index 0000000000..741f1a29fc
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/contains.spec.js
@@ -0,0 +1,250 @@
+/* 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 { containsPosition, containsLocation } from "../utils/contains";
+
+function getTestLoc() {
+ return {
+ start: {
+ line: 10,
+ column: 2,
+ },
+ end: {
+ line: 12,
+ column: 10,
+ },
+ };
+}
+
+// AstPosition.column is typed as a number, but many parts of this test set it
+// to undefined. Using zero instead causes test failures, and allowing it to be
+// undefined causes many flow errors in code manipulating AstPosition.
+// Fake a coercion of undefined to number as a workaround for now.
+function undefinedColumn() {
+ return undefined;
+}
+
+function startPos(lineOffset, columnOffset) {
+ const { start } = getTestLoc();
+ return {
+ line: start.line + lineOffset,
+ column: start.column + columnOffset,
+ };
+}
+
+function endPos(lineOffset, columnOffset) {
+ const { end } = getTestLoc();
+ return {
+ line: end.line + lineOffset,
+ column: end.column + columnOffset,
+ };
+}
+
+function startLine(lineOffset = 0) {
+ const { start } = getTestLoc();
+ return {
+ line: start.line + lineOffset,
+ column: undefinedColumn(),
+ };
+}
+
+function endLine(lineOffset = 0) {
+ const { end } = getTestLoc();
+ return {
+ line: end.line + lineOffset,
+ column: undefinedColumn(),
+ };
+}
+
+function testContains(pos, bool) {
+ const loc = getTestLoc();
+ expect(containsPosition(loc, pos)).toEqual(bool);
+}
+
+describe("containsPosition", () => {
+ describe("location and postion both with the column criteria", () => {
+ /* eslint-disable jest/expect-expect */
+ it("should contain position within the location range", () =>
+ testContains(startPos(1, 1), true));
+
+ it("should not contain position out of the start line", () =>
+ testContains(startPos(-1, 0), false));
+
+ it("should not contain position out of the start column", () =>
+ testContains(startPos(0, -1), false));
+
+ it(`should contain position on the same start line and
+ within the start column`, () => testContains(startPos(0, 1), true));
+
+ it("should not contain position out of the end line", () =>
+ testContains(endPos(1, 0), false));
+
+ it("should not contain position out of the end column", () =>
+ testContains(endPos(0, 1), false));
+
+ // eslint-disable-next-line max-len
+ it("should contain position on the same end line and within the end column", () =>
+ testContains(endPos(0, -1), true));
+ /* eslint-enable jest/expect-expect */
+ });
+
+ describe("position without the column criterion", () => {
+ /* eslint-disable jest/expect-expect */
+ it("should contain position on the same start line", () =>
+ testContains(startLine(0), true));
+
+ it("should contain position on the same end line", () =>
+ testContains(endLine(0), true));
+ /* eslint-enable jest/expect-expect */
+ });
+
+ describe("location without the column criterion", () => {
+ it("should contain position on the same start line", () => {
+ const loc = getTestLoc();
+ loc.start.column = undefinedColumn();
+ const pos = {
+ line: loc.start.line,
+ column: 1,
+ };
+ expect(containsPosition(loc, pos)).toEqual(true);
+ });
+
+ it("should contain position on the same end line", () => {
+ const loc = getTestLoc();
+ loc.end.column = undefinedColumn();
+ const pos = {
+ line: loc.end.line,
+ column: 1,
+ };
+ expect(containsPosition(loc, pos)).toEqual(true);
+ });
+ });
+
+ describe("location and postion both without the column criterion", () => {
+ it("should contain position on the same start line", () => {
+ const loc = getTestLoc();
+ loc.start.column = undefinedColumn();
+ const pos = startLine();
+ expect(containsPosition(loc, pos)).toEqual(true);
+ });
+
+ it("should contain position on the same end line", () => {
+ const loc = getTestLoc();
+ loc.end.column = undefinedColumn();
+ const pos = endLine();
+ expect(containsPosition(loc, pos)).toEqual(true);
+ });
+ });
+});
+
+describe("containsLocation", () => {
+ describe("locations both with the column criteria", () => {
+ it("should contian location within the range", () => {
+ const locA = getTestLoc();
+ const locB = {
+ start: startPos(1, 1),
+ end: endPos(-1, -1),
+ };
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+
+ it("should not contian location out of the start line", () => {
+ const locA = getTestLoc();
+ const locB = getTestLoc();
+ locB.start.line--;
+ expect(containsLocation(locA, locB)).toEqual(false);
+ });
+
+ it("should not contian location out of the start column", () => {
+ const locA = getTestLoc();
+ const locB = getTestLoc();
+ locB.start.column--;
+ expect(containsLocation(locA, locB)).toEqual(false);
+ });
+
+ it("should not contian location out of the end line", () => {
+ const locA = getTestLoc();
+ const locB = getTestLoc();
+ locB.end.line++;
+ expect(containsLocation(locA, locB)).toEqual(false);
+ });
+
+ it("should not contian location out of the end column", () => {
+ const locA = getTestLoc();
+ const locB = getTestLoc();
+ locB.end.column++;
+ expect(containsLocation(locA, locB)).toEqual(false);
+ });
+
+ it(`should contain location on the same start line and
+ within the start column`, () => {
+ const locA = getTestLoc();
+ const locB = {
+ start: startPos(0, 1),
+ end: endPos(-1, -1),
+ };
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+
+ it(`should contain location on the same end line and
+ within the end column`, () => {
+ const locA = getTestLoc();
+ const locB = {
+ start: startPos(1, 1),
+ end: endPos(0, -1),
+ };
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+ });
+
+ describe("location A without the column criterion", () => {
+ it("should contain location on the same start line", () => {
+ const locA = getTestLoc();
+ locA.start.column = undefinedColumn();
+ const locB = getTestLoc();
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+
+ it("should contain location on the same end line", () => {
+ const locA = getTestLoc();
+ locA.end.column = undefinedColumn();
+ const locB = getTestLoc();
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+ });
+
+ describe("location B without the column criterion", () => {
+ it("should contain location on the same start line", () => {
+ const locA = getTestLoc();
+ const locB = getTestLoc();
+ locB.start.column = undefinedColumn();
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+
+ it("should contain location on the same end line", () => {
+ const locA = getTestLoc();
+ const locB = getTestLoc();
+ locB.end.column = undefinedColumn();
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+ });
+
+ describe("locations both without the column criteria", () => {
+ it("should contain location on the same start line", () => {
+ const locA = getTestLoc();
+ const locB = getTestLoc();
+ locA.start.column = undefinedColumn();
+ locB.start.column = undefinedColumn();
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+
+ it("should contain location on the same end line", () => {
+ const locA = getTestLoc();
+ const locB = getTestLoc();
+ locA.end.column = undefinedColumn();
+ locB.end.column = undefinedColumn();
+ expect(containsLocation(locA, locB)).toEqual(true);
+ });
+ });
+});
diff --git a/devtools/client/debugger/src/workers/parser/tests/findOutOfScopeLocations.spec.js b/devtools/client/debugger/src/workers/parser/tests/findOutOfScopeLocations.spec.js
new file mode 100644
index 0000000000..797443fbf9
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/findOutOfScopeLocations.spec.js
@@ -0,0 +1,75 @@
+/* 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/>. */
+
+import findOutOfScopeLocations from "../findOutOfScopeLocations";
+
+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 = populateSource("outOfScope");
+ const actual = findOutOfScopeLocations({
+ source,
+ line: 5,
+ column: 5,
+ });
+
+ expect(formatLines(actual)).toMatchSnapshot();
+ });
+
+ it("should roll up function blocks", () => {
+ const source = populateSource("outOfScope");
+ const actual = findOutOfScopeLocations({
+ source,
+ line: 24,
+ column: 0,
+ });
+
+ expect(formatLines(actual)).toMatchSnapshot();
+ });
+
+ it("should exclude function for locations on declaration", () => {
+ const source = populateSource("outOfScope");
+ const actual = findOutOfScopeLocations({
+ source,
+ line: 3,
+ column: 12,
+ });
+
+ expect(formatLines(actual)).toMatchSnapshot();
+ });
+
+ it("should treat comments as out of scope", () => {
+ const source = populateSource("outOfScopeComment");
+ const actual = findOutOfScopeLocations({
+ source,
+ 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 = populateSource("outOfScope");
+ const actual = findOutOfScopeLocations({
+ source,
+ line: 61,
+ column: 0,
+ });
+ expect(formatLines(actual)).toMatchSnapshot();
+ });
+});
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/allSymbols.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/allSymbols.js
new file mode 100644
index 0000000000..bebda9f36a
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/allSymbols.js
@@ -0,0 +1,33 @@
+const TIME = 60;
+let count = 0;
+
+function incrementCounter(counter) {
+ return counter++;
+}
+
+const sum = (a, b) => a + b;
+
+const Obj = {
+ foo: 1,
+ doThing() {
+ console.log("hey");
+ },
+ doOtherThing: function() {
+ return 42;
+ }
+};
+
+Obj.property = () => {};
+Obj.otherProperty = 1;
+
+class Ultra {
+ constructor() {
+ this.awesome = true;
+ }
+
+ beAwesome(person) {
+ console.log(`${person} is Awesome!`);
+ }
+}
+
+this.props.history.push(`/dacs/${this.props.dac.id}`);
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/async.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/async.js
new file mode 100644
index 0000000000..43216be635
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/async.js
@@ -0,0 +1,10 @@
+async function foo() {
+ return new Promise(resolve => {
+ setTimeout(resolve, 10);
+ });
+}
+
+async function stuff() {
+ await foo(1);
+ await foo(2);
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/call-sites.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/call-sites.js
new file mode 100644
index 0000000000..aa73700d93
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/call-sites.js
@@ -0,0 +1,4 @@
+aaa(bbb(), ccc());
+dddd()
+ .eee()
+ .ffff();
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/callExpressions.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/callExpressions.js
new file mode 100644
index 0000000000..2771dede6a
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/callExpressions.js
@@ -0,0 +1,7 @@
+dispatch({ d });
+function evaluate(script, { frameId } = {frameId: 3}, {c} = {c: 2}) {}
+
+a(b(c()));
+
+a.b().c();
+a.b.c.d();
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/calls.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/calls.js
new file mode 100644
index 0000000000..f05d445db7
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/calls.js
@@ -0,0 +1,21 @@
+foo(1, '2', bar())
+
+foo()
+ .bar()
+ .bazz()
+
+console.log('yo')
+
+foo(
+ 1,
+ bar()
+)
+
+var a = 3;
+
+// set a step point at the first call expression in step expressions
+var x = { a: a(), b: b(), c: c() };
+var b = [ foo() ];
+[ a(), b(), c() ];
+(1, a(), b());
+x(1, a(), b());
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/class.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/class.js
new file mode 100644
index 0000000000..59d612ebfe
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/class.js
@@ -0,0 +1,28 @@
+class Test {
+ publicProperty;
+ #privateProperty = "default";
+ static myStatic = "static";
+ static hello() {
+ return "Hello " + this.myStatic
+ }
+ static {
+ const x = this.myStatic;
+ }
+
+ constructor() {
+ this.publicProperty = "foo";
+ this.#privateProperty = "bar";
+ }
+
+ bar(a) {
+ console.log("bar", a);
+ }
+
+ baz = b => {
+ return b * 2;
+ };
+}
+
+class Test2 {}
+
+let expressiveClass = class {};
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/component.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/component.js
new file mode 100644
index 0000000000..38d9b00096
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/component.js
@@ -0,0 +1,84 @@
+/*
+ * class
+ */
+
+class Punny extends Component {
+ constructor(props) {
+ super();
+ this.onClick = this.onClick.bind(this);
+ }
+
+ componentDidMount() {}
+
+ onClick() {}
+
+ renderMe() {
+ return <div onClick={this.onClick} />;
+ }
+
+ render() {}
+}
+
+/*
+ * CALL EXPRESSIONS - createClass, extend
+ */
+
+const TodoView = Backbone.View.extend({
+ tagName: "li",
+
+ render: function() {
+ console.log("yo");
+ }
+});
+
+const TodoClass = createClass({
+ tagName: "li",
+
+ render: function() {
+ console.log("yo");
+ }
+});
+
+TodoClass = createClass({
+ tagName: "li",
+
+ render: function() {
+ console.log("yo");
+ }
+});
+
+app.TodoClass = createClass({
+ tagName: "li",
+
+ render: function() {
+ console.log("yo");
+ }
+});
+
+/*
+ * PROTOTYPE
+ */
+
+function Button() {
+ if (!(this instanceof Button)) return new Button();
+ this.color = null;
+ Nanocomponent.call(this);
+}
+
+Button.prototype = Object.create(Nanocomponent.prototype);
+
+var x = function() {};
+
+Button.prototype.createElement = function(color) {
+ this.color = color;
+ return html`
+ <button style="background-color: ${color}">
+ Click Me
+ </button>
+ `;
+};
+
+// Implement conditional rendering
+Button.prototype.update = function(newColor) {
+ return newColor !== this.color;
+};
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/computed-props.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/computed-props.js
new file mode 100644
index 0000000000..4c0f182f33
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/computed-props.js
@@ -0,0 +1,8 @@
+(function(key) {
+ let obj = {
+ b: 5
+ };
+ obj[key] = 0;
+ const c = obj.b;
+ return obj;
+})("a");
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/control-flow.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/control-flow.js
new file mode 100644
index 0000000000..b9e859ff74
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/control-flow.js
@@ -0,0 +1,39 @@
+
+if (x) {
+ foo();
+}
+else if (y) {
+ foo();
+}
+else {
+ foo();
+}
+
+for (var i=0; i< 5; i++ ) {
+ foo();
+}
+
+while (x) {
+ foo();
+}
+
+switch (c) {
+ case a:
+ console.log('hi')
+}
+
+var a = 3;
+
+for (const val of [1, 2]) {
+ console.log("pause again", val);
+}
+
+for (const val of vals) {
+ console.log("pause again", val);
+}
+
+try {
+} catch (e) {
+}
+
+with (e) {}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/decorators.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/decorators.js
new file mode 100644
index 0000000000..22c0a1398d
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/decorators.js
@@ -0,0 +1,2 @@
+@annotation
+class MyClass { }
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/destructuring.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/destructuring.js
new file mode 100644
index 0000000000..52686e6573
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/destructuring.js
@@ -0,0 +1,16 @@
+const { b, resty } = compute(stuff);
+const { first: f, last: l } = obj;
+
+const [a, ...rest] = compute(stuff);
+const [x] = ["a"];
+
+for (const [index, element] of arr.entries()) {
+ console.log(index, element);
+}
+
+const { a: aa = 10, b: bb = 5 } = { a: 3 };
+const { temp: [{ foo: foooo }] } = obj;
+
+let { [key]: foo } = { z: "bar" };
+
+let [, prefName] = prefsBlueprint[accessorName];
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/es6.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/es6.js
new file mode 100644
index 0000000000..90b53141f4
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/es6.js
@@ -0,0 +1 @@
+dispatch({ ...action, [PROMISE]: promise });
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/expression.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/expression.js
new file mode 100644
index 0000000000..fa80b68add
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/expression.js
@@ -0,0 +1,25 @@
+const obj = { a: { b: 2 } }; // e.g. obj.a.b
+const foo = obj2.c.secondProperty; // e.g. foo.obj2.c.secondProperty
+
+// computed properties
+const com = { [a]: { b: "c", [d]: "e" }, [b]: 3 }; // e.g. com[a].b
+const firstAuthor = collection.books[1].author;
+const firstActionDirector = collection.genres["sci-fi"].movies[0].director;
+
+app.TodoView = Backbone.extend({
+ render: function() {}
+});
+
+// assignments
+obj.foo = { a: { b: "c" }, b: 3 }; // e.g. obj.foo.a.b
+com = { a: { b: "c" }, b: 3 }; // e.g. com.a.b
+
+// arrays
+const res = [{ a: 2 }, { b: 3 }]; // e.g. res[1].b
+const res2 = { a: [{ b: 2 }] }; // e.g. res.a[0].b
+const res3 = { a: [{ b: 2 }], b: [{ c: 3 }] }; // e.g. res.a[0].b
+const res4 = [[{ a: 3 }], [{ b: a.b.c.v.d }]]; // e.g. res[1][0].b
+
+function params({ a, b }) {} // e.g. a
+var pars = function({ a, b }) {};
+const evil = obj2.doEvil().c.secondProperty; // e.g. obj2.doEvil or ""
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/flow.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/flow.js
new file mode 100644
index 0000000000..1135bd62a4
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/flow.js
@@ -0,0 +1,5 @@
+class App extends Component {
+ renderHello(name: string, action: ReduxAction, { todos }: Props) {
+ return `howdy ${name}`;
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/angular1FalsePositive.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/angular1FalsePositive.js
new file mode 100644
index 0000000000..5220f26c8c
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/angular1FalsePositive.js
@@ -0,0 +1,11 @@
+const frameworkStars = {
+ angular: 40779,
+ react: 111576,
+ vue: 114358,
+};
+
+const container = new Container();
+container.module("sum", (...args) => args.reduce((s, c) => s + c, 0));
+
+container.get("sum",
+ (sum) => sum(Object.values(frameworkStars)));
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/angular1Module.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/angular1Module.js
new file mode 100644
index 0000000000..f0e8c381ef
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/angular1Module.js
@@ -0,0 +1,4 @@
+angular.module('something', ['ngRoute', 'ngResource'])
+ .config(function ($routeProvider) {
+ 'use strict';
+ });
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/plainJavascript.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/plainJavascript.js
new file mode 100644
index 0000000000..41609f8715
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/plainJavascript.js
@@ -0,0 +1,8 @@
+"use strict"
+
+const a = 2;
+
+function test(a) {
+ return a;
+}
+
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactComponent.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactComponent.js
new file mode 100644
index 0000000000..37f3ac49e5
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactComponent.js
@@ -0,0 +1,3 @@
+import React, { Component } from "react";
+
+class PrimaryPanes extends Component {}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactComponentEs5.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactComponentEs5.js
new file mode 100644
index 0000000000..a4370b5369
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactComponentEs5.js
@@ -0,0 +1,3 @@
+var React = require("react");
+
+class PrimaryPanes extends React.Component {}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactLibrary.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactLibrary.js
new file mode 100644
index 0000000000..9ca048e77f
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reactLibrary.js
@@ -0,0 +1,19 @@
+/**
+ * Base class helpers for the updating state of a component.
+ */
+function Component(props, context, updater) {
+ this.props = props;
+ this.context = context;
+ // If a component has string refs, we will assign a different object later.
+ this.refs = emptyObject;
+ // We initialize the default updater but the real one gets injected by the
+ // renderer.
+ this.updater = updater || ReactNoopUpdateQueue;
+}
+
+Component.prototype.isReactComponent = {};
+Component.prototype.setState = function (partialState, callback) {
+ !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)
+ ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
+ this.updater.enqueueSetState(this, partialState, callback, 'setState');
+};
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reduxLibrary.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reduxLibrary.js
new file mode 100644
index 0000000000..b86c8fb0cf
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/reduxLibrary.js
@@ -0,0 +1,39 @@
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.Redux = {})));
+ }(this, (function (exports) { 'use strict';
+
+ function symbolObservablePonyfill(root) {
+ var result;
+ var Symbol = root.Symbol;
+
+ if (typeof Symbol === 'function') {
+ if (Symbol.observable) {
+ result = Symbol.observable;
+ } else {
+ result = Symbol('observable');
+ Symbol.observable = result;
+ }
+ } else {
+ result = '@@observable';
+ }
+
+ return result;
+ }
+
+ /* global window */
+
+ var root;
+
+ if (typeof self !== 'undefined') {
+ root = self;
+ } else if (typeof window !== 'undefined') {
+ root = window;
+ } else if (typeof global !== 'undefined') {
+ root = global;
+ } else if (typeof module !== 'undefined') {
+ root = module;
+ } else {
+ root = Function('return this')();
+ } \ No newline at end of file
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/vueFileComponent.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/vueFileComponent.js
new file mode 100644
index 0000000000..d41e55b72b
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/vueFileComponent.js
@@ -0,0 +1,3 @@
+Vue.component('test-item', {
+ template: '<li>This is a test item</li>'
+}) \ No newline at end of file
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/vueFileDeclarative.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/vueFileDeclarative.js
new file mode 100644
index 0000000000..844fce1451
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/frameworks/vueFileDeclarative.js
@@ -0,0 +1,6 @@
+var app = new Vue({
+ el: '#app',
+ data: {
+ message: 'Hello Vue!'
+ }
+}) \ No newline at end of file
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/func.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/func.js
new file mode 100644
index 0000000000..bb0d4c1b05
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/func.js
@@ -0,0 +1,50 @@
+function square(n) {
+ return n * n;
+}
+
+export function exFoo() {
+ return "yay";
+}
+
+async function slowFoo() {
+ return "meh";
+}
+
+export async function exSlowFoo() {
+ return "yay in a bit";
+}
+
+function ret() {
+ return foo();
+}
+
+child = function() {};
+
+(function() {
+ 2;
+})();
+
+const obj = {
+ foo: function name() {
+ 2 + 2;
+ },
+
+ bar() {
+ 2 + 2;
+ }
+};
+
+export default function root() {
+}
+
+function test(a1, a2 = 45, { a3, a4, a5: { a6: a7 } = {} } = {}) {
+ console.log("pause next here");
+}
+
+() => (x = 4);
+
+function ret2() {
+ return (
+ foo()
+ );
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/functionNames.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/functionNames.js
new file mode 100644
index 0000000000..2ae38fc548
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/functionNames.js
@@ -0,0 +1,50 @@
+/* eslint-disable */
+
+({
+ foo: function() {},
+ "foo": function() {},
+ 42: function() {},
+
+ foo() {},
+ "foo"() {},
+ 42() {},
+});
+
+foo = function() {};
+obj.foo = function() {};
+
+var foo = function(){};
+var [foo = function(){}] = [];
+var {foo = function(){}} = {};
+
+[foo = function(){}] = [];
+({foo = function(){}} = {});
+({bar: foo = function(){}} = {});
+
+function fn([foo = function(){}]){}
+function f2({foo = function(){}} = {}){}
+function f3({bar: foo = function(){}} = {}){}
+
+class Cls {
+ foo = function() {};
+ "foo" = function() {};
+ 42 = function() {};
+
+ foo() {}
+ "foo"() {}
+ 42() {}
+}
+
+(function(){});
+
+export default function (){}
+
+const defaultObj = {a: 1};
+const defaultArr = ['smthng'];
+function a(first, second){}
+function b(first = 'bla', second){}
+function c(first = {}, second){}
+function d(first = [], second){}
+function e(first = defaultObj, second){}
+function f(first = defaultArr, second){}
+function g(first = null, second){}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/generators.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/generators.js
new file mode 100644
index 0000000000..7c71838827
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/generators.js
@@ -0,0 +1,4 @@
+function* foo() {
+ yield 1;
+ yield 2;
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/jsx.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/jsx.js
new file mode 100644
index 0000000000..c781f7666f
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/jsx.js
@@ -0,0 +1,5 @@
+const jsxElement = <h1> Hi ! I'm here ! </h1>;
+
+<div id="3" res={foo()}>
+ <Item>{foo()}</Item>
+</div>
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/math.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/math.js
new file mode 100644
index 0000000000..508d28ca99
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/math.js
@@ -0,0 +1,15 @@
+function math(n) {
+ function square(n) {
+ // inline comment
+ n * n;
+ }
+
+ // document some lines
+ const two = square(2);
+
+ const four = squaare(4);
+ return two * four;
+}
+
+var child = function() {};
+child2 = function() {};
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/modules.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/modules.js
new file mode 100644
index 0000000000..8ba351497e
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/modules.js
@@ -0,0 +1,10 @@
+import {x} from "y"
+import z from "y";
+
+export class AppComponent {
+ title = 'app'
+}
+
+export default class AppComponent {
+ title = 'app'
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/object-expressions.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/object-expressions.js
new file mode 100644
index 0000000000..b7f4806e04
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/object-expressions.js
@@ -0,0 +1,6 @@
+const y = ({ params });
+const foo = ({ b });
+const bar = { x: 3, y: "434", z: true, a: null, s: c * 2, d : getValue(2) }
+const params = frameId ? { frameActor: frameId } : {}
+
+const collection = {genres: {"sci-fi": {movies: [{director: "yo"}]}}}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/optional-chaining.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/optional-chaining.js
new file mode 100644
index 0000000000..757335f78b
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/optional-chaining.js
@@ -0,0 +1,3 @@
+const obj = {};
+obj?.a;
+obj?.a?.b ?? [];
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/outOfScope.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/outOfScope.js
new file mode 100644
index 0000000000..30218f546b
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/outOfScope.js
@@ -0,0 +1,62 @@
+// Program Scope
+
+function outer() {
+ function inner() {
+ const x = 1;
+ }
+
+ const arrow = () => {
+ const x = 1;
+ };
+
+ const declaration = function() {
+ const x = 1;
+ };
+
+ assignment = (function() {
+ const x = 1;
+ })();
+
+ const iifeDeclaration = (function() {
+ const x = 1;
+ })();
+
+ return function() {
+ const x = 1;
+ };
+}
+
+function exclude() {
+ function another() {
+ const x = 1;
+ }
+}
+
+const globalArrow = () => {
+ const x = 1;
+};
+
+const globalDeclaration = function() {
+ const x = 1;
+};
+
+globalAssignment = (function() {
+ const x = 1;
+})();
+
+const globalIifeDeclaration = (function() {
+ const x = 1;
+})();
+
+function parentFunc() {
+ let MAX = 3;
+ let nums = [0, 1, 2, 3];
+ let x = 1;
+ let y = nums.find(function(n) {
+ return n == x;
+ });
+ function innerFunc(a) {
+ return Math.max(a, MAX);
+ }
+ return innerFunc(y);
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/outOfScopeComment.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/outOfScopeComment.js
new file mode 100644
index 0000000000..bc02f94671
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/outOfScopeComment.js
@@ -0,0 +1,4 @@
+// Some comment
+(function() {
+ const x = 1;
+})();
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/parseScriptTags.html b/devtools/client/debugger/src/workers/parser/tests/fixtures/parseScriptTags.html
new file mode 100644
index 0000000000..6283f0ee98
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/parseScriptTags.html
@@ -0,0 +1,42 @@
+<html>
+<head>
+ <script type="text/javascript">
+ var globalObject = {
+ first: "name",
+ last: "words"
+ };
+ function sayHello (name) {
+ return `Hello, ${name}!`;
+ }
+ </script>
+ <style>
+ BODY {
+ font-size: 48px;
+ color: rebeccapurple;
+ }
+ </style>
+</head>
+<body>
+ <h1>Testing Script Tags in HTML</h1>
+ <script>
+ const capitalize = name => {
+ return name[0].toUpperCase() + name.substring(1)
+ };
+ const greetAll = ["my friend", "buddy", "world"]
+ .map(capitalize)
+ .map(sayHello)
+ .join("\n");
+
+ globalObject.greetings = greetAll;
+ </script>
+ <p>
+ Some arbitrary intermediate content to affect the offsets of the scripts
+ </p>
+ <script>
+ (function iife() {
+ const greeting = sayHello("Ryan");
+ console.log(greeting);
+ })();
+ </script>
+</body>
+</html>
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/private-fields.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/private-fields.js
new file mode 100644
index 0000000000..ca9abc8f1d
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/private-fields.js
@@ -0,0 +1,24 @@
+class MyClass {
+ constructor(secret, ...rest) {
+ const self = this;
+ this.#secret = secret;
+ self.#restParams = rest;
+ }
+
+ #secret;
+ #restParams;
+ #salt = "bloup";
+ creationDate = new Date();
+
+ #getSalt() {
+ return this.#salt;
+ }
+
+ debug() {
+ const self = this;
+ const creationDate = this.creationDate;
+ const secret = this.#secret;
+ const salt = self.#getSalt();
+ return `${creationDate}|${salt}|${secret}`;
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/proto.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/proto.js
new file mode 100644
index 0000000000..38c3b63ac7
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/proto.js
@@ -0,0 +1,14 @@
+const foo = function() {};
+
+const bar = () => {};
+
+const TodoView = Backbone.View.extend({
+ tagName: "li",
+ initialize: function() {},
+ doThing(b) {
+ console.log("hi", b);
+ },
+ render: function() {
+ return this;
+ }
+});
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/resolveToken.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/resolveToken.js
new file mode 100644
index 0000000000..4660f0f568
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/resolveToken.js
@@ -0,0 +1,40 @@
+const a = 1;
+let b = 0;
+
+function getA() {
+ return a;
+}
+
+function setB(newB) {
+ b = newB;
+}
+
+const plusAB = (function(x, y) {
+ const obj = { x, y };
+ function insideClosure(alpha, beta) {
+ return alpha + beta + obj.x + obj.y;
+ }
+
+ return insideClosure;
+})(a, b);
+
+function withMultipleScopes() {
+ var outer = 1;
+ function innerScope() {
+ var inner = outer + 1;
+ return inner;
+ }
+
+ const fromIIFE = (function(toIIFE) {
+ return innerScope() + toIIFE;
+ })(1);
+
+ {
+ // random block
+ let x = outer + fromIIFE;
+ if (x) {
+ const y = x * x;
+ console.log(y);
+ }
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/arrow-function.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/arrow-function.js
new file mode 100644
index 0000000000..4ec72fd450
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/arrow-function.js
@@ -0,0 +1,11 @@
+export {};
+
+let outer = (p1) => {
+ console.log(this);
+
+ (function() {
+ var inner = (p2) => {
+ console.log(this);
+ };
+ })();
+};
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/binding-types.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/binding-types.js
new file mode 100644
index 0000000000..8c9cc05d1d
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/binding-types.js
@@ -0,0 +1,24 @@
+import def from "";
+import { named } from "";
+import { thing as otherNamed } from "";
+import * as namespace from "";
+
+function fn() {}
+class cls {
+ method(){
+
+ }
+}
+
+var aVar;
+let aLet;
+const aConst = "";
+
+(function inner() {
+ this;
+ arguments;
+});
+
+{
+ function blockFn(){}
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/block-statement.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/block-statement.js
new file mode 100644
index 0000000000..5e64d1180f
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/block-statement.js
@@ -0,0 +1,13 @@
+export {};
+
+let first;
+
+{
+ var second;
+ function third() {}
+ class Fourth {}
+ let fifth;
+ const sixth = 6;
+}
+
+var seventh;
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-declaration.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-declaration.js
new file mode 100644
index 0000000000..1c2c74dcbc
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-declaration.js
@@ -0,0 +1,14 @@
+export {};
+
+class Outer {
+ method() {
+ class Inner {
+ m() {
+ console.log(this);
+ }
+ }
+ }
+}
+
+@decorator
+class Second {}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-expression.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-expression.js
new file mode 100644
index 0000000000..16b6841d71
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-expression.js
@@ -0,0 +1,11 @@
+export {};
+
+var Outer = class Outer {
+ method() {
+ var Inner = class {
+ m() {
+ console.log(this);
+ }
+ };
+ }
+};
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-property.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-property.js
new file mode 100644
index 0000000000..a80cad3a87
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/class-property.js
@@ -0,0 +1,10 @@
+export {};
+
+class Foo {
+ prop = this.init();
+
+ other = do {
+ var one;
+ let two;
+ };
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/complex-nesting.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/complex-nesting.js
new file mode 100644
index 0000000000..40763f556f
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/complex-nesting.js
@@ -0,0 +1,29 @@
+function named(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = root;
+function root() {
+ function fn(arg) {
+ var _this = this,
+ _arguments = arguments;
+
+ console.log(this, arguments);
+ console.log("pause here", fn, root);
+
+ var arrow = function arrow(argArrow) {
+ console.log(_this, _arguments);
+ console.log("pause here", fn, root);
+ };
+ arrow("arrow-arg");
+ }
+
+ fn.call("this-value", "arg-value");
+}
+module.exports = exports["default"];
+
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/expressions.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/expressions.js
new file mode 100644
index 0000000000..6698acd8e8
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/expressions.js
@@ -0,0 +1,6 @@
+const foo = {};
+
+foo.bar().baz;
+(0, foo.bar)().baz;
+Object(foo.bar)().baz;
+__webpack_require__.i(foo.bar)().baz;
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/flowtype-bindings.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/flowtype-bindings.js
new file mode 100644
index 0000000000..385797c044
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/flowtype-bindings.js
@@ -0,0 +1,11 @@
+import type { One, Two, Three } from "./src/mod";
+
+type Other = {
+ root: typeof root,
+};
+
+const aConst = (window: Array<string>);
+
+export default function root() {
+
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/fn-body-lex-and-nonlex.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/fn-body-lex-and-nonlex.js
new file mode 100644
index 0000000000..a7f6d7670a
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/fn-body-lex-and-nonlex.js
@@ -0,0 +1,23 @@
+function fn() {
+ var nonlex;
+ let lex;
+
+}
+
+function fn2() {
+ function nonlex(){}
+ let lex;
+
+}
+
+function fn3() {
+ var nonlex;
+ class Thing {}
+
+}
+
+function fn4() {
+ function nonlex(){}
+ class Thing {}
+
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/for-loops.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/for-loops.js
new file mode 100644
index 0000000000..747eeeae7d
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/for-loops.js
@@ -0,0 +1,13 @@
+export {};
+
+for (var one;;) {}
+for (let two;;) {}
+for (const three = 3;;) {}
+
+for (var four in {}) {}
+for (let five in {}) {}
+for (const six in {}) {}
+
+for (var seven of {}) {}
+for (let eight of {}) {}
+for (const nine of {}) {}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/function-declaration.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/function-declaration.js
new file mode 100644
index 0000000000..759374b437
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/function-declaration.js
@@ -0,0 +1,11 @@
+export {};
+
+function outer(p1) {}
+
+{
+ function middle(p2) {
+ function inner(p3) {}
+
+ console.log(this);
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/function-expression.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/function-expression.js
new file mode 100644
index 0000000000..436413533e
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/function-expression.js
@@ -0,0 +1,7 @@
+export {};
+
+let fn = function(p1) {};
+
+let fn2 = function withName(p2) {
+ console.log(this);
+};
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/jsx-component.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/jsx-component.js
new file mode 100644
index 0000000000..ffe1c1dfce
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/jsx-component.js
@@ -0,0 +1,6 @@
+import SomeComponent from "";
+
+<SomeComponent attr="value" />;
+<SomeComponent attr="value"></SomeComponent>;
+<SomeComponent.prop attr="value" />;
+<SomeComponent.prop.child attr="value" />;
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/out-of-order-declarations.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/out-of-order-declarations.js
new file mode 100644
index 0000000000..4f36d9fc38
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/out-of-order-declarations.js
@@ -0,0 +1,21 @@
+var val;
+
+export default function root() {
+ var val;
+
+ var fn;
+
+ this;
+
+ function callback() {
+ console.log(val, fn, callback, root, this);
+
+ var val;
+
+ function fn(){};
+ }
+
+ callback();
+}
+
+import aDefault from "./src/mod";
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/pattern-declarations.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/pattern-declarations.js
new file mode 100644
index 0000000000..6810ef4614
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/pattern-declarations.js
@@ -0,0 +1,2 @@
+var { prop: one } = {};
+var [ two ] = [];
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/simple-module.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/simple-module.js
new file mode 100644
index 0000000000..b25cc7a863
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/simple-module.js
@@ -0,0 +1,11 @@
+import foo from "foo";
+
+console.log(foo);
+
+var one = 1;
+let two = 2;
+const three = 3;
+
+function fn() {}
+
+this;
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/switch-statement.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/switch-statement.js
new file mode 100644
index 0000000000..7163c3811d
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/switch-statement.js
@@ -0,0 +1,22 @@
+export {};
+
+switch (foo) {
+ case "zero":
+ var zero;
+ case "one":
+ let one;
+ case "two":
+ let two;
+ case "three": {
+ let three;
+ }
+}
+
+switch (foo) {
+ case "":
+ function two(){}
+}
+switch (foo) {
+ case "":
+ class three {}
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/try-catch.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/try-catch.js
new file mode 100644
index 0000000000..8ccf4db592
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/try-catch.js
@@ -0,0 +1,9 @@
+export {};
+
+try {
+ var first;
+ let second;
+} catch (err) {
+ var third;
+ let fourth;
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/ts-sample.ts b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/ts-sample.ts
new file mode 100644
index 0000000000..e23ff83754
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/ts-sample.ts
@@ -0,0 +1,41 @@
+
+// TSEnumDeclaration
+enum Color {
+ // TSEnumMember
+ Red,
+ Green,
+ Blue,
+}
+
+class Example<T> {
+ // TSParameterProperty
+ constructor(public foo) {
+
+ }
+
+ method(): never {
+ throw new Error();
+ }
+}
+
+// TSTypeAssertion
+var foo = <any>window;
+
+// TSAsExpression
+(window as any);
+
+// TSNonNullExpression
+(window!);
+
+// TSModuleDeclaration
+namespace TheSpace {
+ function fn() {
+
+ }
+}
+
+// TSImportEqualsDeclaration
+import ImportedClass = require("mod");
+
+// TSExportAssignment
+export = Example;
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/tsx-sample.tsx b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/tsx-sample.tsx
new file mode 100644
index 0000000000..9e2b9faf8b
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/tsx-sample.tsx
@@ -0,0 +1,41 @@
+
+// TSEnumDeclaration
+enum Color {
+ // TSEnumMember
+ Red,
+ Green,
+ Blue,
+}
+
+class Example<T> {
+ // TSParameterProperty
+ constructor(public foo) {
+
+ }
+
+ method(): never {
+ throw new Error();
+ }
+}
+
+// JSXElement
+var foo = <any>window</any>;
+
+// TSAsExpression
+(window as any);
+
+// TSNonNullExpression
+(window!);
+
+// TSModuleDeclaration
+namespace TheSpace {
+ function fn() {
+
+ }
+}
+
+// TSImportEqualsDeclaration
+import ImportedClass = require("mod");
+
+// TSExportAssignment
+export = Example;
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/vue-sample.vue b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/vue-sample.vue
new file mode 100644
index 0000000000..0fceee99d1
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/scopes/vue-sample.vue
@@ -0,0 +1,26 @@
+<template>
+ <div class="hello">
+ <h1>{{ msg }}</h1>
+ </div>
+</template>
+
+<script>
+var moduleVar = "data";
+
+export default {
+ name: 'HelloWorld',
+ data () {
+ var fnVar = 4;
+
+ return {
+ msg: 'Welcome to Your Vue.js App'
+ };
+ }
+};
+</script>
+
+<style scoped>
+a {
+ color: red;
+}
+</style>
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/statements.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/statements.js
new file mode 100644
index 0000000000..f2c113570e
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/statements.js
@@ -0,0 +1,40 @@
+debugger; debugger;
+console.log("a"); console.log("a");
+
+// assignments with valid pause locations
+this.x = 3;
+var a = 4;
+var d = [foo()]
+var f = 3, e = 4;
+var g = [], h = {};
+
+// assignments with invalid pause locations
+var b = foo();
+c = foo();
+
+
+const arr = [
+ '1',
+ 2,
+ foo()
+]
+
+const obj = {
+ a: '1',
+ b: 2,
+ c: foo(),
+}
+
+foo(
+ 1,
+ foo(
+ 1
+ ),
+ 3
+)
+
+throw new Error("3");
+3;
+
+while (i < 6) { break }
+while (i < 6) { continue;}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/thisExpression.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/thisExpression.js
new file mode 100644
index 0000000000..dd398db426
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/thisExpression.js
@@ -0,0 +1,11 @@
+class Test {
+ constructor() {
+ this.foo = {
+ a: "foobar"
+ };
+ }
+
+ bar() {
+ console.log(this.foo.a);
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/fixtures/var.js b/devtools/client/debugger/src/workers/parser/tests/fixtures/var.js
new file mode 100644
index 0000000000..509ad368e8
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/fixtures/var.js
@@ -0,0 +1,21 @@
+var foo = 1;
+let bar = 2;
+const baz = 3;
+const a = 4,
+ b = 5;
+a = 5;
+
+var { foo: { baw } } = {}
+var {bap} = {}
+var {ll = 3} = {}
+
+
+var [first] = [1]
+
+var { a: _a } = 3
+
+var [oh, {my: god}] = [{},{}]
+
+var [[oj], [{oy, vey: _vey, mitzvot: _mitz = 4}]] = [{},{}]
+
+var [one, ...stuff] = []
diff --git a/devtools/client/debugger/src/workers/parser/tests/framework.spec.js b/devtools/client/debugger/src/workers/parser/tests/framework.spec.js
new file mode 100644
index 0000000000..d41f45b71c
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/framework.spec.js
@@ -0,0 +1,63 @@
+/* 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 { getSymbols } from "../getSymbols";
+import { populateOriginalSource } from "./helpers";
+import cases from "jest-in-case";
+
+cases(
+ "Parser.getFramework",
+ ({ name, file, value }) => {
+ const source = populateOriginalSource("frameworks/plainJavascript");
+ const symbols = getSymbols(source.id);
+ expect(symbols.framework).toBeNull();
+ },
+ [
+ {
+ name: "is undefined when no framework",
+ file: "frameworks/plainJavascript",
+ value: null,
+ },
+ {
+ name: "does not get confused with angular (#6833)",
+ file: "frameworks/angular1FalsePositive",
+ value: null,
+ },
+ {
+ name: "recognizes ES6 React component",
+ file: "frameworks/reactComponent",
+ value: "React",
+ },
+ {
+ name: "recognizes ES5 React component",
+ file: "frameworks/reactComponentEs5",
+ value: "React",
+ },
+ {
+ name: "recognizes Angular 1 module",
+ file: "frameworks/angular1Module",
+ value: "Angular",
+ },
+ {
+ name: "recognizes declarative Vue file",
+ file: "frameworks/vueFileDeclarative",
+ value: "Vue",
+ },
+ {
+ name: "recognizes component Vue file",
+ file: "frameworks/vueFileComponent",
+ value: "Vue",
+ },
+ {
+ name: "recognizes the react library file",
+ file: "framework/reactLibrary",
+ value: "React",
+ },
+ {
+ name: "recognizes the redux library file",
+ file: "framework/reduxLibrary",
+ value: "React",
+ },
+ ]
+);
diff --git a/devtools/client/debugger/src/workers/parser/tests/getScopes.spec.js b/devtools/client/debugger/src/workers/parser/tests/getScopes.spec.js
new file mode 100644
index 0000000000..fa19197a92
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/getScopes.spec.js
@@ -0,0 +1,227 @@
+/* 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/>. */
+
+import getScopes from "../getScopes";
+import { populateOriginalSource } from "./helpers";
+import cases from "jest-in-case";
+
+cases(
+ "Parser.getScopes",
+ ({ name, file, type, locations }) => {
+ const source = populateOriginalSource(file, type);
+
+ locations.forEach(([line, column]) => {
+ const scopes = getScopes({
+ sourceId: source.id,
+ line,
+ column,
+ });
+
+ expect(scopes).toMatchSnapshot(
+ `getScopes ${name} at line ${line} column ${column}`
+ );
+ });
+ },
+ [
+ {
+ name: "finds scope bindings in fn body with both lex and non-lex items",
+ file: "scopes/fn-body-lex-and-nonlex",
+ locations: [
+ [4, 0],
+ [10, 0],
+ [16, 0],
+ [22, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings in a vue file",
+ file: "scopes/vue-sample",
+ type: "vue",
+ locations: [[14, 0]],
+ },
+ {
+ name: "finds scope bindings in a typescript file",
+ file: "scopes/ts-sample",
+ type: "ts",
+ locations: [
+ [9, 0],
+ [13, 4],
+ [17, 0],
+ [33, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings in a typescript-jsx file",
+ file: "scopes/tsx-sample",
+ type: "tsx",
+ locations: [
+ [9, 0],
+ [13, 4],
+ [17, 0],
+ [33, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings in a module",
+ file: "scopes/simple-module",
+ locations: [[7, 0]],
+ },
+ {
+ name: "finds scope bindings in a JSX element",
+ file: "scopes/jsx-component",
+ locations: [[2, 0]],
+ },
+ {
+ name: "finds scope bindings for complex binding nesting",
+ file: "scopes/complex-nesting",
+ locations: [
+ [16, 4],
+ [20, 6],
+ ],
+ },
+ {
+ name: "finds scope bindings for function declarations",
+ file: "scopes/function-declaration",
+ locations: [
+ [2, 0],
+ [3, 20],
+ [5, 1],
+ [9, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for function expressions",
+ file: "scopes/function-expression",
+ locations: [
+ [2, 0],
+ [3, 23],
+ [6, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for arrow functions",
+ file: "scopes/arrow-function",
+ locations: [
+ [2, 0],
+ [4, 0],
+ [7, 0],
+ [8, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for class declarations",
+ file: "scopes/class-declaration",
+ locations: [
+ [2, 0],
+ [5, 0],
+ [7, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for class expressions",
+ file: "scopes/class-expression",
+ locations: [
+ [2, 0],
+ [5, 0],
+ [7, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for for loops",
+ file: "scopes/for-loops",
+ locations: [
+ [2, 0],
+ [3, 17],
+ [4, 17],
+ [5, 25],
+ [7, 22],
+ [8, 22],
+ [9, 23],
+ [11, 23],
+ [12, 23],
+ [13, 24],
+ ],
+ },
+ {
+ name: "finds scope bindings for try..catch",
+ file: "scopes/try-catch",
+ locations: [
+ [2, 0],
+ [4, 0],
+ [7, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for out of order declarations",
+ file: "scopes/out-of-order-declarations",
+ locations: [
+ [2, 0],
+ [5, 0],
+ [11, 0],
+ [14, 0],
+ [17, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for block statements",
+ file: "scopes/block-statement",
+ locations: [
+ [2, 0],
+ [6, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for class properties",
+ file: "scopes/class-property",
+ locations: [
+ [2, 0],
+ [4, 16],
+ [6, 12],
+ [7, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings and exclude Flowtype",
+ file: "scopes/flowtype-bindings",
+ locations: [
+ [8, 0],
+ [10, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings for declarations with patterns",
+ file: "scopes/pattern-declarations",
+ locations: [[1, 0]],
+ },
+ {
+ name: "finds scope bindings for switch statements",
+ file: "scopes/switch-statement",
+ locations: [
+ [2, 0],
+ [5, 0],
+ [7, 0],
+ [9, 0],
+ [11, 0],
+ [17, 0],
+ [21, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings with proper types",
+ file: "scopes/binding-types",
+ locations: [
+ [5, 0],
+ [9, 0],
+ [18, 0],
+ [23, 0],
+ ],
+ },
+ {
+ name: "finds scope bindings with expression metadata",
+ file: "scopes/expressions",
+ locations: [[2, 0]],
+ },
+ ]
+);
diff --git a/devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js b/devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js
new file mode 100644
index 0000000000..6a7cccce49
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js
@@ -0,0 +1,49 @@
+/* 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/>. */
+
+import { formatSymbols } from "../utils/formatSymbols";
+import { populateSource, populateOriginalSource } from "./helpers";
+import cases from "jest-in-case";
+
+cases(
+ "Parser.getSymbols",
+ ({ name, file, original, type }) => {
+ const source = original
+ ? populateOriginalSource(file, type)
+ : populateSource(file, type);
+
+ 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 },
+ { name: "var", file: "var" },
+ { name: "expression", file: "expression" },
+ { name: "allSymbols", file: "allSymbols" },
+ { name: "call sites", file: "call-sites" },
+ { name: "call expression", file: "callExpressions" },
+ { name: "object expressions", file: "object-expressions" },
+ { name: "optional chaining", file: "optional-chaining" },
+ { name: "private fields", file: "private-fields" },
+ {
+ name: "finds symbols in an html file",
+ file: "parseScriptTags",
+ type: "html",
+ },
+ { name: "component", file: "component", original: true },
+ {
+ name: "react component",
+ file: "frameworks/reactComponent",
+ original: true,
+ },
+ { name: "flow", file: "flow", original: true },
+ { name: "jsx", file: "jsx", original: true },
+ { name: "destruct", file: "destructuring" },
+ ]
+);
diff --git a/devtools/client/debugger/src/workers/parser/tests/helpers/index.js b/devtools/client/debugger/src/workers/parser/tests/helpers/index.js
new file mode 100644
index 0000000000..47c358ae66
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/helpers/index.js
@@ -0,0 +1,86 @@
+/* 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 fs from "fs";
+import path from "path";
+
+import { makeMockSourceAndContent } from "../../../../utils/test-mockup";
+import { setSource } from "../../sources";
+import * as asyncValue from "../../../../utils/async-value";
+
+export function getFixture(name, type = "js") {
+ return fs.readFileSync(
+ path.join(__dirname, `../fixtures/${name}.${type}`),
+ "utf8"
+ );
+}
+
+function getSourceContent(name, type = "js") {
+ 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 {
+ type: "text",
+ value: text,
+ contentType,
+ };
+}
+
+export function getSource(name, type) {
+ const { value: text, contentType } = getSourceContent(name, type);
+
+ return makeMockSourceAndContent(undefined, name, contentType, text);
+}
+
+export function populateSource(name, type) {
+ const { content, ...source } = getSource(name, type);
+ setSource({
+ id: source.id,
+ text: content.value,
+ contentType: content.contentType,
+ isWasm: false,
+ });
+ return {
+ ...source,
+ content: asyncValue.fulfilled(content),
+ };
+}
+
+export function getOriginalSource(name, type) {
+ return getOriginalSourceWithContent(name, type);
+}
+
+export function getOriginalSourceWithContent(name, type) {
+ const { value: text, contentType } = getSourceContent(name, type);
+
+ return makeMockSourceAndContent(
+ undefined,
+ `${name}/originalSource-1`,
+ contentType,
+ text
+ );
+}
+
+export function populateOriginalSource(name, type) {
+ const { content, ...source } = getOriginalSourceWithContent(name, type);
+ setSource({
+ id: source.id,
+ text: content.value,
+ contentType: content.contentType,
+ isWasm: false,
+ });
+ return {
+ ...source,
+ content: asyncValue.fulfilled(content),
+ };
+}
diff --git a/devtools/client/debugger/src/workers/parser/tests/mapBindings.spec.js b/devtools/client/debugger/src/workers/parser/tests/mapBindings.spec.js
new file mode 100644
index 0000000000..8c23ab5873
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/mapBindings.spec.js
@@ -0,0 +1,161 @@
+/* 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 mapExpressionBindings from "../mapBindings";
+import { parseConsoleScript } from "../utils/ast";
+import cases from "jest-in-case";
+
+const prettier = require("prettier");
+
+function format(code) {
+ return prettier.format(code, { semi: false, parser: "babel" });
+}
+
+function excludedTest({ name, expression, bindings = [] }) {
+ const safeExpression = mapExpressionBindings(
+ expression,
+ parseConsoleScript(expression),
+ bindings
+ );
+ expect(format(safeExpression)).toEqual(format(expression));
+}
+
+function includedTest({ name, expression, newExpression, bindings }) {
+ const safeExpression = mapExpressionBindings(
+ expression,
+ parseConsoleScript(expression),
+ bindings
+ );
+ expect(format(safeExpression)).toEqual(format(newExpression));
+}
+
+describe("mapExpressionBindings", () => {
+ cases("included cases", includedTest, [
+ {
+ name: "single declaration",
+ expression: "const a = 2; let b = 3; var c = 4;",
+ newExpression: "self.a = 2; self.b = 3; self.c = 4;",
+ },
+ {
+ name: "multiple declarations",
+ expression: "const a = 2, b = 3",
+ newExpression: "self.a = 2; self.b = 3",
+ },
+ {
+ name: "declaration with separate assignment",
+ expression: "let a; a = 2;",
+ newExpression: "self.a = void 0; self.a = 2;",
+ },
+ {
+ name: "multiple declarations with no assignment",
+ expression: "let a = 2, b;",
+ newExpression: "self.a = 2; self.b = void 0;",
+ },
+ {
+ name: "local bindings become assignments",
+ bindings: ["a"],
+ expression: "var a = 2;",
+ newExpression: "a = 2;",
+ },
+ {
+ name: "assignments",
+ expression: "a = 2;",
+ newExpression: "self.a = 2;",
+ },
+ {
+ name: "assignments with +=",
+ expression: "a += 2;",
+ newExpression: "self.a += 2;",
+ },
+ {
+ name: "destructuring (objects)",
+ expression: "const { a } = {}; ",
+ newExpression: "({ a: self.a } = {})",
+ },
+ {
+ name: "destructuring (arrays)",
+ expression: " var [a, ...foo] = [];",
+ newExpression: "([self.a, ...self.foo] = [])",
+ },
+ {
+ name: "destructuring (declarations)",
+ expression: "var {d,e} = {}, {f} = {}; ",
+ newExpression: `({ d: self.d, e: self.e } = {});
+ ({ f: self.f } = {})
+ `,
+ },
+ {
+ name: "destructuring & declaration",
+ expression: "const { a } = {}; var b = 3",
+ newExpression: `({ a: self.a } = {});
+ self.b = 3
+ `,
+ },
+ {
+ name: "destructuring assignment",
+ expression: "[a] = [3]",
+ newExpression: "[self.a] = [3]",
+ },
+ {
+ name: "destructuring assignment (declarations)",
+ expression: "[a] = [3]; var b = 4",
+ newExpression: "[self.a] = [3];\n self.b = 4",
+ },
+ ]);
+
+ cases("excluded cases", excludedTest, [
+ { name: "local variables", expression: "function a() { var b = 2}" },
+ { name: "functions", expression: "function a() {}" },
+ { name: "classes", expression: "class a {}" },
+
+ { name: "with", expression: "with (obj) {var a = 2;}" },
+ {
+ name: "with & declaration",
+ expression: "with (obj) {var a = 2;}; ; var b = 3",
+ },
+ {
+ name: "hoisting",
+ expression: "{ const h = 3; }",
+ },
+ {
+ name: "assignments",
+ bindings: ["a"],
+ expression: "a = 2;",
+ },
+ {
+ name: "identifier",
+ expression: "a",
+ },
+ ]);
+
+ cases("cases that we should map in the future", excludedTest, [
+ { name: "blocks (IF)", expression: "if (true) { var a = 3; }" },
+ {
+ name: "hoisting",
+ expression: "{ var g = 5; }",
+ },
+ {
+ name: "for loops bindings",
+ expression: "for (let foo = 4; false;){}",
+ },
+ ]);
+
+ cases("cases that we shouldn't map in the future", includedTest, [
+ {
+ name: "window properties",
+ expression: "var innerHeight = 3; var location = 5;",
+ newExpression: "self.innerHeight = 3; self.location = 5;",
+ },
+ {
+ name: "self declaration",
+ expression: "var self = 3",
+ newExpression: "self.self = 3",
+ },
+ {
+ name: "self assignment",
+ expression: "self = 3",
+ newExpression: "self.self = 3",
+ },
+ ]);
+});
diff --git a/devtools/client/debugger/src/workers/parser/tests/mapExpression.spec.js b/devtools/client/debugger/src/workers/parser/tests/mapExpression.spec.js
new file mode 100644
index 0000000000..27cc86b039
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/mapExpression.spec.js
@@ -0,0 +1,785 @@
+/* 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 mapExpression from "../mapExpression";
+import { format } from "prettier";
+import cases from "jest-in-case";
+
+function test({
+ expression,
+ newExpression,
+ bindings,
+ mappings,
+ shouldMapBindings,
+ expectedMapped,
+ parseExpression = true,
+}) {
+ const res = mapExpression(expression, mappings, bindings, shouldMapBindings);
+
+ if (parseExpression) {
+ expect(
+ format(res.expression, {
+ parser: "babel",
+ })
+ ).toEqual(format(newExpression, { parser: "babel" }));
+ } else {
+ expect(res.expression).toEqual(newExpression);
+ }
+
+ expect(res.mapped).toEqual(expectedMapped);
+}
+
+function formatAwait(body) {
+ return `(async () => { ${body} })();`;
+}
+
+describe("mapExpression", () => {
+ cases("mapExpressions", test, [
+ {
+ name: "await",
+ expression: "await a()",
+ newExpression: formatAwait("return a()"),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (multiple statements)",
+ expression: "const x = await a(); x + x",
+ newExpression: formatAwait("self.x = await a(); return x + x;"),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (inner)",
+ expression: "async () => await a();",
+ newExpression: "async () => await a();",
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (multiple awaits)",
+ expression: "const x = await a(); await b(x)",
+ newExpression: formatAwait("self.x = await a(); return b(x);"),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (assignment)",
+ expression: "let x = await sleep(100, 2)",
+ newExpression: formatAwait("return (self.x = await sleep(100, 2))"),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (destructuring)",
+ expression: "const { a, c: y } = await b()",
+ newExpression: formatAwait(
+ "return ({ a: self.a, c: self.y } = await b())"
+ ),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (array destructuring)",
+ expression: "const [a, y] = await b();",
+ newExpression: formatAwait("return ([self.a, self.y] = await b())"),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (mixed destructuring)",
+ expression: "const [{ a }] = await b();",
+ newExpression: formatAwait("return ([{ a: self.a }] = await b())"),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (destructuring, multiple statements)",
+ expression: "const { a, c: y } = await b(), { x } = await y()",
+ newExpression: formatAwait(`
+ ({ a: self.a, c: self.y } = await b())
+ return ({ x: self.x } = await y());
+ `),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (destructuring, bindings)",
+ expression: "const { a, c: y } = await b();",
+ newExpression: formatAwait("return ({ a, c: y } = await b())"),
+ bindings: ["a", "y"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (array destructuring, bindings)",
+ expression: "const [a, y] = await b();",
+ newExpression: formatAwait("return ([a, y] = await b())"),
+ bindings: ["a", "y"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (mixed destructuring, bindings)",
+ expression: "const [{ a }] = await b();",
+ newExpression: formatAwait("return ([{ a }] = await b())"),
+ bindings: ["a"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (destructuring with defaults, bindings)",
+ expression: "const { c, a = 5 } = await b();",
+ newExpression: formatAwait("return ({ c: self.c, a = 5 } = await b())"),
+ bindings: ["a", "y"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (array destructuring with defaults, bindings)",
+ expression: "const [a, y = 10] = await b();",
+ newExpression: formatAwait("return ([a, y = 10] = await b())"),
+ bindings: ["a", "y"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (mixed destructuring with defaults, bindings)",
+ expression: "const [{ c = 5 }, a = 5] = await b();",
+ newExpression: formatAwait(
+ "return ([ { c: self.c = 5 }, a = 5] = await b())"
+ ),
+ bindings: ["a"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (nested destructuring, bindings)",
+ expression: "const { a, c: { y } } = await b();",
+ newExpression: formatAwait(`
+ return ({
+ a,
+ c: { y }
+ } = await b());
+ `),
+ bindings: ["a", "y"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (nested destructuring with defaults)",
+ expression: "const { a, c: { y = 5 } = {} } = await b();",
+ newExpression: formatAwait(`return ({
+ a: self.a,
+ c: { y: self.y = 5 } = {},
+ } = await b());
+ `),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (very nested destructuring with defaults)",
+ expression:
+ "const { a, c: { y: { z = 10, b } = { b: 5 } } } = await b();",
+ newExpression: formatAwait(`
+ return ({
+ a: self.a,
+ c: {
+ y: { z: self.z = 10, b: self.b } = {
+ b: 5
+ }
+ }
+ } = await b());
+ `),
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (with SyntaxError)",
+ expression: "await new Promise())",
+ newExpression: formatAwait("await new Promise())"),
+ parseExpression: false,
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, let assignment)",
+ expression: "let a = await 123;",
+ newExpression: `let a;
+
+ (async () => {
+ return a = await 123;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, var assignment)",
+ expression: "var a = await 123;",
+ newExpression: `var a;
+
+ (async () => {
+ return a = await 123;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, const assignment)",
+ expression: "const a = await 123;",
+ newExpression: `let a;
+
+ (async () => {
+ return a = await 123;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, multiple assignments)",
+ expression: "let a = 1, b, c = 3; b = await 123; a + b + c",
+ newExpression: `let a, b, c;
+
+ (async () => {
+ a = 1;
+ c = 3;
+ b = await 123;
+ return a + b + c;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, object destructuring)",
+ expression: "let {a, b, c} = await x;",
+ newExpression: `let a, b, c;
+
+ (async () => {
+ return ({a, b, c} = await x);
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, object destructuring with rest)",
+ expression: "let {a, ...rest} = await x;",
+ newExpression: `let a, rest;
+
+ (async () => {
+ return ({a, ...rest} = await x);
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, object destructuring with renaming and default)",
+ expression: "let {a: hello, b, c: world, d: $ = 4} = await x;",
+ newExpression: `let hello, b, world, $;
+
+ (async () => {
+ return ({a: hello, b, c: world, d: $ = 4} = await x);
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, nested object destructuring + renaming + default)",
+ expression: `let {
+ a: hello, c: { y: { z = 10, b: bill, d: [e, f = 20] }}
+ } = await x; z;`,
+ newExpression: `let hello, z, bill, e, f;
+
+ (async () => {
+ ({ a: hello, c: { y: { z = 10, b: bill, d: [e, f = 20] }}} = await x);
+ return z;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, array destructuring)",
+ expression: "let [a, b, c] = await x; c;",
+ newExpression: `let a, b, c;
+
+ (async () => {
+ [a, b, c] = await x;
+ return c;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, array destructuring with default)",
+ expression: "let [a, b = 1, c = 2] = await x; c;",
+ newExpression: `let a, b, c;
+
+ (async () => {
+ [a, b = 1, c = 2] = await x;
+ return c;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, array destructuring with default and rest)",
+ expression: "let [a, b = 1, c = 2, ...rest] = await x; rest;",
+ newExpression: `let a, b, c, rest;
+
+ (async () => {
+ [a, b = 1, c = 2, ...rest] = await x;
+ return rest;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, nested array destructuring with default)",
+ expression: "let [a, b = 1, [c = 2, [d = 3, e = 4]]] = await x; c;",
+ newExpression: `let a, b, c, d, e;
+
+ (async () => {
+ [a, b = 1, [c = 2, [d = 3, e = 4]]] = await x;
+ return c;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (no bindings, dynamic import)",
+ expression: `
+ var {rainbowLog} = await import("./cool-module.js");
+ rainbowLog("dynamic");`,
+ newExpression: `var rainbowLog;
+
+ (async () => {
+ ({rainbowLog} = await import("./cool-module.js"));
+ return rainbowLog("dynamic");
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (nullish coalesce operator)",
+ expression: "await x; true ?? false",
+ newExpression: `(async () => {
+ await x;
+ return true ?? false;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (optional chaining operator)",
+ expression: "await x; x?.y?.z",
+ newExpression: `(async () => {
+ await x;
+ return x?.y?.z;
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (async function declaration with nullish coalesce operator)",
+ expression: "async function coalesce(x) { await x; return x ?? false; }",
+ newExpression:
+ "async function coalesce(x) { await x; return x ?? false; }",
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: false,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "await (async function declaration with optional chaining operator)",
+ expression: "async function chain(x) { await x; return x?.y?.z; }",
+ newExpression: "async function chain(x) { await x; return x?.y?.z; }",
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: false,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ // check that variable declaration in for loop is not put outside of the async iife
+ name: "await (for loop)",
+ expression: "for (let i=0;i<2;i++) {}; var b = await 1;",
+ newExpression: `var b;
+
+ (async () => {
+ for (let i=0;i<2;i++) {}
+
+ return (b = await 1);
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ // check that variable declaration in for-in loop is not put outside of the async iife
+ name: "await (for..in loop)",
+ expression: "for (let i in {}) {}; var b = await 1;",
+ newExpression: `var b;
+
+ (async () => {
+ for (let i in {}) {}
+
+ return (b = await 1);
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ // check that variable declaration in for-of loop is not put outside of the async iife
+ name: "await (for..of loop)",
+ expression: "for (let i of []) {}; var b = await 1;",
+ newExpression: `var b;
+
+ (async () => {
+ for (let i of []) {}
+
+ return (b = await 1);
+ })()`,
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: true,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "simple",
+ expression: "a",
+ newExpression: "a",
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "mappings",
+ expression: "a",
+ newExpression: "_a",
+ bindings: [],
+ mappings: {
+ a: "_a",
+ },
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: false,
+ originalExpression: true,
+ },
+ },
+ {
+ name: "declaration",
+ expression: "var a = 3;",
+ newExpression: "self.a = 3",
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "declaration + destructuring",
+ expression: "var { a } = { a: 3 };",
+ newExpression: "({ a: self.a } = {\n a: 3 \n})",
+ bindings: [],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "bindings",
+ expression: "var a = 3;",
+ newExpression: "a = 3",
+ bindings: ["a"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "bindings + destructuring",
+ expression: "var { a } = { a: 3 };",
+ newExpression: "({ a } = { \n a: 3 \n })",
+ bindings: ["a"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "bindings + destructuring + rest",
+ expression: "var { a, ...foo } = {}",
+ newExpression: "({ a, ...self.foo } = {})",
+ bindings: ["a"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "bindings + array destructuring + rest",
+ expression: "var [a, ...foo] = []",
+ newExpression: "([a, ...self.foo] = [])",
+ bindings: ["a"],
+ mappings: {},
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "bindings + mappings",
+ expression: "a = 3;",
+ newExpression: "self.a = 3",
+ bindings: ["_a"],
+ mappings: { a: "_a" },
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "bindings + mappings + destructuring",
+ expression: "var { a } = { a: 4 }",
+ newExpression: "({ a: self.a } = {\n a: 4 \n})",
+ bindings: ["_a"],
+ mappings: { a: "_a" },
+ shouldMapBindings: true,
+ expectedMapped: {
+ await: false,
+ bindings: true,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "bindings without mappings",
+ expression: "a = 3;",
+ newExpression: "a = 3",
+ bindings: [],
+ mappings: { a: "_a" },
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: false,
+ bindings: false,
+ originalExpression: false,
+ },
+ },
+ {
+ name: "object destructuring + bindings without mappings",
+ expression: "({ a } = {});",
+ newExpression: "({ a: _a } = {})",
+ bindings: [],
+ mappings: { a: "_a" },
+ shouldMapBindings: false,
+ expectedMapped: {
+ await: false,
+ bindings: false,
+ originalExpression: true,
+ },
+ },
+ ]);
+});
diff --git a/devtools/client/debugger/src/workers/parser/tests/mapOriginalExpression.spec.js b/devtools/client/debugger/src/workers/parser/tests/mapOriginalExpression.spec.js
new file mode 100644
index 0000000000..028c86b5fe
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/mapOriginalExpression.spec.js
@@ -0,0 +1,93 @@
+/* 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 mapExpression from "../mapExpression";
+import { format } from "prettier";
+
+const formatOutput = output =>
+ format(output, {
+ parser: "babel",
+ });
+
+const mapOriginalExpression = (expression, mappings) =>
+ mapExpression(expression, mappings, [], false, false).expression;
+
+describe("mapOriginalExpression", () => {
+ it("simple", () => {
+ const generatedExpression = mapOriginalExpression("a + b;", {
+ a: "foo",
+ b: "bar",
+ });
+ expect(generatedExpression).toEqual("foo + bar;");
+ });
+
+ it("this", () => {
+ const generatedExpression = mapOriginalExpression("this.prop;", {
+ this: "_this",
+ });
+ expect(generatedExpression).toEqual("_this.prop;");
+ });
+
+ it("member expressions", () => {
+ const generatedExpression = mapOriginalExpression("a + b", {
+ a: "_mod.foo",
+ b: "_mod.bar",
+ });
+ expect(generatedExpression).toEqual("_mod.foo + _mod.bar;");
+ });
+
+ it("block", () => {
+ // todo: maybe wrap with parens ()
+ const generatedExpression = mapOriginalExpression("{a}", {
+ a: "_mod.foo",
+ b: "_mod.bar",
+ });
+ expect(generatedExpression).toEqual("{\n _mod.foo;\n}");
+ });
+
+ it("skips codegen with no mappings", () => {
+ const generatedExpression = mapOriginalExpression("a + b", {
+ a: "a",
+ c: "_c",
+ });
+ expect(generatedExpression).toEqual("a + b");
+ });
+
+ it("object destructuring", () => {
+ const generatedExpression = mapOriginalExpression("({ a } = { a: 4 })", {
+ a: "_mod.foo",
+ });
+
+ expect(formatOutput(generatedExpression)).toEqual(
+ formatOutput("({ a: _mod.foo } = {\n a: 4 \n})")
+ );
+ });
+
+ it("nested object destructuring", () => {
+ const generatedExpression = mapOriginalExpression(
+ "({ a: { b, c } } = { a: 4 })",
+ {
+ a: "_mod.foo",
+ b: "_mod.bar",
+ }
+ );
+
+ expect(formatOutput(generatedExpression)).toEqual(
+ formatOutput("({ a: { b: _mod.bar, c } } = {\n a: 4 \n})")
+ );
+ });
+
+ it("shadowed bindings", () => {
+ const generatedExpression = mapOriginalExpression(
+ "window.thing = function fn(){ var a; a; b; }; a; b; ",
+ {
+ a: "_a",
+ b: "_b",
+ }
+ );
+ expect(generatedExpression).toEqual(
+ "window.thing = function fn() {\n var a;\n a;\n _b;\n};\n\n_a;\n_b;"
+ );
+ });
+});
diff --git a/devtools/client/debugger/src/workers/parser/tests/sources.spec.js b/devtools/client/debugger/src/workers/parser/tests/sources.spec.js
new file mode 100644
index 0000000000..e84ae4ad22
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/sources.spec.js
@@ -0,0 +1,14 @@
+/* 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 { getSource } from "../sources";
+
+describe("sources", () => {
+ it("fail getSource", () => {
+ const sourceId = "some.nonexistent.source.id";
+ expect(() => {
+ getSource(sourceId);
+ }).toThrow();
+ });
+});
diff --git a/devtools/client/debugger/src/workers/parser/tests/validate.spec.js b/devtools/client/debugger/src/workers/parser/tests/validate.spec.js
new file mode 100644
index 0000000000..e7edefe472
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/tests/validate.spec.js
@@ -0,0 +1,15 @@
+/* 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 { hasSyntaxError } from "../validate";
+
+describe("has syntax error", () => {
+ it("should return false", () => {
+ expect(hasSyntaxError("foo")).toEqual(false);
+ });
+
+ it("should return the error object for the invalid expression", () => {
+ expect(hasSyntaxError("foo)(")).toMatchSnapshot();
+ });
+});
diff --git a/devtools/client/debugger/src/workers/parser/utils/ast.js b/devtools/client/debugger/src/workers/parser/utils/ast.js
new file mode 100644
index 0000000000..2adbcd9c7c
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/utils/ast.js
@@ -0,0 +1,225 @@
+/* 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 parseScriptTags from "parse-script-tags";
+import * as babelParser from "@babel/parser";
+import * as t from "@babel/types";
+import { getSource } from "../sources";
+
+let ASTs = new Map();
+
+function _parse(code, opts) {
+ return babelParser.parse(code, {
+ ...opts,
+ tokens: true,
+ });
+}
+
+const sourceOptions = {
+ generated: {
+ sourceType: "unambiguous",
+ tokens: true,
+ plugins: [
+ "classStaticBlock",
+ "classPrivateProperties",
+ "classPrivateMethods",
+ "classProperties",
+ "objectRestSpread",
+ "optionalChaining",
+ "privateIn",
+ "nullishCoalescingOperator",
+ ],
+ },
+ original: {
+ sourceType: "unambiguous",
+ tokens: true,
+ plugins: [
+ "jsx",
+ "flow",
+ "doExpressions",
+ "optionalChaining",
+ "nullishCoalescingOperator",
+ "decorators-legacy",
+ "objectRestSpread",
+ "classStaticBlock",
+ "classPrivateProperties",
+ "classPrivateMethods",
+ "classProperties",
+ "exportDefaultFrom",
+ "exportNamespaceFrom",
+ "asyncGenerators",
+ "functionBind",
+ "functionSent",
+ "dynamicImport",
+ "react-jsx",
+ ],
+ },
+};
+
+export function parse(text, opts) {
+ let ast = {};
+ if (!text) {
+ return ast;
+ }
+
+ try {
+ ast = _parse(text, opts);
+ } catch (error) {
+ console.error(error);
+ }
+
+ return ast;
+}
+
+// Custom parser for parse-script-tags that adapts its input structure to
+// our parser's signature
+function htmlParser({ source, line }) {
+ return parse(source, { startLine: line, ...sourceOptions.generated });
+}
+
+const VUE_COMPONENT_START = /^\s*</;
+function vueParser({ source, line }) {
+ return parse(source, {
+ startLine: line,
+ ...sourceOptions.original,
+ });
+}
+function parseVueScript(code) {
+ if (typeof code !== "string") {
+ return {};
+ }
+
+ let ast;
+
+ // .vue files go through several passes, so while there is a
+ // single-file-component Vue template, there are also generally .vue files
+ // that are still just JS as well.
+ if (code.match(VUE_COMPONENT_START)) {
+ ast = parseScriptTags(code, vueParser);
+ if (t.isFile(ast)) {
+ // parseScriptTags is currently hard-coded to return scripts, but Vue
+ // always expects ESM syntax, so we just hard-code it.
+ ast.program.sourceType = "module";
+ }
+ } else {
+ ast = parse(code, sourceOptions.original);
+ }
+ return ast;
+}
+
+export function parseConsoleScript(text, opts) {
+ try {
+ return _parse(text, {
+ plugins: [
+ "classStaticBlock",
+ "classPrivateProperties",
+ "classPrivateMethods",
+ "objectRestSpread",
+ "dynamicImport",
+ "nullishCoalescingOperator",
+ "optionalChaining",
+ ],
+ ...opts,
+ allowAwaitOutsideFunction: true,
+ });
+ } catch (e) {
+ return null;
+ }
+}
+
+export function parseScript(text, opts) {
+ return _parse(text, opts);
+}
+
+export function getAst(sourceId) {
+ if (ASTs.has(sourceId)) {
+ return ASTs.get(sourceId);
+ }
+
+ const source = getSource(sourceId);
+
+ if (source.isWasm) {
+ return null;
+ }
+
+ let ast = {};
+ const { contentType } = source;
+ if (contentType == "text/html") {
+ ast = parseScriptTags(source.text, htmlParser) || {};
+ } else if (contentType && contentType === "text/vue") {
+ ast = parseVueScript(source.text) || {};
+ } else if (
+ contentType &&
+ contentType.match(/(javascript|jsx)/) &&
+ !contentType.match(/typescript-jsx/)
+ ) {
+ const type = source.id.includes("original") ? "original" : "generated";
+ const options = sourceOptions[type];
+ ast = parse(source.text, options);
+ } else if (contentType && contentType.match(/typescript/)) {
+ const options = {
+ ...sourceOptions.original,
+ plugins: [
+ ...sourceOptions.original.plugins.filter(
+ p =>
+ p !== "flow" &&
+ p !== "decorators" &&
+ p !== "decorators2" &&
+ (p !== "jsx" || contentType.match(/typescript-jsx/))
+ ),
+ "decorators-legacy",
+ "typescript",
+ ],
+ };
+ ast = parse(source.text, options);
+ }
+
+ ASTs.set(source.id, ast);
+ return ast;
+}
+
+export function clearASTs() {
+ ASTs = new Map();
+}
+
+export function traverseAst(sourceId, visitor, state) {
+ const ast = getAst(sourceId);
+ if (!ast || !Object.keys(ast).length) {
+ return null;
+ }
+
+ t.traverse(ast, visitor, state);
+ return ast;
+}
+
+export function hasNode(rootNode, predicate) {
+ try {
+ t.traverse(rootNode, {
+ enter: (node, ancestors) => {
+ if (predicate(node, ancestors)) {
+ throw new Error("MATCH");
+ }
+ },
+ });
+ } catch (e) {
+ if (e.message === "MATCH") {
+ return true;
+ }
+ }
+ return false;
+}
+
+export function replaceNode(ancestors, node) {
+ const parent = ancestors[ancestors.length - 1];
+
+ if (typeof parent.index === "number") {
+ if (Array.isArray(node)) {
+ parent.node[parent.key].splice(parent.index, 1, ...node);
+ } else {
+ parent.node[parent.key][parent.index] = node;
+ }
+ } else {
+ parent.node[parent.key] = node;
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/utils/contains.js b/devtools/client/debugger/src/workers/parser/utils/contains.js
new file mode 100644
index 0000000000..ed4cb31c1d
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/utils/contains.js
@@ -0,0 +1,29 @@
+/* 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 startsBefore(a, b) {
+ let before = a.start.line < b.line;
+ if (a.start.line === b.line) {
+ before =
+ a.start.column >= 0 && b.column >= 0 ? a.start.column <= b.column : true;
+ }
+ return before;
+}
+
+function endsAfter(a, b) {
+ let after = a.end.line > b.line;
+ if (a.end.line === b.line) {
+ after =
+ a.end.column >= 0 && b.column >= 0 ? a.end.column >= b.column : true;
+ }
+ return after;
+}
+
+export function containsPosition(a, b) {
+ return startsBefore(a, b) && endsAfter(a, b);
+}
+
+export function containsLocation(a, b) {
+ return containsPosition(a, b.start) && containsPosition(a, b.end);
+}
diff --git a/devtools/client/debugger/src/workers/parser/utils/formatSymbols.js b/devtools/client/debugger/src/workers/parser/utils/formatSymbols.js
new file mode 100644
index 0000000000..3bcf37e7c4
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/utils/formatSymbols.js
@@ -0,0 +1,65 @@
+/* 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 { getSymbols } from "../getSymbols";
+
+function formatLocation(loc) {
+ if (!loc) {
+ return "";
+ }
+
+ const { start, end } = loc;
+ const startLoc = `(${start.line}, ${start.column})`;
+ const endLoc = `(${end.line}, ${end.column})`;
+
+ return `[${startLoc}, ${endLoc}]`;
+}
+
+function summarize(symbol) {
+ if (typeof symbol == "boolean") {
+ return symbol ? "true" : "false";
+ }
+
+ const loc = formatLocation(symbol.location);
+ const params = symbol.parameterNames
+ ? `(${symbol.parameterNames.join(", ")})`
+ : "";
+ const expression = symbol.expression || "";
+ const klass = symbol.klass || "";
+ const name = symbol.name == undefined ? "" : symbol.name;
+ const names = symbol.specifiers ? symbol.specifiers.join(", ") : "";
+ const values = symbol.values ? symbol.values.join(", ") : "";
+ const index = symbol.index ? symbol.index : "";
+
+ return `${loc} ${expression} ${name}${params} ${klass} ${names} ${values} ${index}`.trim(); // eslint-disable-line max-len
+}
+const bools = ["hasJsx", "hasTypes"];
+const strings = ["framework"];
+function formatBool(name, symbols) {
+ return `${name}: ${symbols[name] ? "true" : "false"}`;
+}
+
+function formatString(name, symbols) {
+ return `${name}: ${symbols[name]}`;
+}
+
+function formatKey(name, symbols) {
+ if (bools.includes(name)) {
+ return formatBool(name, symbols);
+ }
+
+ if (strings.includes(name)) {
+ return formatString(name, symbols);
+ }
+
+ return `${name}:\n${symbols[name].map(summarize).join("\n")}`;
+}
+
+export function formatSymbols(sourceId) {
+ const symbols = getSymbols(sourceId);
+
+ return Object.keys(symbols)
+ .map(name => formatKey(name, symbols))
+ .join("\n\n");
+}
diff --git a/devtools/client/debugger/src/workers/parser/utils/getFunctionName.js b/devtools/client/debugger/src/workers/parser/utils/getFunctionName.js
new file mode 100644
index 0000000000..1fe85a5c69
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/utils/getFunctionName.js
@@ -0,0 +1,96 @@
+/* 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 * as t from "@babel/types";
+
+// Perform ES6's anonymous function name inference for all
+// locations where static analysis is possible.
+// eslint-disable-next-line complexity
+export default function getFunctionName(node, parent) {
+ if (t.isIdentifier(node.id)) {
+ return node.id.name;
+ }
+
+ if (
+ t.isObjectMethod(node, { computed: false }) ||
+ t.isClassMethod(node, { computed: false }) ||
+ t.isClassPrivateMethod(node)
+ ) {
+ const { key } = node;
+
+ if (t.isIdentifier(key)) {
+ return key.name;
+ }
+ if (t.isStringLiteral(key)) {
+ return key.value;
+ }
+ if (t.isNumericLiteral(key)) {
+ return `${key.value}`;
+ }
+
+ if (t.isPrivateName(key)) {
+ return `#${key.id.name}`;
+ }
+ }
+
+ if (
+ t.isObjectProperty(parent, { computed: false, value: node }) ||
+ // TODO: Babylon 6 doesn't support computed class props. It is included
+ // here so that it is most flexible. Once Babylon 7 is used, this
+ // can change to use computed: false like ObjectProperty.
+ (t.isClassProperty(parent, { value: node }) && !parent.computed) ||
+ (t.isClassPrivateProperty(parent, { value: node }) && !parent.computed)
+ ) {
+ const { key } = parent;
+
+ if (t.isIdentifier(key)) {
+ return key.name;
+ }
+ if (t.isStringLiteral(key)) {
+ return key.value;
+ }
+ if (t.isNumericLiteral(key)) {
+ return `${key.value}`;
+ }
+
+ if (t.isPrivateName(key)) {
+ return `#${key.id.name}`;
+ }
+ }
+
+ if (t.isAssignmentExpression(parent, { operator: "=", right: node })) {
+ if (t.isIdentifier(parent.left)) {
+ return parent.left.name;
+ }
+
+ // This case is not supported in standard ES6 name inference, but it
+ // is included here since it is still a helpful case during debugging.
+ if (t.isMemberExpression(parent.left, { computed: false })) {
+ return parent.left.property.name;
+ }
+ }
+
+ if (
+ t.isAssignmentPattern(parent, { right: node }) &&
+ t.isIdentifier(parent.left)
+ ) {
+ return parent.left.name;
+ }
+
+ if (
+ t.isVariableDeclarator(parent, { init: node }) &&
+ t.isIdentifier(parent.id)
+ ) {
+ return parent.id.name;
+ }
+
+ if (
+ t.isExportDefaultDeclaration(parent, { declaration: node }) &&
+ t.isFunctionDeclaration(node)
+ ) {
+ return "default";
+ }
+
+ return "anonymous";
+}
diff --git a/devtools/client/debugger/src/workers/parser/utils/helpers.js b/devtools/client/debugger/src/workers/parser/utils/helpers.js
new file mode 100644
index 0000000000..0850ea678c
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/utils/helpers.js
@@ -0,0 +1,230 @@
+/* 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 * as t from "@babel/types";
+import generate from "@babel/generator";
+
+export function isFunction(node) {
+ return (
+ t.isFunction(node) ||
+ t.isArrowFunctionExpression(node) ||
+ t.isObjectMethod(node) ||
+ t.isClassMethod(node)
+ );
+}
+
+export function isAwaitExpression(path) {
+ const { node, parent } = path;
+ return (
+ t.isAwaitExpression(node) ||
+ t.isAwaitExpression(parent.init) ||
+ t.isAwaitExpression(parent)
+ );
+}
+
+export function isYieldExpression(path) {
+ const { node, parent } = path;
+ return (
+ t.isYieldExpression(node) ||
+ t.isYieldExpression(parent.init) ||
+ t.isYieldExpression(parent)
+ );
+}
+
+export function isObjectShorthand(parent) {
+ if (!t.isObjectProperty(parent)) {
+ return false;
+ }
+
+ if (parent.value && parent.value.left) {
+ return (
+ parent.value.type === "AssignmentPattern" &&
+ parent.value.left.type === "Identifier"
+ );
+ }
+
+ return (
+ parent.value &&
+ parent.key.start == parent.value.start &&
+ parent.key.loc.identifierName === parent.value.loc.identifierName
+ );
+}
+
+export function getObjectExpressionValue(node) {
+ const { value } = node;
+
+ if (t.isIdentifier(value)) {
+ return value.name;
+ }
+
+ if (t.isCallExpression(value) || t.isFunctionExpression(value)) {
+ return "";
+ }
+ const code = generate(value).code;
+
+ const shouldWrap = t.isObjectExpression(value);
+ return shouldWrap ? `(${code})` : code;
+}
+
+export function getCode(node) {
+ return generate(node).code;
+}
+
+export function getComments(ast) {
+ if (!ast || !ast.comments) {
+ return [];
+ }
+ return ast.comments.map(comment => ({
+ name: comment.location,
+ location: comment.loc,
+ }));
+}
+
+export function getSpecifiers(specifiers) {
+ if (!specifiers) {
+ return [];
+ }
+
+ return specifiers.map(specifier => specifier.local?.name);
+}
+
+export function isComputedExpression(expression) {
+ return /^\[/m.test(expression);
+}
+
+export function getMemberExpression(root) {
+ function _getMemberExpression(node, expr) {
+ if (t.isMemberExpression(node)) {
+ expr = [node.property.name].concat(expr);
+ return _getMemberExpression(node.object, expr);
+ }
+
+ if (t.isCallExpression(node)) {
+ return [];
+ }
+
+ if (t.isThisExpression(node)) {
+ return ["this"].concat(expr);
+ }
+
+ return [node.name].concat(expr);
+ }
+
+ const expr = _getMemberExpression(root, []);
+ return expr.join(".");
+}
+
+export function getVariables(dec) {
+ if (!dec.id) {
+ return [];
+ }
+
+ if (t.isArrayPattern(dec.id)) {
+ if (!dec.id.elements) {
+ return [];
+ }
+
+ // NOTE: it's possible that an element is empty or has several variables
+ // e.g. const [, a] = arr
+ // e.g. const [{a, b }] = 2
+ return dec.id.elements
+ .filter(Boolean)
+ .map(element => ({
+ name: t.isAssignmentPattern(element)
+ ? element.left.name
+ : element.name || element.argument?.name,
+ location: element.loc,
+ }))
+ .filter(({ name }) => name);
+ }
+
+ return [
+ {
+ name: dec.id.name,
+ location: dec.loc,
+ },
+ ];
+}
+
+export function getPatternIdentifiers(pattern) {
+ let items = [];
+ if (t.isObjectPattern(pattern)) {
+ items = pattern.properties.map(({ value }) => value);
+ }
+
+ if (t.isArrayPattern(pattern)) {
+ items = pattern.elements;
+ }
+
+ return getIdentifiers(items);
+}
+
+function getIdentifiers(items) {
+ let ids = [];
+ items.forEach(function (item) {
+ if (t.isObjectPattern(item) || t.isArrayPattern(item)) {
+ ids = ids.concat(getPatternIdentifiers(item));
+ } else if (t.isIdentifier(item)) {
+ const { start, end } = item.loc;
+ ids.push({
+ name: item.name,
+ expression: item.name,
+ location: { start, end },
+ });
+ }
+ });
+ return ids;
+}
+
+// Top Level checks the number of "body" nodes in the ancestor chain
+// if the node is top-level, then it shoul only have one body.
+export function isTopLevel(ancestors) {
+ return ancestors.filter(ancestor => ancestor.key == "body").length == 1;
+}
+
+export function nodeLocationKey(a) {
+ const { start, end } = a.location;
+ return `${start.line}:${start.column}:${end.line}:${end.column}`;
+}
+
+export function getFunctionParameterNames(path) {
+ if (path.node.params != null) {
+ return path.node.params.map(param => {
+ if (param.type !== "AssignmentPattern") {
+ return param.name;
+ }
+
+ // Parameter with default value
+ if (
+ param.left.type === "Identifier" &&
+ param.right.type === "Identifier"
+ ) {
+ return `${param.left.name} = ${param.right.name}`;
+ } else if (
+ param.left.type === "Identifier" &&
+ param.right.type === "StringLiteral"
+ ) {
+ return `${param.left.name} = ${param.right.value}`;
+ } else if (
+ param.left.type === "Identifier" &&
+ param.right.type === "ObjectExpression"
+ ) {
+ return `${param.left.name} = {}`;
+ } else if (
+ param.left.type === "Identifier" &&
+ param.right.type === "ArrayExpression"
+ ) {
+ return `${param.left.name} = []`;
+ } else if (
+ param.left.type === "Identifier" &&
+ param.right.type === "NullLiteral"
+ ) {
+ return `${param.left.name} = null`;
+ }
+
+ return null;
+ });
+ }
+ return [];
+}
diff --git a/devtools/client/debugger/src/workers/parser/utils/inferClassName.js b/devtools/client/debugger/src/workers/parser/utils/inferClassName.js
new file mode 100644
index 0000000000..09d25f275d
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/utils/inferClassName.js
@@ -0,0 +1,93 @@
+/* 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 * as t from "@babel/types";
+
+// the function class is inferred from a call like
+// createClass or extend
+function fromCallExpression(callExpression) {
+ const allowlist = ["extend", "createClass"];
+ const { callee } = callExpression.node;
+ if (!callee) {
+ return null;
+ }
+
+ const name = t.isMemberExpression(callee)
+ ? callee.property.name
+ : callee.name;
+
+ if (!allowlist.includes(name)) {
+ return null;
+ }
+
+ const variable = callExpression.findParent(p =>
+ t.isVariableDeclarator(p.node)
+ );
+ if (variable) {
+ return variable.node.id.name;
+ }
+
+ const assignment = callExpression.findParent(p =>
+ t.isAssignmentExpression(p.node)
+ );
+
+ if (!assignment) {
+ return null;
+ }
+
+ const { left } = assignment.node;
+
+ if (left.name) {
+ return name;
+ }
+
+ if (t.isMemberExpression(left)) {
+ return left.property.name;
+ }
+
+ return null;
+}
+
+// the function class is inferred from a prototype assignment
+// e.g. TodoClass.prototype.render = function() {}
+function fromPrototype(assignment) {
+ const { left } = assignment.node;
+ if (!left) {
+ return null;
+ }
+
+ if (
+ t.isMemberExpression(left) &&
+ left.object &&
+ t.isMemberExpression(left.object) &&
+ left.object.property.identifier === "prototype"
+ ) {
+ return left.object.object.name;
+ }
+
+ return null;
+}
+
+// infer class finds an appropriate class for functions
+// that are defined inside of a class like thing.
+// e.g. `class Foo`, `TodoClass.prototype.foo`,
+// `Todo = createClass({ foo: () => {}})`
+export function inferClassName(path) {
+ const classDeclaration = path.findParent(p => t.isClassDeclaration(p.node));
+ if (classDeclaration) {
+ return classDeclaration.node.id.name;
+ }
+
+ const callExpression = path.findParent(p => t.isCallExpression(p.node));
+ if (callExpression) {
+ return fromCallExpression(callExpression);
+ }
+
+ const assignment = path.findParent(p => t.isAssignmentExpression(p.node));
+ if (assignment) {
+ return fromPrototype(assignment);
+ }
+
+ return null;
+}
diff --git a/devtools/client/debugger/src/workers/parser/utils/simple-path.js b/devtools/client/debugger/src/workers/parser/utils/simple-path.js
new file mode 100644
index 0000000000..c167103566
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/utils/simple-path.js
@@ -0,0 +1,147 @@
+/* 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/>. */
+
+export default function createSimplePath(ancestors) {
+ if (ancestors.length === 0) {
+ return null;
+ }
+
+ // Slice the array because babel-types traverse may continue mutating
+ // the ancestors array in later traversal logic.
+ return new SimplePath(ancestors.slice());
+}
+
+/**
+ * Mimics @babel/traverse's NodePath API in a simpler fashion that isn't as
+ * heavy, but still allows the ease of passing paths around to process nested
+ * AST structures.
+ */
+class SimplePath {
+ _index;
+ _ancestors;
+ _ancestor;
+
+ _parentPath;
+
+ constructor(ancestors, index = ancestors.length - 1) {
+ if (index < 0 || index >= ancestors.length) {
+ console.error(ancestors);
+ throw new Error("Created invalid path");
+ }
+
+ this._ancestors = ancestors;
+ this._ancestor = ancestors[index];
+ this._index = index;
+ }
+
+ get parentPath() {
+ let path = this._parentPath;
+ if (path === undefined) {
+ if (this._index === 0) {
+ path = null;
+ } else {
+ path = new SimplePath(this._ancestors, this._index - 1);
+ }
+ this._parentPath = path;
+ }
+
+ return path;
+ }
+
+ get parent() {
+ return this._ancestor.node;
+ }
+
+ get node() {
+ const { node, key, index } = this._ancestor;
+
+ if (typeof index === "number") {
+ return node[key][index];
+ }
+
+ return node[key];
+ }
+
+ get key() {
+ return this._ancestor.key;
+ }
+
+ set node(replacement) {
+ if (this.type !== "Identifier") {
+ throw new Error(
+ "Replacing anything other than leaf nodes is undefined behavior " +
+ "in t.traverse()"
+ );
+ }
+
+ const { node, key, index } = this._ancestor;
+ if (typeof index === "number") {
+ node[key][index] = replacement;
+ } else {
+ node[key] = replacement;
+ }
+ }
+
+ get type() {
+ return this.node.type;
+ }
+
+ get inList() {
+ return typeof this._ancestor.index === "number";
+ }
+
+ get containerIndex() {
+ const { index } = this._ancestor;
+
+ if (typeof index !== "number") {
+ throw new Error("Cannot get index of non-array node");
+ }
+
+ return index;
+ }
+
+ get depth() {
+ return this._index;
+ }
+
+ replace(node) {
+ this.node = node;
+ }
+
+ find(predicate) {
+ for (let path = this; path; path = path.parentPath) {
+ if (predicate(path)) {
+ return path;
+ }
+ }
+ return null;
+ }
+
+ findParent(predicate) {
+ if (!this.parentPath) {
+ throw new Error("Cannot use findParent on root path");
+ }
+
+ return this.parentPath.find(predicate);
+ }
+
+ getSibling(offset) {
+ const { node, key, index } = this._ancestor;
+
+ if (typeof index !== "number") {
+ throw new Error("Non-array nodes do not have siblings");
+ }
+
+ const container = node[key];
+
+ const siblingIndex = index + offset;
+ if (siblingIndex < 0 || siblingIndex >= container.length) {
+ return null;
+ }
+
+ return new SimplePath(
+ this._ancestors.slice(0, -1).concat([{ node, key, index: siblingIndex }])
+ );
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/utils/tests/ast.spec.js b/devtools/client/debugger/src/workers/parser/utils/tests/ast.spec.js
new file mode 100644
index 0000000000..e8d2964205
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/utils/tests/ast.spec.js
@@ -0,0 +1,41 @@
+/* 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 { getAst } from "../ast";
+import { setSource } from "../../sources";
+import cases from "jest-in-case";
+
+import { makeMockSourceAndContent } from "../../../../utils/test-mockup";
+
+const astKeys = [
+ "type",
+ "start",
+ "end",
+ "loc",
+ "errors",
+ "program",
+ "comments",
+ "tokens",
+];
+
+cases(
+ "ast.getAst",
+ ({ name }) => {
+ const source = makeMockSourceAndContent(undefined, "foo", name, "2");
+ setSource({
+ id: source.id,
+ text: source.content.value || "",
+ contentType: source.content.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" },
+ ]
+);
diff --git a/devtools/client/debugger/src/workers/parser/validate.js b/devtools/client/debugger/src/workers/parser/validate.js
new file mode 100644
index 0000000000..d01e76668a
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/validate.js
@@ -0,0 +1,14 @@
+/* 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 { parseScript } from "./utils/ast";
+
+export function hasSyntaxError(input) {
+ try {
+ parseScript(input);
+ return false;
+ } catch (e) {
+ return `${e.name} : ${e.message}`;
+ }
+}
diff --git a/devtools/client/debugger/src/workers/parser/worker.js b/devtools/client/debugger/src/workers/parser/worker.js
new file mode 100644
index 0000000000..caa49cd482
--- /dev/null
+++ b/devtools/client/debugger/src/workers/parser/worker.js
@@ -0,0 +1,30 @@
+/* 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 { getSymbols, clearSymbols } from "./getSymbols";
+import { clearASTs } from "./utils/ast";
+import getScopes, { clearScopes } from "./getScopes";
+import { setSource, clearSources } from "./sources";
+import findOutOfScopeLocations from "./findOutOfScopeLocations";
+import { hasSyntaxError } from "./validate";
+import mapExpression from "./mapExpression";
+
+import { workerHandler } from "../../../../shared/worker-utils";
+
+function clearState() {
+ clearASTs();
+ clearScopes();
+ clearSources();
+ clearSymbols();
+}
+
+self.onmessage = workerHandler({
+ findOutOfScopeLocations,
+ getSymbols,
+ getScopes,
+ clearState,
+ hasSyntaxError,
+ mapExpression,
+ setSource,
+});