mike-lischke / antlr4-c3

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

translateToRuleIndex addNew doesn't really add, it replaces #55

Closed alessiostalla closed 3 years ago

alessiostalla commented 3 years ago

translateToRuleIndex checks for a rule to already be present in order to avoid adding a duplicate entry.

However, entries are in a map, not a list, so no duplicates are possible, and what really happens is that each new found path overwrites the previous one. IMO this should be clarified:

This could be controlled by a flag, as one user might want to stop searching as early as possible, while another might want to collect all the paths. But as it is now, all paths are examined but only the latest is returned, which is a waste.

mike-lischke commented 3 years ago

This is a valid point and tbh. I'm not sure which way to go here. Does it have merits to store all paths over which a specific rule was found? I'm not even using a single path in my projects. It is more the wish to provide all information to c3 user in case it is useful, why I included that detail. But I haven't found a real world example to take advantage of the stored path.

So, I'm open for both approaches, or even remove the path entirely.

alessiostalla commented 3 years ago

Actually I've never used the path either, but maybe there are more advanced users out there :)

mike-lischke commented 3 years ago

Well, even though it's not the best approach as it is implemented now, I'd not touch it until someone comes up with a real need. Thanks for bringing it up anyway.