toAst and fromAst are not identity operation
Bug Report 🐛
toAst and fromAst are not identity operation.
Expected Behavior
Ideally, toAst and fromAst should be identity operation.
Current Behavior
The culprit here is that while fromAst populates the manager with model files, it doesn't provide definitions. However getModels relies on definitions being there.
Otherwise fromAst and getAst operations are identity.
I'm not sure this is a bug. In your REPL, the first time you run you are creating an AST from CTO, so the CTO text is also added to the ModelManager. In your second run you just add the AST to the ModelManager and the CTO is not present.
The CTO text is not used by the ModelManager, it is preserved purely for debugging, if added. Hence the definitions is optional in the ModelFile constructor.
@mttrbrts perhaps we should drop support for addModel / addCTOModel take a CTO string in ModelManager for v4? This would make concerto-core independent of CTO parser (saving memory and module size).
@mttrbrts perhaps we should drop support for addModel / addCTOModel take a CTO string in ModelManager for v4? This would make concerto-core independent of CTO parser (saving memory and module size).
I agree with that.
Perhaps the confusion stems from getModels returning the CML content? What should the behaviour be if a ModelManager doesn't know about the CML? To only list the namespaces, perhaps?