source: trip-planner-front/node_modules/@babel/traverse/lib/path/removal.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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