项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

47 lines
1.5 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
  6. exports.addComment = addComment;
  7. exports.addComments = addComments;
  8. function t() {
  9. var data = _interopRequireWildcard(require("@babel/types"));
  10. t = function t() {
  11. return data;
  12. };
  13. return data;
  14. }
  15. 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; } }
  16. function shareCommentsWithSiblings() {
  17. if (typeof this.key === "string") return;
  18. var node = this.node;
  19. if (!node) return;
  20. var trailing = node.trailingComments;
  21. var leading = node.leadingComments;
  22. if (!trailing && !leading) return;
  23. var prev = this.getSibling(this.key - 1);
  24. var next = this.getSibling(this.key + 1);
  25. var hasPrev = Boolean(prev.node);
  26. var hasNext = Boolean(next.node);
  27. if (hasPrev && hasNext) {} else if (hasPrev) {
  28. prev.addComments("trailing", trailing);
  29. } else if (hasNext) {
  30. next.addComments("leading", leading);
  31. }
  32. }
  33. function addComment(type, content, line) {
  34. t().addComment(this.node, type, content, line);
  35. }
  36. function addComments(type, comments) {
  37. t().addComments(this.node, type, comments);
  38. }