MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / visit

Function visit

scripts/migrate-schema-class.ts:162–193  ·  view source on GitHub ↗
(node: ts.Node)

Source from the content-addressed store, hash-verified

160const findClassDecls = (source: ts.SourceFile): ClassDeclInfo[] => {
161 const out: ClassDeclInfo[] = [];
162 const visit = (node: ts.Node) => {
163 if (ts.isClassDeclaration(node) && node.heritageClauses && node.name) {
164 const extendsClause = node.heritageClauses.find(
165 (c) => c.token === ts.SyntaxKind.ExtendsKeyword,
166 );
167 if (extendsClause && extendsClause.types.length === 1) {
168 const parsed = parseSchemaClassExtends(extendsClause.types[0].expression);
169 if (parsed) {
170 // Only handle classes with empty bodies — anything with custom methods
171 // needs human attention.
172 if (node.members.length > 0) {
173 console.warn(
174 ` ⚠ ${node.name.text} has ${node.members.length} member(s); skipping (manual review)`,
175 );
176 } else {
177 const isExported =
178 node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
179 out.push({
180 name: node.name.text,
181 kind: parsed.kind,
182 identifier: parsed.identifier,
183 fieldsText: parsed.fieldsText,
184 isExported,
185 fullStart: node.getStart(source),
186 end: node.getEnd(),
187 });
188 }
189 }
190 }
191 }
192 ts.forEachChild(node, visit);
193 };
194 visit(source);
195 return out;
196};

Callers 2

findClassDeclsFunction · 0.70
findConstructorCallsFunction · 0.70

Calls 4

parseSchemaClassExtendsFunction · 0.85
warnMethod · 0.80
pushMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected