Rename SelfTargetingIntention#allowCaretInsideElement
The current method makes it a bit hard to understand its purpose.
This commit is contained in:
committed by
TeamCityServer
parent
abcc716ffc
commit
476d1da1cf
+2
-1
@@ -36,7 +36,8 @@ class HLConvertToBlockBodyIntention :
|
||||
val reformat: Boolean,
|
||||
) : HLApplicatorInput
|
||||
|
||||
override fun allowCaretInsideElement(element: PsiElement) = element !is KtDeclaration && super.allowCaretInsideElement(element)
|
||||
override fun skipProcessingFurtherElementsAfter(element: PsiElement) =
|
||||
element is KtDeclaration || super.skipProcessingFurtherElementsAfter(element)
|
||||
|
||||
override val applicabilityRange: HLApplicabilityRange<KtDeclarationWithBody> get() = ApplicabilityRanges.SELF
|
||||
|
||||
|
||||
+11
-3
@@ -79,7 +79,7 @@ abstract class SelfTargetingIntention<TElement : PsiElement>(
|
||||
if (elementType.isInstance(element) && isApplicableTo(element as TElement, offset)) {
|
||||
return element
|
||||
}
|
||||
if (element.textRange.containsInside(offset) && !allowCaretInsideElement(element)) break
|
||||
if (element.textRange.containsInside(offset) && skipProcessingFurtherElementsAfter(element)) break
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -89,8 +89,16 @@ abstract class SelfTargetingIntention<TElement : PsiElement>(
|
||||
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
|
||||
/** Whether to keep looking for targets after having processed the given element, which contains the cursor.
|
||||
* */
|
||||
@Deprecated(
|
||||
"The name of this method is a bit confusing and hence deprecated.",
|
||||
replaceWith = ReplaceWith("!skipProcessingFurtherElementsAfter(element)")
|
||||
)
|
||||
protected open fun allowCaretInsideElement(element: PsiElement): Boolean = !skipProcessingFurtherElementsAfter(element)
|
||||
|
||||
/** Whether to skip looking for targets after having processed the given element, which contains the cursor. */
|
||||
protected open fun skipProcessingFurtherElementsAfter(element: PsiElement): Boolean = element is KtBlockExpression
|
||||
|
||||
final override fun isAvailable(project: Project, editor: Editor, file: PsiFile): Boolean {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class FunctionWithLambdaExpressionBodyInspection : AbstractKotlinInspection() {
|
||||
}
|
||||
|
||||
private class AddArrowIntention : SpecifyExplicitLambdaSignatureIntention() {
|
||||
override fun allowCaretInsideElement(element: PsiElement) = true
|
||||
override fun skipProcessingFurtherElementsAfter(element: PsiElement): Boolean = false
|
||||
}
|
||||
|
||||
private class RemoveBracesFix : LocalQuickFix {
|
||||
|
||||
@@ -46,9 +46,9 @@ class AddNameToArgumentIntention : SelfTargetingIntention<KtValueArgument>(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun allowCaretInsideElement(element: PsiElement) = element !is KtValueArgumentList &&
|
||||
element !is KtContainerNode &&
|
||||
super.allowCaretInsideElement(element)
|
||||
override fun skipProcessingFurtherElementsAfter(element: PsiElement) = element is KtValueArgumentList ||
|
||||
element is KtContainerNode ||
|
||||
super.skipProcessingFurtherElementsAfter(element)
|
||||
|
||||
override fun applyTo(element: KtValueArgument, editor: Editor?) {
|
||||
apply(element)
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ class ConvertPropertyInitializerToGetterIntention : SelfTargetingRangeIntention<
|
||||
null
|
||||
}
|
||||
|
||||
override fun allowCaretInsideElement(element: PsiElement): Boolean {
|
||||
override fun skipProcessingFurtherElementsAfter(element: PsiElement): Boolean {
|
||||
// do not work inside lambda's in initializer - they can be too big
|
||||
return element !is KtDeclaration && super.allowCaretInsideElement(element)
|
||||
return element is KtDeclaration || super.skipProcessingFurtherElementsAfter(element)
|
||||
}
|
||||
|
||||
override fun applyTo(element: KtProperty, editor: Editor?) {
|
||||
|
||||
@@ -44,7 +44,8 @@ class ConvertToBlockBodyIntention : SelfTargetingIntention<KtDeclarationWithBody
|
||||
}
|
||||
}
|
||||
|
||||
override fun allowCaretInsideElement(element: PsiElement) = element !is KtDeclaration && super.allowCaretInsideElement(element)
|
||||
override fun skipProcessingFurtherElementsAfter(element: PsiElement) =
|
||||
element is KtDeclaration || super.skipProcessingFurtherElementsAfter(element)
|
||||
|
||||
override fun applyTo(element: KtDeclarationWithBody, editor: Editor?) {
|
||||
convert(element, true)
|
||||
|
||||
@@ -93,5 +93,5 @@ class RemoveBracesIntention : SelfTargetingIntention<KtElement>(KtElement::class
|
||||
}
|
||||
}
|
||||
|
||||
override fun allowCaretInsideElement(element: PsiElement) = element !is KtBlockExpression || element.parent is KtWhenEntry
|
||||
override fun skipProcessingFurtherElementsAfter(element: PsiElement) = element is KtBlockExpression && element.parent !is KtWhenEntry
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user