MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / coNamedInFile

Method coNamedInFile

src/mcp/tools.ts:4861–4885  ·  view source on GitHub ↗
(t: string, fp: string)

Source from the content-addressed store, hash-verified

4859 /[._$]|::|\//.test(x) || /[a-z][A-Z]/.test(x) || /^[A-Z]/.test(x);
4860 const fileNameSets = new Map<string, Set<string>>();
4861 const coNamedInFile = (t: string, fp: string): boolean => {
4862 let names = fileNameSets.get(fp);
4863 if (!names) {
4864 names = new Set<string>();
4865 try {
4866 // An interface's members (#1638) describe a shape; nobody names
4867 // them in a question. Counting them let `readonly host: string` in
4868 // an options interface corroborate the English word "main" into
4869 // seeding the same file's `main()`, which then took the named-first
4870 // tier from the answer files (vscode "extension host … main process").
4871 const fileNodes = cg.getNodesInFile(fp);
4872 const interfaces = fileNodes.filter((n) => n.kind === 'interface');
4873 const declaresShape = (n: Node) =>
4874 (n.kind === 'property' || n.kind === 'method') &&
4875 interfaces.some((i) => n.startLine >= i.startLine && n.endLine <= i.endLine);
4876 for (const n of fileNodes) if (!declaresShape(n)) names.add(n.name.toLowerCase());
4877 } catch { /* unreadable file entry — treat as uncorroborated */ }
4878 fileNameSets.set(fp, names);
4879 }
4880 const self = t.toLowerCase();
4881 for (const o of lcTokens) {
4882 if (o !== self && names.has(o)) return true;
4883 }
4884 return false;
4885 };
4886 for (const t of tokens) {
4887 // Enumerate ALL defs of a bare token via the direct index, not FTS — a
4888 // 50+-overload name (tokio `poll`) ranks the wanted def (`Harness::poll`)

Callers

nothing calls this directly

Calls 5

hasMethod · 0.80
getMethod · 0.65
getNodesInFileMethod · 0.65
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected