don't try to walk over the siblings of PsiFile to check if "introduce variable" is enabled (EA-86136 - assert: SharedPsiElementImplUtil.getChildIndex)
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightBundle
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
@@ -35,6 +36,7 @@ class IntroduceVariableIntention : SelfTargetingRangeIntention<PsiElement>(
|
||||
PsiElement::class.java, CodeInsightBundle.message("intention.introduce.variable.text")
|
||||
) {
|
||||
private fun getExpressionToProcess(element: PsiElement): KtExpression? {
|
||||
if (element is PsiFile) return null
|
||||
val startElement = PsiTreeUtil.skipSiblingsBackward(element, PsiWhiteSpace::class.java) ?: element
|
||||
return startElement.parentsWithSelf
|
||||
.filterIsInstance<KtExpression>()
|
||||
|
||||
Reference in New Issue
Block a user