(commentPath: any, print: any)
| 298 | } |
| 299 | |
| 300 | function printTrailingComment(commentPath: any, print: any) { |
| 301 | const comment = commentPath.getValue(commentPath); |
| 302 | n.Comment.assert(comment); |
| 303 | |
| 304 | const loc = comment.loc; |
| 305 | const lines = loc && loc.lines; |
| 306 | const parts = []; |
| 307 | |
| 308 | if (lines instanceof Lines) { |
| 309 | const fromPos = lines.skipSpaces(loc.start, true) || lines.firstPos(); |
| 310 | const leadingSpace = lines.slice(fromPos, loc.start); |
| 311 | |
| 312 | if (leadingSpace.length === 1) { |
| 313 | // If the leading space contains no newlines, then we want to |
| 314 | // preserve it exactly as we found it. |
| 315 | parts.push(leadingSpace); |
| 316 | } else { |
| 317 | // If the leading space contains newlines, then replace it |
| 318 | // with just that many newlines, sans all other spaces. |
| 319 | parts.push(new Array(leadingSpace.length).join("\n")); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | parts.push(print(commentPath)); |
| 324 | |
| 325 | return concat(parts); |
| 326 | } |
| 327 | |
| 328 | export function printComments(path: any, print: any) { |
| 329 | const value = path.getValue(); |
no test coverage detected
searching dependent graphs…