Dynamic rules lifetime
Dynamic rules lose their value in between builders (and also in between analysis phase and calling a builder) in Spoofax.
Steps to reproduce:
1) create new Spoofax language project
2) add builders:
rules debug-set-index: (selected, position, ast, path, project-path) -> None() with rules(Index := ["foo", "bar"]) debug-show-index: (selected, position, ast, path, project-path) -> (filename, result) with filename := <guarantee-extension(|"index.aterm")> path; result := <Index;debug(!"stored index ") <+ !"Index is emtpy"> //TODO: why is the index empty?
menus menu: "Dynamic Rules" (openeditor) action: "debug-set-index" = debug-set-index action: "debug-show-index" = debug-show-index
3) create a new language file, call first builder, call second builder.
Expected output: file with
["foo", "bar"]
Actual output: file with
Index is emtpy
Spoofax version:
Submitted by Daco Harkes on 26 September 2016 at 10:42Eclipse: org.eclipse.platform.ide 4.6.0.I20160606-1100 Spoofax: org.metaborg.spoofax.eclipse 2.1.0.20160919-225254-master System: Mac OS X x86_64 10.11.6
Issue Log
On 26 September 2016 at 11:05 Daco Harkes commented:
Possible work around: store in file.
On 26 September 2016 at 11:43 Daco Harkes commented:
Actually not: attachments get lost.
On 14 February 2017 at 13:09 Gabriël Konat tagged stratego
On 14 February 2017 at 13:11 Gabriël Konat commented:
It should reuse the dynamic rules between invocations on the same language and project, so this is probably a bug. Unfortunately, the code that maintains Stratego dynamic rules is very hacky and I do not know how to do this.
Log in to post comments