eclipse-langium/langium

Proposal missing from the content assist

ydaveluy opened this issue · 4 comments

Hey !

I probably found a minor issue in the content assist in case of multiple keyword alternatives. It seems that if the previous token is of a keyword kind, this keyword is not proposed by the content assist.

Langium version: 3.1
Package name: Langium

Steps To Reproduce

  1. Open this playground
  2. Ctrl+space on line 4

The current behavior

The content assist propose to create a new 'student' but not an other 'teacher'. After a 'student', the content assist propose to create a 'teacher' but not an other 'student'.

The expected behavior

The content assist should propose a 'student' and a 'teacher' in all cases.

Hm, interesting. It's also pretty interest that this can be pretty easily fixed by using a small refactoring of the grammar. See here.

Yes, in your refactoring, 'student' and 'teacher' are on different AstNodes, and it works properly.

In my case, I think the issue comes from DefaultCompletionProvider.findFeaturesAt, which does not return the previous feature, but I don't fully understand how this function works.

Yeah, I'm not saying that this isn't a bug - but there are at least in theory ways to circumvent this. I've added this to #1678.

Thanks for the workaround.

I continued investigating this issue and I noticed that we enter in this branch for the missing feature:

It means that the previous feature is added in the visited Set somewhere before processing the Group.