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

Fix keywords completion #67

Merged

Conversation

YaPravaATyNet
Copy link
Contributor

No description provided.

)
private val AFTER_FLOAT_LITERAL = psiElement().afterLeafSkipping(
psiElement().withText(""),
psiElement().withElementType(MatlabTypes.FLOAT)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to create two different rules. You may create composite rule like this:

        private val AFTER_NUMBER_LITERAL = psiElement().afterLeafSkipping(
                alwaysFalse<PsiElement>(),
                or(psiElement(MatlabTypes.INTEGER), psiElement(MatlabTypes.FLOAT))
        )

@@ -35,6 +43,10 @@ class MatlabKeywordCompletionContributor : CompletionContributor() {
private fun provider(vararg keywords: String): CompletionProvider<CompletionParameters> {
return object : CompletionProvider<CompletionParameters>() {
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
val position = parameters.position
if (AFTER_INTEGER_LITERAL.accepts(position) || AFTER_FLOAT_LITERAL.accepts(position)) {
return
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add result.stopHere() before return.
It will disable completion of identifiers from current file

@kornilova203 kornilova203 merged commit bdfc7e9 into kornilova203:master Jul 14, 2020
@YaPravaATyNet YaPravaATyNet deleted the fix-keywords-completion branch July 14, 2020 19:49
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

Successfully merging this pull request may close these issues.

2 participants