(path: any, print: any)
| 326 | } |
| 327 | |
| 328 | export function printComments(path: any, print: any) { |
| 329 | const value = path.getValue(); |
| 330 | const innerLines = print(path); |
| 331 | const comments = |
| 332 | n.Node.check(value) && types.getFieldValue(value, "comments"); |
| 333 | |
| 334 | if (!comments || comments.length === 0) { |
| 335 | return innerLines; |
| 336 | } |
| 337 | |
| 338 | const leadingParts: any[] = []; |
| 339 | const trailingParts = [innerLines]; |
| 340 | |
| 341 | path.each(function (commentPath: any) { |
| 342 | const comment = commentPath.getValue(); |
| 343 | const leading = types.getFieldValue(comment, "leading"); |
| 344 | const trailing = types.getFieldValue(comment, "trailing"); |
| 345 | |
| 346 | if ( |
| 347 | leading || |
| 348 | (trailing && |
| 349 | !( |
| 350 | n.Statement.check(value) || |
| 351 | comment.type === "Block" || |
| 352 | comment.type === "CommentBlock" |
| 353 | )) |
| 354 | ) { |
| 355 | leadingParts.push(printLeadingComment(commentPath, print)); |
| 356 | } else if (trailing) { |
| 357 | trailingParts.push(printTrailingComment(commentPath, print)); |
| 358 | } |
| 359 | }, "comments"); |
| 360 | |
| 361 | leadingParts.push.apply(leadingParts, trailingParts); |
| 362 | return concat(leadingParts); |
| 363 | } |
no test coverage detected
searching dependent graphs…