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

Method coNamedInFile

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

Source from the content-addressed store, hash-verified

4837 /[._$]|::|\//.test(x) || /[a-z][A-Z]/.test(x) || /^[A-Z]/.test(x);
4838 const fileNameSets = new Map<string, Set<string>>();
4839 const coNamedInFile = (t: string, fp: string): boolean => {
4840 let names = fileNameSets.get(fp);
4841 if (!names) {
4842 names = new Set<string>();
4843 try {
4844 // An interface's members (#1638) describe a shape; nobody names
4845 // them in a question. Counting them let `readonly host: string` in
4846 // an options interface corroborate the English word "main" into
4847 // seeding the same file's `main()`, which then took the named-first
4848 // tier from the answer files (vscode "extension host … main process").
4849 const fileNodes = cg.getNodesInFile(fp);
4850 const interfaces = fileNodes.filter((n) => n.kind === 'interface');
4851 const declaresShape = (n: Node) =>
4852 (n.kind === 'property' || n.kind === 'method') &&
4853 interfaces.some((i) => n.startLine >= i.startLine && n.endLine <= i.endLine);
4854 for (const n of fileNodes) if (!declaresShape(n)) names.add(n.name.toLowerCase());
4855 } catch { /* unreadable file entry — treat as uncorroborated */ }
4856 fileNameSets.set(fp, names);
4857 }
4858 const self = t.toLowerCase();
4859 for (const o of lcTokens) {
4860 if (o !== self && names.has(o)) return true;
4861 }
4862 return false;
4863 };
4864 for (const t of tokens) {
4865 // Enumerate ALL defs of a bare token via the direct index, not FTS — a
4866 // 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