MCPcopy
hub / github.com/prettier/prettier / isEndOfLineComment

Function isEndOfLineComment

src/main/comments/attach.js:288–313  ·  view source on GitHub ↗
(text, options, decoratedComments, commentIndex)

Source from the content-addressed store, hash-verified

286}
287
288function isEndOfLineComment(text, options, decoratedComments, commentIndex) {
289 const { comment, followingNode } = decoratedComments[commentIndex];
290 const { locStart, locEnd } = options;
291 let end = locEnd(comment);
292
293 if (followingNode) {
294 // Find last comment on the same line
295 for (
296 let index = commentIndex + 1;
297 index < decoratedComments.length;
298 index++
299 ) {
300 const { comment, followingNode: currentCommentFollowingNode } =
301 decoratedComments[index];
302 if (
303 currentCommentFollowingNode !== followingNode ||
304 !isAllEmptyAndNoLineBreak(text.slice(end, locStart(comment)))
305 ) {
306 break;
307 }
308 end = locEnd(comment);
309 }
310 }
311
312 return hasNewline(text, end);
313}
314
315function breakTies(tiesToBreak, options) {
316 const tieCount = tiesToBreak.length;

Callers 1

attachCommentsFunction · 0.85

Calls 4

isAllEmptyAndNoLineBreakFunction · 0.85
hasNewlineFunction · 0.85
locEndFunction · 0.50
locStartFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…