MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / stripGo

Function stripGo

src/resolution/strip-comments.ts:329–398  ·  view source on GitHub ↗
(src: string)

Source from the content-addressed store, hash-verified

327// ---------- Go ----------
328
329function stripGo(src: string): string {
330 const out = src.split('');
331 let i = 0;
332 const n = src.length;
333
334 while (i < n) {
335 const c = src[i]!;
336 const c2 = src[i + 1] ?? '';
337
338 // Block comment
339 if (c === '/' && c2 === '*') {
340 const start = i;
341 i += 2;
342 while (i < n && !(src[i] === '*' && src[i + 1] === '/')) i++;
343 if (i < n) i += 2;
344 blankRange(out, start, i, src);
345 continue;
346 }
347
348 // Line comment
349 if (c === '/' && c2 === '/') {
350 const start = i;
351 while (i < n && src[i] !== '\n') i++;
352 blankRange(out, start, i, src);
353 continue;
354 }
355
356 // Raw string with backticks (no escapes, can span lines)
357 if (c === '`') {
358 i++;
359 while (i < n && src[i] !== '`') i++;
360 if (i < n) i++;
361 continue;
362 }
363
364 // Interpreted string with double quotes
365 if (c === '"') {
366 i++;
367 while (i < n && src[i] !== '"') {
368 if (src[i] === '\\' && i + 1 < n) {
369 i += 2;
370 continue;
371 }
372 if (src[i] === '\n') break;
373 i++;
374 }
375 if (i < n && src[i] === '"') i++;
376 continue;
377 }
378
379 // Rune literal with single quotes (handle as a tiny string)
380 if (c === "'") {
381 i++;
382 while (i < n && src[i] !== "'") {
383 if (src[i] === '\\' && i + 1 < n) {
384 i += 2;
385 continue;
386 }

Callers 1

stripCommentsForRegexFunction · 0.85

Calls 2

blankRangeFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected