hexMachina
hexMachina copied to clipboard
Detect circular references in DSL and provide a meaningful error message
Example code:
snapshotModule = new module.SnapshotModule(snapshotDependencies);
snapshotDependencies = new Array<hex.di.mapping.MappingDefinition>(
mapping({fromType: "Void->Void", toValue: snapshotController.onSnapshotSaved, withName: "onSnapshotSaved"})
);
snapshotController = new adapter.SnapshotController(snapshotModule.takeSnapshot);
As you can see, there is a circular dependency between snapshotModule and snapshotController, but it might be hard to notice in some cases.
Trying to compile the code results in a really long list of errors, none of which are helpful to find the source of the problem.
It would be nice if circular dependencies are detected during building of the dependency graph, and a meaningful error message is produced.
This one is tricky (for the edge cases). I will have to think about it in details. Btw, I could develop a 1st iteration for the common ones.
Yeah I know it's tricky :)