Smaller range for SplitPropertyDeclarationIntention
This commit is contained in:
+8
-3
@@ -17,12 +17,17 @@
|
||||
package org.jetbrains.kotlin.idea.intentions.declarations
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingOffsetIndependentIntention
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingRangeIntention
|
||||
import org.jetbrains.kotlin.idea.intentions.splitPropertyDeclaration
|
||||
import org.jetbrains.kotlin.psi.JetProperty
|
||||
|
||||
public class SplitPropertyDeclarationIntention : JetSelfTargetingOffsetIndependentIntention<JetProperty>(javaClass(), "Split property declaration") {
|
||||
override fun isApplicableTo(element: JetProperty): Boolean = element.hasInitializer() && element.isLocal()
|
||||
public class SplitPropertyDeclarationIntention : JetSelfTargetingRangeIntention<JetProperty>(javaClass(), "Split property declaration") {
|
||||
override fun applicabilityRange(element: JetProperty): TextRange? {
|
||||
if (!element.isLocal()) return null
|
||||
val initializer = element.getInitializer() ?: return null
|
||||
return TextRange(element.getTextRange().getStartOffset(), initializer.getTextRange().getStartOffset())
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetProperty, editor: Editor) {
|
||||
splitPropertyDeclaration(element)
|
||||
|
||||
Reference in New Issue
Block a user