fix: Fallback to filename when Pascal module name is empty
Some .dpr templates use "program;" without a name, which produces an empty moduleName in the AST. Fall back to the filename (without extension) to prevent nodes with empty names that cause downstream FK constraint errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
482cbee0d0
commit
763e280829
@@ -1850,6 +1850,16 @@ describe('Pascal / Delphi Extraction', () => {
|
||||
expect(moduleNode).toBeDefined();
|
||||
expect(moduleNode?.name).toBe('MyApp');
|
||||
});
|
||||
|
||||
it('should fallback to filename when module name is empty', () => {
|
||||
// Some .dpr templates use "program;" without a name
|
||||
const code = `program;\nuses SysUtils;\nbegin\nend.`;
|
||||
const result = extractFromSource('Console.dpr', code);
|
||||
|
||||
const moduleNode = result.nodes.find((n) => n.kind === 'module');
|
||||
expect(moduleNode).toBeDefined();
|
||||
expect(moduleNode?.name).toBe('Console');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Uses clause (imports)', () => {
|
||||
|
||||
Reference in New Issue
Block a user