Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MelangeResource upcast() cannot be called several times on the same resource #113

Open
dvojtise opened this issue Mar 12, 2018 · 0 comments

Comments

@dvojtise
Copy link
Contributor

In scenario where we wish to mix code written on a base language and an extended language, is would be useful to be able to call the method upcast several time according to the need.

for example:

load the model using conversion using an URL such as
melange:/file/model/myfsm.fsm?lang=fsmadaptation.XSFSM (fsm is cloned as an xsfsm)
then a some point call a code as fsm by changing the modeltype to FSMMT melangeRes.upcast("fsmadaptation.FSMMT")
do a transformation based on FSMMT (ie. operations are not copied by melange and exists only for fsm metaclasses)
then continue to work as XSFSMMT
melangeRes.upcast("fsmadaptation.XSFSMMT") (or melangeRes.upcast(null) as stated in the API doc, null is supposed to remove the adaptation)
Continue the transformation as XSFSMMT/null

In that case, I think we can maintain the model state (since we do not change the language) and only change the ModelType

However the current implementation in https://github.com/diverse-project/melange/blob/master/plugins/fr.inria.diverse.melange.resource/src/main/java/fr/inria/diverse/melange/resource/MelangeResourceImpl.xtend#L327 fully reloads the model from the wrappedResource and crashes becauses the resource already exists (https://github.com/diverse-project/melange/blob/master/plugins/fr.inria.diverse.melange.resource/src/main/java/fr/inria/diverse/melange/resource/MelangeResourceImpl.xtend#L350)

note: the extendsAs method documentation also states that null can be used to remove the adaptatoin, but in that case I don't think we can (easily) maintain the model state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant