eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
669 stars 62 forks source link

Improve completion AST node accuracy #1267

Closed msujew closed 8 months ago

msujew commented 8 months ago

Closes https://github.com/eclipse-langium/langium/issues/1266

Improves the accuracy with which the completion provider picks the AST node:

  1. Fixes a very minor issue in the findLeafNodeAtOffset method, which sometimes gave back a CST node that appeared after the specified offset.
  2. Only pick one AST node, ideally at the position before the current completion position.

Also reduces the amount of false-positive completion proposals by implementing a performNextTokenCompletion method. In cases where we definitely first want to complete the current ID/word/keyword/etc, the completion provider should not yield more completion contexts. This method controls that behavior by checking whether we have a word at the current offset position.