Fix in keyword completion
This commit is contained in:
@@ -32,6 +32,8 @@ import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
|||||||
import org.jetbrains.jet.lang.psi.psiUtil.prevLeaf
|
import org.jetbrains.jet.lang.psi.psiUtil.prevLeaf
|
||||||
import org.jetbrains.jet.plugin.completion.handlers.KotlinKeywordInsertHandler
|
import org.jetbrains.jet.plugin.completion.handlers.KotlinKeywordInsertHandler
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.siblings
|
import org.jetbrains.jet.lang.psi.psiUtil.siblings
|
||||||
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
|
import com.intellij.psi.PsiComment
|
||||||
|
|
||||||
class KeywordLookupObject(val keyword: String)
|
class KeywordLookupObject(val keyword: String)
|
||||||
|
|
||||||
@@ -159,13 +161,22 @@ object KeywordCompletion {
|
|||||||
|
|
||||||
elementAt.getParentByType(javaClass<PsiErrorElement>(), strict = false) != null -> false
|
elementAt.getParentByType(javaClass<PsiErrorElement>(), strict = false) != null -> false
|
||||||
|
|
||||||
elementAt.prevLeaf() is PsiErrorElement -> false
|
elementAt.prevLeafSkipWhitespacesAndComments() is PsiErrorElement -> false
|
||||||
|
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun PsiElement.prevLeafSkipWhitespacesAndComments(): PsiElement? {
|
||||||
|
var leaf = prevLeaf()
|
||||||
|
while (leaf != null) {
|
||||||
|
if (leaf !is PsiWhiteSpace && leaf !is PsiComment) return leaf
|
||||||
|
leaf = leaf!!.prevLeaf()
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
// builds text within scope (or from the start of the file) before position element excluding almost all declarations
|
// builds text within scope (or from the start of the file) before position element excluding almost all declarations
|
||||||
private fun buildReducedContextBefore(builder: StringBuilder, position: PsiElement, scope: PsiElement?) {
|
private fun buildReducedContextBefore(builder: StringBuilder, position: PsiElement, scope: PsiElement?) {
|
||||||
if (position == scope) return
|
if (position == scope) return
|
||||||
|
|||||||
@@ -2,10 +2,5 @@ class Test {
|
|||||||
class <caret>
|
class <caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
/*TODO: should be only 'object'*/
|
|
||||||
// EXIST: class
|
|
||||||
// EXIST: fun
|
|
||||||
// EXIST: object
|
// EXIST: object
|
||||||
// EXIST: trait
|
// NUMBER: 1
|
||||||
// EXIST: val
|
|
||||||
// NUMBER: 5
|
|
||||||
Reference in New Issue
Block a user