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

Method coNamedInFile

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

Source from the content-addressed store, hash-verified

4781 /[._$]|::|\//.test(x) || /[a-z][A-Z]/.test(x) || /^[A-Z]/.test(x);
4782 const fileNameSets = new Map<string, Set<string>>();
4783 const coNamedInFile = (t: string, fp: string): boolean => {
4784 let names = fileNameSets.get(fp);
4785 if (!names) {
4786 names = new Set<string>();
4787 try {
4788 // An interface's members (#1638) describe a shape; nobody names
4789 // them in a question. Counting them let `readonly host: string` in
4790 // an options interface corroborate the English word "main" into
4791 // seeding the same file's `main()`, which then took the named-first
4792 // tier from the answer files (vscode "extension host … main process").
4793 const fileNodes = cg.getNodesInFile(fp);
4794 const interfaces = fileNodes.filter((n) => n.kind === 'interface');
4795 const declaresShape = (n: Node) =>
4796 (n.kind === 'property' || n.kind === 'method') &&
4797 interfaces.some((i) => n.startLine >= i.startLine && n.endLine <= i.endLine);
4798 for (const n of fileNodes) if (!declaresShape(n)) names.add(n.name.toLowerCase());
4799 } catch { /* unreadable file entry — treat as uncorroborated */ }
4800 fileNameSets.set(fp, names);
4801 }
4802 const self = t.toLowerCase();
4803 for (const o of lcTokens) {
4804 if (o !== self && names.has(o)) return true;
4805 }
4806 return false;
4807 };
4808 for (const t of tokens) {
4809 // Enumerate ALL defs of a bare token via the direct index, not FTS — a
4810 // 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