source: trip-planner-front/node_modules/@babel/traverse/lib/path/comments.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.0 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
7exports.addComment = addComment;
8exports.addComments = addComments;
9
10var _t = require("@babel/types");
11
12const {
13 addComment: _addComment,
14 addComments: _addComments
15} = _t;
16
17function shareCommentsWithSiblings() {
18 if (typeof this.key === "string") return;
19 const node = this.node;
20 if (!node) return;
21 const trailing = node.trailingComments;
22 const leading = node.leadingComments;
23 if (!trailing && !leading) return;
24 const prev = this.getSibling(this.key - 1);
25 const next = this.getSibling(this.key + 1);
26 const hasPrev = Boolean(prev.node);
27 const hasNext = Boolean(next.node);
28
29 if (hasPrev && !hasNext) {
30 prev.addComments("trailing", trailing);
31 } else if (hasNext && !hasPrev) {
32 next.addComments("leading", leading);
33 }
34}
35
36function addComment(type, content, line) {
37 _addComment(this.node, type, content, line);
38}
39
40function addComments(type, comments) {
41 _addComments(this.node, type, comments);
42}
Note: See TracBrowser for help on using the repository browser.