* @param {AstPath} path * @param {*} options * @param {*} print * @param {*} [args] * @returns {Doc}
(path, options, print, args)
| 58 | * @returns {Doc} |
| 59 | */ |
| 60 | function print(path, options, print, args) { |
| 61 | if (path.isRoot) { |
| 62 | options.__onHtmlBindingRoot?.(path.node, options); |
| 63 | } |
| 64 | |
| 65 | const { node } = path; |
| 66 | |
| 67 | let doc = isIgnored(path) |
| 68 | ? printIgnored(path, options) |
| 69 | : printWithoutParentheses(path, options, print, args); |
| 70 | if (!doc) { |
| 71 | return ""; |
| 72 | } |
| 73 | |
| 74 | if (shouldPrintDirectly(node)) { |
| 75 | return doc; |
| 76 | } |
| 77 | |
| 78 | doc = printCommentsForFunction(path, options, doc); |
| 79 | |
| 80 | const decoratorsDoc = |
| 81 | // `ClassExpression` prints own decorators |
| 82 | node.type !== "ClassExpression" && isNonEmptyArray(node.decorators) |
| 83 | ? printDecorators(path, options, print) |
| 84 | : ""; |
| 85 | |
| 86 | const needsParens = needsParentheses(path, options); |
| 87 | |
| 88 | if (!decoratorsDoc && !needsParens) { |
| 89 | return doc; |
| 90 | } |
| 91 | |
| 92 | return inheritLabel(doc, (doc) => [ |
| 93 | needsParens ? "(" : "", |
| 94 | decoratorsDoc ? group([decoratorsDoc, doc]) : doc, |
| 95 | needsParens ? ")" : "", |
| 96 | ]); |
| 97 | } |
| 98 | |
| 99 | function printCommentsForFunction(path, options, doc) { |
| 100 | const { node } = path; |
no test coverage detected
searching dependent graphs…