MCPcopy
hub / github.com/lingodotdev/lingo.dev / extractBlockComment

Function extractBlockComment

packages/cli/src/cli/loaders/jsonc.ts:112–165  ·  view source on GitHub ↗
(
  lines: string[],
  startIndex: number,
)

Source from the content-addressed store, hash-verified

110}
111
112function extractBlockComment(
113 lines: string[],
114 startIndex: number,
115): { hint: string | null; lineIndex: number; endIndex: number } {
116 const startLine = lines[startIndex];
117
118 // Single-line block comment
119 const singleMatch = startLine.match(/\/\*\s*(.*?)\s*\*\//);
120 if (singleMatch) {
121 return {
122 hint: singleMatch[1].trim(),
123 lineIndex: startIndex,
124 endIndex: startIndex,
125 };
126 }
127
128 // Multi-line block comment
129 const commentParts: string[] = [];
130 let endIndex = startIndex;
131
132 // Extract content from first line
133 const firstContent = startLine.replace(/.*?\/\*\s*/, "").trim();
134 if (firstContent && !firstContent.includes("*/")) {
135 commentParts.push(firstContent);
136 }
137
138 // Process subsequent lines
139 for (let i = startIndex + 1; i < lines.length; i++) {
140 const line = lines[i];
141 endIndex = i;
142
143 if (line.includes("*/")) {
144 const lastContent = line
145 .replace(/\*\/.*$/, "")
146 .replace(/^\s*\*?\s*/, "")
147 .trim();
148 if (lastContent) {
149 commentParts.push(lastContent);
150 }
151 break;
152 } else {
153 const content = line.replace(/^\s*\*?\s*/, "").trim();
154 if (content) {
155 commentParts.push(content);
156 }
157 }
158 }
159
160 return {
161 hint: commentParts.join(" ").trim() || null,
162 lineIndex: startIndex,
163 endIndex,
164 };
165}
166
167function findAssociatedKey(
168 lines: string[],

Callers 1

extractCommentFromLineFunction · 0.85

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected