Code completion (error recovery?) produces weird ASTs
My editor esv file triggers the
editor-complete
rule for auto completion, I set it to the following for debugging purposes:
editor-complete =
debug(!"Editor complete: "); failNow, when I have:
var t : Task = Task{};
t.
and I do a Ctrl+space I see the following in my Spoofax console, sometimes:Editor complete: (FieldAccess(Var(""),COMPLETION("")),[2,3,3,1,1,1,1,1,1,0,1,0], ...)
This, of course is not a valid AST. The identifier in a Var (in mobl, because that’s what I’m using it for) cannot be empty. The odd thing is that a second later when I try again, it works just fine.
This has probably something todo with error recovery or the fact that it’s still parsing, but without this working I can never setup ‘.’ as a trigger for auto completion (which I really want), because it will always give me these kind of ASTs.
Submitted by Zef Hemel on 30 March 2010 at 08:33
Issue Log
Seems to work fine for me. I always get the FieldAccess(Var(“t”),COMPLETION("")), no matter if I use the trigger or not.
These things tend to be easier to discuss with an example program. Here’s mine:
module simplimport mobl
entity Task { n : String }
function foo() {
var t : Task = Task{};
t.
}(Note that it caches the parse results if you try content completion twice on the same source file, so for testing you should probably change it a bit each time.)
Actually, I just found something fishy in the caching logic…
Fixed in 0.4.2.1.
Log in to post comments