Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug with '(' showing for allShortestPaths, ANY, etc #115

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

ncordon
Copy link
Collaborator

@ncordon ncordon commented Oct 17, 2023

What

Solves a bug where we get allShortestPaths '(' instead of allShortestPaths as completion.

Why

This was introduced when the errors code started to use c3 for giving better error messages. The reason is the c3 engine keeps a static copy of the ATN cached for all the instances, that depends only on the name of the parser, but not the ignoredTokens:

export class CodeCompletionCore {
    private static followSetsByATN = new Map<string, FollowSetsPerState>();

The ATN transitions get computed having into account the ignored tokens:

    if (!this.candidates.tokens.has(symbol)) {
        // Following is empty if there is more than one entry in the set.
        this.candidates.tokens.set(symbol, set.following);

There's a race condition between the errors code (which doesn't configure ignored tokens to get brackets in the error messages :Expected one of (, [, etc) and the completions engine (which just suggests keywords).

@ncordon ncordon force-pushed the fixes-ignored-tokens branch from 8965010 to a20bc16 Compare October 17, 2023 10:34
@ncordon ncordon added bug Something isn't working auto completion Issues related to the auto-completion labels Oct 17, 2023
@ncordon ncordon requested a review from OskarDamkjaer October 17, 2023 10:36
@ncordon ncordon force-pushed the fixes-ignored-tokens branch from a20bc16 to d478ff9 Compare October 17, 2023 10:46
@ncordon ncordon merged commit 42d6f3c into main Oct 17, 2023
3 checks passed
@ncordon ncordon deleted the fixes-ignored-tokens branch October 17, 2023 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto completion Issues related to the auto-completion bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants