1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/@babel/traverse/lib/path/comments.js

47 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2023-12-18 13:12:25 +08:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
exports.addComment = addComment;
exports.addComments = addComments;
function t() {
2024-01-16 21:26:16 +08:00
var data = _interopRequireWildcard(require("@babel/types"));
2023-12-18 13:12:25 +08:00
2024-01-16 21:26:16 +08:00
t = function t() {
2023-12-18 13:12:25 +08:00
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function shareCommentsWithSiblings() {
if (typeof this.key === "string") return;
2024-01-16 21:26:16 +08:00
var node = this.node;
2023-12-18 13:12:25 +08:00
if (!node) return;
2024-01-16 21:26:16 +08:00
var trailing = node.trailingComments;
var leading = node.leadingComments;
2023-12-18 13:12:25 +08:00
if (!trailing && !leading) return;
2024-01-16 21:26:16 +08:00
var prev = this.getSibling(this.key - 1);
var next = this.getSibling(this.key + 1);
var hasPrev = Boolean(prev.node);
var hasNext = Boolean(next.node);
2023-12-18 13:12:25 +08:00
if (hasPrev && hasNext) {} else if (hasPrev) {
prev.addComments("trailing", trailing);
} else if (hasNext) {
next.addComments("leading", leading);
}
}
function addComment(type, content, line) {
t().addComment(this.node, type, content, line);
}
function addComments(type, comments) {
t().addComments(this.node, type, comments);
}