(path, options, printPath, args, embeds)
| 102 | } |
| 103 | |
| 104 | function callPluginPrintFunction(path, options, printPath, args, embeds) { |
| 105 | const { node } = path; |
| 106 | const { printer } = options; |
| 107 | |
| 108 | let doc; |
| 109 | |
| 110 | // Escape hatch |
| 111 | if (printer.hasPrettierIgnore?.(path)) { |
| 112 | doc = printIgnored(path, options, printPath, args); |
| 113 | } else if (embeds.has(node)) { |
| 114 | doc = embeds.get(node); |
| 115 | } else { |
| 116 | doc = printer.print(path, options, printPath, args); |
| 117 | } |
| 118 | |
| 119 | switch (node) { |
| 120 | case options.cursorNode: |
| 121 | doc = inheritLabel(doc, (doc) => [cursor, doc, cursor]); |
| 122 | break; |
| 123 | case options.nodeBeforeCursor: |
| 124 | doc = inheritLabel(doc, (doc) => [doc, cursor]); |
| 125 | break; |
| 126 | case options.nodeAfterCursor: |
| 127 | doc = inheritLabel(doc, (doc) => [cursor, doc]); |
| 128 | break; |
| 129 | } |
| 130 | |
| 131 | // We let JSXElement print its comments itself because it adds () around |
| 132 | // UnionTypeAnnotation has to align the child without the comments |
| 133 | if ( |
| 134 | printer.printComment && |
| 135 | isNonEmptyArray(node.comments) && |
| 136 | !printer.willPrintOwnComments?.(path, options) |
| 137 | ) { |
| 138 | // printComments will call the plugin print function and check for |
| 139 | // comments to print |
| 140 | doc = printComments(path, doc, options); |
| 141 | } |
| 142 | |
| 143 | return doc; |
| 144 | } |
| 145 | |
| 146 | async function prepareToPrint(ast, options) { |
| 147 | const comments = ast.comments ?? []; |
no test coverage detected
searching dependent graphs…