You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation for the resolution for the previous similar issue is leading to a few APIs in concerto-core and concerto-cto breakiing when they try to refer to the resolved type reference for the imported-aliased declarations.
Main issue is that when a model AST is resolved, we loose the reference to the aliased type names instead have the resolved type name, which was replaced.
Expected Behavior
Resolved model should preserve both the resolved type names and the original type name as specified by the user.
Current Behavior
Resolved model only replaces the type names used by the user with resolved type names (taking into account aliases).
Possible Solution
Steps to Reproduce
Model Decoration
If we try to decorate these models with given DCS, the process fails with error.
Printing a resolved model from AST, where an declaration extending an aliased declaration would break
If we try to load these models, validate, resolve and print these models, the printing step would result in an error.
Print a resolved model from AST, where a property instantiated using an aliased declaration would change to the base declaration rather than the aliased declaration.
if we try to load these models, validate, resolve and print these models, the processes are successful but we loose reference to the aliased type which is imported in the property instantiation.
The issue is that resolveMetamodel method (called by ModelManager.toAst(true)) was modified to replace aliased imports with the actual type names inside TypeIdentifiers. This is useful for users processing the AST however it is lossy as it is difficult to recover the name as originally used by the user in the CTO file. In a subsequent call to fromAst the resolved AST is used:
If the resolved type was not imported then a type not found error will occur
If the resolved imported type has the same name as a type in the current namespace then a conflict will occur, leading to undefined behavior
If the resolved imported type is used a super class for a class with the same name, then a conflict will occur
Printer.toCTO has not been updated to recover the aliased name, so the roundtrip from [CTO with aliased import -> Resolved AST -> CTO] will be lossy, with aliased type names replaced with resolved type names
Possible Implementation
ModelManager.getAst(true) should return:
A valid instance of the meta model
Namespaces should be added to TypeIdentifiers so that imports do not need to be inspected
A aliasName property should be added for types that are referred to in this model file by a name that is different from their name in their host namespace
The name property should be updated to be the name of a type in its host namespace
ModelManager.fromAst(true) should return:
A populated ModelManager
If an aliasName property is present on a TypeIdentifier it should be used for the name of a type, otherwise the name property should be used as the type name
Printer.toCTO(ast) should return:
If a TypeIdentifier has an aliasName print that rather that the name property for the type name
Metamodel update
Add an optional aliasName to TypeIdentifier
Republish concerto-metamodel
Update models.accordproject.org
Unit Tests
Alias an import and use wherever a type can be referenced:
Bug Report 🐛
The implementation for the resolution for the previous similar issue is leading to a few APIs in
concerto-core
andconcerto-cto
breakiing when they try to refer to the resolved type reference for the imported-aliased declarations.Main issue is that when a model AST is resolved, we loose the reference to the aliased type names instead have the resolved type name, which was replaced.
Expected Behavior
Resolved model should preserve both the resolved type names and the original type name as specified by the user.
Current Behavior
Resolved model only replaces the type names used by the user with resolved type names (taking into account aliases).
Possible Solution
Steps to Reproduce
If we try to decorate these models with given DCS, the process fails with error.
If we try to load these models, validate, resolve and print these models, the printing step would result in an error.
if we try to load these models, validate, resolve and print these models, the processes are successful but we loose reference to the aliased type which is imported in the property instantiation.
Context (Environment)
Desktop
Detailed Description
The issue is that
resolveMetamodel
method (called by ModelManager.toAst(true)
) was modified to replace aliased imports with the actual type names inside TypeIdentifiers. This is useful for users processing the AST however it is lossy as it is difficult to recover the name as originally used by the user in the CTO file. In a subsequent call tofromAst
the resolved AST is used:Possible Implementation
ModelManager.getAst(true) should return:
aliasName
property should be added for types that are referred to in this model file by a name that is different from their name in their host namespacename
property should be updated to be the name of a type in its host namespaceModelManager.fromAst(true) should return:
aliasName
property is present on aTypeIdentifier
it should be used for the name of a type, otherwise thename
property should be used as the type namePrinter.toCTO(ast) should return:
aliasName
print that rather that thename
property for the type nameMetamodel update
aliasName
to TypeIdentifierUnit Tests
Alias an import and use wherever a type can be referenced:
Test that
[email protected]
CTO file roundtrips through getAst(true) and fromAst(ast) and can be used with decorator command set.The text was updated successfully, but these errors were encountered: