From abcc716ffc736f3be6efba025b0687afacb064f5 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Thu, 17 Jun 2021 10:06:47 -0700 Subject: [PATCH] Document org.jetbrains.kotlin.idea.intentions.SelfTargetingIntention#allowCaretInsideElement Also update its usage so that the contract of this method is easier to understand. --- .../jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt index 7f4f20db8e1..f92ac860257 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt @@ -79,7 +79,7 @@ abstract class SelfTargetingIntention( if (elementType.isInstance(element) && isApplicableTo(element as TElement, offset)) { return element } - if (!allowCaretInsideElement(element) && element.textRange.containsInside(offset)) break + if (element.textRange.containsInside(offset) && !allowCaretInsideElement(element)) break } return null } @@ -89,6 +89,7 @@ abstract class SelfTargetingIntention( return getTarget(offset, file) } + /** Whether to keep looking for targets after having processed the given element, which contains the cursor. */ protected open fun allowCaretInsideElement(element: PsiElement): Boolean = element !is KtBlockExpression final override fun isAvailable(project: Project, editor: Editor, file: PsiFile): Boolean {