source: frontend/node_modules/@babel/traverse/lib/scope/traverseForScope.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.8 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = traverseForScope;
7var _t = require("@babel/types");
8var _index = require("../index.js");
9var _visitors = require("../visitors.js");
10var _context = require("../path/context.js");
11const {
12 VISITOR_KEYS
13} = _t;
14function traverseForScope(path, visitors, state) {
15 const exploded = (0, _visitors.explode)(visitors);
16 if (exploded.enter || exploded.exit) {
17 throw new Error("Should not be used with enter/exit visitors.");
18 }
19 _traverse(path.parentPath, path.parent, path.node, path.container, path.key, path.listKey, path.hub, path);
20 function _traverse(parentPath, parent, node, container, key, listKey, hub, inPath) {
21 if (!node) {
22 return;
23 }
24 const path = inPath || _index.NodePath.get({
25 hub,
26 parentPath,
27 parent,
28 container,
29 listKey,
30 key
31 });
32 _context._forceSetScope.call(path);
33 const visitor = exploded[node.type];
34 if (visitor != null && visitor.enter) {
35 for (const visit of visitor.enter) {
36 visit.call(state, path, state);
37 }
38 }
39 if (path.shouldSkip) {
40 return;
41 }
42 const keys = VISITOR_KEYS[node.type];
43 if (!(keys != null && keys.length)) {
44 return;
45 }
46 for (const key of keys) {
47 const prop = node[key];
48 if (!prop) continue;
49 if (Array.isArray(prop)) {
50 for (let i = 0; i < prop.length; i++) {
51 const value = prop[i];
52 _traverse(path, node, value, prop, i, key);
53 }
54 } else {
55 _traverse(path, node, prop, node, key, null);
56 }
57 }
58 if (visitor != null && visitor.exit) {
59 for (const visit of visitor.exit) {
60 visit.call(state, path, state);
61 }
62 }
63 }
64}
65
66//# sourceMappingURL=traverseForScope.js.map
Note: See TracBrowser for help on using the repository browser.