Order of execution for on-save and analyze
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
Issue Log
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, theReferenceResolver.getLinkTarget()
shows how to force an analysis if it hasn’t been performed yet. Looking at it now, it appears theStrategoObserver.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 :)
Interesting, this could explain the occasional misses of compilations that sometimes occur (sometimes a compile is not performed on a save, for some reason).
Log in to post comments