source: imaps-frontend/node_modules/@babel/traverse/lib/path/removal.js@ 0c6b92a

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports._assertUnremoved = _assertUnremoved;
7exports._callRemovalHooks = _callRemovalHooks;
8exports._markRemoved = _markRemoved;
9exports._remove = _remove;
10exports._removeFromScope = _removeFromScope;
11exports.remove = remove;
12var _removalHooks = require("./lib/removal-hooks.js");
13var _cache = require("../cache.js");
14var _replacement = require("./replacement.js");
15var _index = require("./index.js");
16var _t = require("@babel/types");
17var _modification = require("./modification.js");
18var _context = require("./context.js");
19const {
20 getBindingIdentifiers
21} = _t;
22function remove() {
23 var _this$opts;
24 _assertUnremoved.call(this);
25 _context.resync.call(this);
26 if (_callRemovalHooks.call(this)) {
27 _markRemoved.call(this);
28 return;
29 }
30 if (!((_this$opts = this.opts) != null && _this$opts.noScope)) {
31 _removeFromScope.call(this);
32 }
33 this.shareCommentsWithSiblings();
34 _remove.call(this);
35 _markRemoved.call(this);
36}
37function _removeFromScope() {
38 const bindings = getBindingIdentifiers(this.node, false, false, true);
39 Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
40}
41function _callRemovalHooks() {
42 if (this.parentPath) {
43 for (const fn of _removalHooks.hooks) {
44 if (fn(this, this.parentPath)) return true;
45 }
46 }
47}
48function _remove() {
49 if (Array.isArray(this.container)) {
50 this.container.splice(this.key, 1);
51 _modification.updateSiblingKeys.call(this, this.key, -1);
52 } else {
53 _replacement._replaceWith.call(this, null);
54 }
55}
56function _markRemoved() {
57 this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
58 if (this.parent) {
59 (0, _cache.getCachedPaths)(this.hub, this.parent).delete(this.node);
60 }
61 this.node = null;
62}
63function _assertUnremoved() {
64 if (this.removed) {
65 throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
66 }
67}
68
69//# sourceMappingURL=removal.js.map
Note: See TracBrowser for help on using the repository browser.