mentions
Whether a file's code (not its imports) uses a name.
import type { parse } from "#codebase/tcmts/core/ts"; import { isIdentifier as ts_isIdentifier, isImportDeclaration as ts_isImportDeclaration } from "typescript/ast"; export function mentions(sf: ReturnType<typeof parse>, name: string): boolean { let found = false; const visit = (n: Parameters<typeof ts_isIdentifier>[0]) => { if (found) return; if (ts_isIdentifier(n) && n.text === name) found = true; else n.forEachChild(visit); }; for (const st of sf.statements) if (!ts_isImportDeclaration(st)) visit(st); return found; }