( line: string, lines: string[], lineIndex: number, )
| 68 | } |
| 69 | |
| 70 | function extractCommentFromLine( |
| 71 | line: string, |
| 72 | lines: string[], |
| 73 | lineIndex: number, |
| 74 | ): { |
| 75 | hint: string | null; |
| 76 | lineIndex: number; |
| 77 | endIndex: number; |
| 78 | isInline: boolean; |
| 79 | } { |
| 80 | const trimmed = line.trim(); |
| 81 | |
| 82 | // Single-line comment (standalone) |
| 83 | if (trimmed.startsWith("//")) { |
| 84 | const hint = trimmed.replace(/^\/\/\s*/, "").trim(); |
| 85 | return { hint, lineIndex, endIndex: lineIndex, isInline: false }; |
| 86 | } |
| 87 | |
| 88 | // Block comment (standalone or multi-line) |
| 89 | if (trimmed.startsWith("/*")) { |
| 90 | const blockResult = extractBlockComment(lines, lineIndex); |
| 91 | return { ...blockResult, isInline: false }; |
| 92 | } |
| 93 | |
| 94 | // Inline comments (after JSON content) |
| 95 | // Handle single-line inline comments |
| 96 | const singleInlineMatch = line.match(/^(.+?)\s*\/\/\s*(.+)$/); |
| 97 | if (singleInlineMatch && singleInlineMatch[1].includes(":")) { |
| 98 | const hint = singleInlineMatch[2].trim(); |
| 99 | return { hint, lineIndex, endIndex: lineIndex, isInline: true }; |
| 100 | } |
| 101 | |
| 102 | // Handle block inline comments |
| 103 | const blockInlineMatch = line.match(/^(.+?)\s*\/\*\s*(.*?)\s*\*\/.*$/); |
| 104 | if (blockInlineMatch && blockInlineMatch[1].includes(":")) { |
| 105 | const hint = blockInlineMatch[2].trim(); |
| 106 | return { hint, lineIndex, endIndex: lineIndex, isInline: true }; |
| 107 | } |
| 108 | |
| 109 | return { hint: null, lineIndex, endIndex: lineIndex, isInline: false }; |
| 110 | } |
| 111 | |
| 112 | function extractBlockComment( |
| 113 | lines: string[], |
no test coverage detected