UoY-RoboStar / robochart-textual

This repository contains the plugins for the RoboChart textual editor
Eclipse Public License 2.0
0 stars 1 forks source link

Automatic code generation fails to include all resources #39

Closed pefribeiro closed 2 years ago

pefribeiro commented 2 years ago

If code generation ie. doGenerate is called from an XtextBuilder, currently no attempt is made to resolve all resources in scope, which may result in broken partial builds. This has been noticed when compiling .assertions files that reference a resource X.rct, which uses anonymous (ie. not included via imports) resources in another file Y.rct, resulting in missing .csp includes.

Instead, if calling using the cogs icon this is resolved in:

https://github.com/UoY-RoboStar/robochart-csp-gen/blob/7514dc0c55713e5dd0035b43eedfe74255b0bde8/circus.robocalc.robochart.generator.csp/src/circus/robocalc/robochart/generator/csp/handlers/CompileHandler.xtend#L70-L96

In an upcoming branch change I introduce a universal way to resolve this, but which I think makes more sense to be called within the textual plug-ins of the RoboChart and assertions languages.

ana-york commented 2 years ago

In an upcoming branch change I introduce a universal way to resolve this, but which I think makes more sense to be called within the textual plug-ins of the RoboChart and assertions languages.

Does this mean that a problem will remain with the graphical editor, or is it just a restriction for code reuse?

A

pefribeiro commented 2 years ago

Hi Ana,

Does this mean that a problem will remain with the graphical editor, or is it just a restriction for code reuse? A

I think there won't be a problem with the graphical editor. My understanding is that upon saving a diagram the related textual resource will be updated/saved, which will trigger this mechanism. So a RoboChart diagram save will trigger a save of the related .rct file, followed by an automatic call to doGenerate.

I propose to include this change in the textual plug-ins as the issue is common across all registered code generators, ie. in the case of RoboChart it will be an issue potentially for both the untimed or timed generators, so it makes sense to sort out the cross-references before both generators are called. This same logic is already followed if the user presses the cogs icon, but not when saving a resource individually.

alvarohm commented 2 years ago

Hi Ana and Pedro,

Does this mean that a problem will remain with the graphical editor, or is it just a restriction for code reuse? A

I think there won't be a problem with the graphical editor. My understanding is that upon saving a diagram the related textual resource will be updated/saved, which will trigger this mechanism.

This is correct, the graphical editor is only indirectly connected to the generator, always via the textual editor.

So a RoboChart diagram save will trigger a save of the related .rct file, followed by an automatic call to doGenerate.

I propose to include this change in the textual plug-ins as the issue is common across all registered code generators, ie. in the case of RoboChart it will be an issue potentially for both the untimed or timed generators, so it makes sense to sort out the cross-references before both generators are called. This same logic is already followed if the user presses the cogs icon, but not when saving a resource individually.

I believe this is because xtext is trying to optimise the amount of memory it uses, so it does not load resources if it does not need them. Pedro, thanks for finding a solution to this problem.

Alvaro

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/UoY-RoboStar/robochart-textual/issues/39#issuecomment-923784140, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEHMYKDBEFFXZC6TANOFO3UDBDLRANCNFSM5EM4NJ2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.