1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = undefined;
|
7 |
|
8 | var _escope = require('escope');
|
9 |
|
10 | var _functionType = require('./utils/functionType');
|
11 |
|
12 | var emptyFn = function emptyFn() {};
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | function withScope(ast, _ref) {
|
30 | var _ref$enter = _ref.enter,
|
31 | _enter = _ref$enter === undefined ? emptyFn : _ref$enter;
|
32 |
|
33 | var scopeManager = (0, _escope.analyze)(ast, { ecmaVersion: 6, sourceType: 'module' });
|
34 | var currentScope = scopeManager.acquire(ast);
|
35 |
|
36 | return {
|
37 | enter: function enter(node, parent) {
|
38 | if ((0, _functionType.isFunction)(node)) {
|
39 | currentScope = scopeManager.acquire(node);
|
40 | }
|
41 | return _enter.call(this, node, parent, currentScope);
|
42 | }
|
43 |
|
44 |
|
45 |
|
46 | };
|
47 | }
|
48 | exports.default = withScope;
|
49 | module.exports = exports['default']; |
\ | No newline at end of file |