reusing AST for content completion is too eager
There is a case where the AST for content completion is reused a bit too eager.
This can be reproduced as follows:
- Take the entity language as generated in a new Spoofax project
- Add
completion trigger : "."
to -Completions.esv- Add
"expression" {ID "."}+ -> Definition {cons("Expression")}
to syntax- Add
if <is-list> node then proposals := ["foo", "bar", "z"] end
to the editor-complete strategyThis should allow one to type e.g.
expression foo.bar.z.z
with content completion everytime the dot is entered.
However, when you try this you’ll see it will not take anything but the first word into account for content completion, because, as characters are added, the initial AST will be reused again and again:
:: Completion triggered for: [COMPLETION("foo")] (candidate sorts: [ID, Definition]) :: Completion triggered for: [COMPLETION("foo")] (candidate sorts: [ID, Definition]) :: Completion triggered for: [COMPLETION("foo")] (candidate sorts: [ID, Definition]) ...
Maybe the cached AST should be removed when completion is applied or when any of the completion triggers matches?
EDIT: tried both these simple solutions, neither is good.
Submitted by Tobi Vollebregt on 31 January 2011 at 10:29
Issue Log
I’m not sure if the API will tell you when exactly the completion is applied/triggered. I think the cache just needs a better precondition: it should only apply only when the input text is the same, modulo the identifier at the completion location.
fixed in r21763
Log in to post comments