(text, options, decoratedComments, commentIndex)
| 263 | |
| 264 | const isAllEmptyAndNoLineBreak = (text) => !/[\S\n\u2028\u2029]/.test(text); |
| 265 | function isOwnLineComment(text, options, decoratedComments, commentIndex) { |
| 266 | const { comment, precedingNode } = decoratedComments[commentIndex]; |
| 267 | const { locStart, locEnd } = options; |
| 268 | let start = locStart(comment); |
| 269 | |
| 270 | if (precedingNode) { |
| 271 | // Find first comment on the same line |
| 272 | for (let index = commentIndex - 1; index >= 0; index--) { |
| 273 | const { comment, precedingNode: currentCommentPrecedingNode } = |
| 274 | decoratedComments[index]; |
| 275 | if ( |
| 276 | currentCommentPrecedingNode !== precedingNode || |
| 277 | !isAllEmptyAndNoLineBreak(text.slice(locEnd(comment), start)) |
| 278 | ) { |
| 279 | break; |
| 280 | } |
| 281 | start = locStart(comment); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | return hasNewline(text, start, { backwards: true }); |
| 286 | } |
| 287 | |
| 288 | function isEndOfLineComment(text, options, decoratedComments, commentIndex) { |
| 289 | const { comment, followingNode } = decoratedComments[commentIndex]; |
no test coverage detected
searching dependent graphs…