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 strategy

This 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

On 31 January 2011 at 11:18 Lennart Kats commented:

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.


On 31 January 2011 at 11:18 Lennart Kats tagged runtime

On 31 January 2011 at 13:51 Tobi Vollebregt tagged !tvo

On 31 January 2011 at 13:51 Tobi Vollebregt removed tag !tvo

On 31 January 2011 at 13:51 Tobi Vollebregt tagged @tvo

On 31 January 2011 at 14:25 Tobi Vollebregt closed this issue.

On 31 January 2011 at 14:25 Tobi Vollebregt commented:

fixed in r21763


On 9 February 2011 at 10:41 Lennart Kats tagged 1.0

On 23 March 2011 at 14:51 Tobi Vollebregt tagged completion

Log in to post comments