mike-lischke / antlr4-c3

A grammar agnostic code completion engine for ANTLR4 based parsers
MIT License
396 stars 62 forks source link

Fix invalid Java unit test assertion #116

Closed mallman closed 3 months ago

mallman commented 4 months ago

Fix invalid Java unit test assertion. C3 should not suggest ignored tokens as completions.

See issue #77 for related discussion.

This invalid assertion was hiding a bug in C3. How to fix that bug is up for discussion, but basically it appears that the implementation of the followSetsByATN global cache is problematic. This cache is based on the class name of the parser object, but it does not account for ignored tokens. Two instances of CodeCompletionCore will use the same followSetsByATN entry for the same parser, even if they have different ignored tokens. How to fix this?

The other language implementations of C3 may have the same problem. For example, it looks to me like the C# tests have the same invalid assertion. I'm not sure I want to touch that, though, because I'm not familiar with C#. So this PR just addresses the Java port.

I'm also wondering if this is related to #66 as well. @mike-lischke is the expert here.

mike-lischke commented 4 months ago

Thanks @mallman, please sign your patch so I can merge it (see the DCO link)

mallman commented 4 months ago

Thanks @mallman, please sign your patch so I can merge it (see the DCO link)

Done.

Any thoughts on how to fix the associated bug? Do you want to take that on yourself?

mike-lischke commented 4 months ago

No idea yet. If you would like to take that over that would be great.