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

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.8 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");
17const {
18 getBindingIdentifiers
19} = _t;
20function remove() {
21 var _this$opts;
22 _assertUnremoved.call(this);
23 this.resync();
24 if (_callRemovalHooks.call(this)) {
25 _markRemoved.call(this);
26 return;
27 }
28 if (!((_this$opts = this.opts) != null && _this$opts.noScope)) {
29 _removeFromScope.call(this);
30 }
31 this.shareCommentsWithSiblings();
32 _remove.call(this);
33 _markRemoved.call(this);
34}
35function _removeFromScope() {
36 const bindings = getBindingIdentifiers(this.node, false, false, true);
37 Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
38}
39function _callRemovalHooks() {
40 if (this.parentPath) {
41 for (const fn of _removalHooks.hooks) {
42 if (fn(this, this.parentPath)) return true;
43 }
44 }
45}
46function _remove() {
47 if (Array.isArray(this.container)) {
48 this.container.splice(this.key, 1);
49 this.updateSiblingKeys(this.key, -1);
50 } else {
51 _replacement._replaceWith.call(this, null);
52 }
53}
54function _markRemoved() {
55 this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
56 if (this.parent) {
57 (0, _cache.getCachedPaths)(this.hub, this.parent).delete(this.node);
58 }
59 this.node = null;
60}
61function _assertUnremoved() {
62 if (this.removed) {
63 throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
64 }
65}
66
67//# sourceMappingURL=removal.js.map
Note: See TracBrowser for help on using the repository browser.