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

Autocompletion for sandy stopped to work after complex expression in parentesis #4

Closed
eschava opened this issue Apr 3, 2017 · 10 comments

Comments

@eschava
Copy link

eschava commented Apr 3, 2017

Expression
var a=(1
has suggestions
),*,+,-,/
but expression
var a=(1+1
should have same suggestions instead if has only
*,+,-,/
(without closing parenthesis)

I think it's related to handling of StarLoopbackState somehow.

@eschava
Copy link
Author

eschava commented Apr 3, 2017

I've added couple of unit tests to CompletionTest.kt:

@test fun incompleteParenthesis() {
    val code = "var a = (1"
    assertEquals(setOf(TokenTypeImpl(SandyLexer.RPAREN), TokenTypeImpl(SandyLexer.PLUS), TokenTypeImpl(SandyLexer.MINUS), TokenTypeImpl(SandyLexer.DIVISION), TokenTypeImpl(SandyLexer.ASTERISK)),
            AntlrAutoCompletionSuggester(SandyParser.ruleNames,SandyLexer.VOCABULARY,SandyParser._ATN)
            .suggestions(EditorContextImpl(code, sandyLanguageSupport.antlrLexerFactory)).proposals)
}

@test fun incompleteComplexParenthesis() {
    val code = "var a = (1+1"
    assertEquals(setOf(TokenTypeImpl(SandyLexer.RPAREN), TokenTypeImpl(SandyLexer.PLUS), TokenTypeImpl(SandyLexer.MINUS), TokenTypeImpl(SandyLexer.DIVISION), TokenTypeImpl(SandyLexer.ASTERISK)),
            AntlrAutoCompletionSuggester(SandyParser.ruleNames,SandyLexer.VOCABULARY,SandyParser._ATN)
            .suggestions(EditorContextImpl(code, sandyLanguageSupport.antlrLexerFactory)).proposals)
}

now second test fails

@ftomassetti
Copy link
Owner

Thank you for reporting this. The auto-completion code is a bit tricky, and more tests to cover it will definitely help

@eschava
Copy link
Author

eschava commented Apr 11, 2017

Is there any chance to have it fixed?

@ftomassetti
Copy link
Owner

Yes, I plan to do this in the following weeks. I could accept a PR sooner

@eschava
Copy link
Author

eschava commented Jun 22, 2017

Have you finished with the fix?

@ftomassetti
Copy link
Owner

No, I was hoping to get a PR, then I was kept busy by other open-source projects

@ftomassetti
Copy link
Owner

I have added the two tests you suggested in a separate branch. The first one seems to pass now, while the second one fails.

ftomassetti added a commit that referenced this issue Jun 28, 2017
@ftomassetti
Copy link
Owner

Now it should work. It took a while because I aimed to a significant refactoring, creating a separate library for autocompletion which is integrated into kanvas but can be used also separately.
Sorry it took so long.

@eschava
Copy link
Author

eschava commented Jul 31, 2017

Thanks a lot!

@ftomassetti
Copy link
Owner

Thanks to you for reporting the issue and for your patience. I will be more reactive in the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants