MCPcopy Index your code
hub / github.com/github/copilot-sdk / collectGoTopLevelNames

Function collectGoTopLevelNames

scripts/codegen/go.ts:3436–3467  ·  view source on GitHub ↗
(code: string, keyword: "type" | "const")

Source from the content-addressed store, hash-verified

3434}
3435
3436function collectGoTopLevelNames(code: string, keyword: "type" | "const"): string[] {
3437 const names = new Set<string>();
3438 const lines = code.split(/\r?\n/);
3439 let inBlock = false;
3440
3441 for (const line of lines) {
3442 if (inBlock) {
3443 if (/^\)/.test(line)) {
3444 inBlock = false;
3445 continue;
3446 }
3447
3448 const blockMatch = /^\t([A-Z]\w*)\b/.exec(line);
3449 if (blockMatch) {
3450 names.add(blockMatch[1]);
3451 }
3452 continue;
3453 }
3454
3455 if (new RegExp(`^${keyword}\\s*\\(`).test(line)) {
3456 inBlock = true;
3457 continue;
3458 }
3459
3460 const singleMatch = new RegExp(`^${keyword}\\s+([A-Z]\\w*)\\b`).exec(line);
3461 if (singleMatch) {
3462 names.add(singleMatch[1]);
3463 }
3464 }
3465
3466 return [...names].sort(compareGoTypeNames);
3467}
3468
3469function generateGoSessionEventAliasFile(
3470 generatedSessionTypeCode: string,

Calls 2

execMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…