If you type in some text and save the file shortly after, the on-save builder gets passed the old AST; in other words, on-save builders are called before the new AST is analyzed.

I guess typically users type some text and directly press their favorite Save-keyboard-shortcut. Because on-save is handy for multi-file error checking or even real-time compilation, it is important that it receives an up-to-date AST.

Probably the order of execution is determined by the OBSERVER_DELAY of 600 ms in StrategoObserver.

Submitted by Nathan Bruning on 30 September 2010 at 23:31

On 1 October 2010 at 11:06 Lennart Kats commented:

Good find. It’s pretty much critical that the on save handler gets the most recent, analyzed AST. Right now it is even possible that the file hasn’t been reparsed yet let alone analyzed. I don’t think there’s currently an API to find out if the parse has been scheduled yet, but the current parse can be aborted and one can be started manually (see ContentProposer.parse). As for the analysis, the ReferenceResolver.getLinkTarget() shows how to force an analysis if it hasn’t been performed yet. Looking at it now, it appears the StrategoObserver.isUpdateScheduled() isn’t very well suited for this as it always returns true after the first time a file has been analyzed. Different issue I suppose. Anyway, feel free to take a look at it yourself :)


On 1 October 2010 at 11:32 Zef Hemel commented:

Interesting, this could explain the occasional misses of compilations that sometimes occur (sometimes a compile is not performed on a save, for some reason).


On 9 December 2010 at 14:46 Lennart Kats tagged 1.0

On 9 December 2010 at 14:46 Lennart Kats removed tag 1.0

On 9 December 2010 at 14:47 Lennart Kats tagged 0.61

On 23 November 2011 at 13:44 Lennart Kats removed tag 0.61

On 23 November 2011 at 13:44 Lennart Kats tagged 1.1

On 23 November 2011 at 13:44 Lennart Kats removed tag interesting

On 23 November 2011 at 13:44 Lennart Kats tagged pitfall

On 8 January 2013 at 12:56 Eelco Visser removed tag 1.1

On 8 January 2013 at 12:56 Eelco Visser tagged interesting

On 8 January 2013 at 16:08 Eelco Visser removed tag @nathanbruning

On 8 January 2013 at 16:08 Eelco Visser removed tag @lennartkats

On 8 January 2013 at 16:09 Eelco Visser tagged nabl

On 8 January 2013 at 16:09 Eelco Visser tagged 1.2

On 8 January 2013 at 16:09 Eelco Visser removed tag interesting

On 13 February 2013 at 21:16 Gabriël Konat removed tag nabl

On 13 February 2013 at 21:16 Gabriël Konat tagged major

On 13 March 2014 at 08:52 Eelco Visser removed tag 1.2

Log in to post comments