New J2K: Support general inspections with intention wrapper as quickFix

This commit is contained in:
Simon Ogorodnik
2018-07-07 19:11:21 +03:00
committed by Ilya Kirillov
parent c41be3274e
commit 928647462e
2 changed files with 39 additions and 11 deletions
@@ -54,8 +54,7 @@ abstract class SelfTargetingIntention<TElement : PsiElement>(
abstract fun applyTo(element: TElement, editor: Editor?)
private fun getTarget(editor: Editor, file: PsiFile): TElement? {
val offset = editor.caretModel.offset
fun getTarget(offset: Int, file: PsiFile): TElement? {
val leaf1 = file.findElementAt(offset)
val leaf2 = file.findElementAt(offset - 1)
val commonParent = if (leaf1 != null && leaf2 != null) PsiTreeUtil.findCommonParent(leaf1, leaf2) else null
@@ -81,6 +80,11 @@ abstract class SelfTargetingIntention<TElement : PsiElement>(
return null
}
fun getTarget(editor: Editor, file: PsiFile): TElement? {
val offset = editor.caretModel.offset
return getTarget(offset, file)
}
protected open fun allowCaretInsideElement(element: PsiElement): Boolean =
element !is KtBlockExpression