Reformat: CreateLocalVariableActionFactory
This commit is contained in:
+3
-3
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
|
|||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object CreateLocalVariableActionFactory: KotlinSingleIntentionActionFactory() {
|
object CreateLocalVariableActionFactory : KotlinSingleIntentionActionFactory() {
|
||||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||||
val refExpr = QuickFixUtil.getParentElementOfType(diagnostic, KtNameReferenceExpression::class.java) ?: return null
|
val refExpr = QuickFixUtil.getParentElementOfType(diagnostic, KtNameReferenceExpression::class.java) ?: return null
|
||||||
if (refExpr.getQualifiedElement() != refExpr) return null
|
if (refExpr.getQualifiedElement() != refExpr) return null
|
||||||
@@ -47,7 +47,7 @@ object CreateLocalVariableActionFactory: KotlinSingleIntentionActionFactory() {
|
|||||||
.filter { it is KtBlockExpression || it is KtDeclarationWithBody }
|
.filter { it is KtBlockExpression || it is KtDeclarationWithBody }
|
||||||
.firstOrNull() as? KtElement ?: return null
|
.firstOrNull() as? KtElement ?: return null
|
||||||
|
|
||||||
return object: CreateFromUsageFixBase<KtSimpleNameExpression>(refExpr) {
|
return object : CreateFromUsageFixBase<KtSimpleNameExpression>(refExpr) {
|
||||||
override fun getText(): String = KotlinBundle.message("create.local.variable.from.usage", propertyName)
|
override fun getText(): String = KotlinBundle.message("create.local.variable.from.usage", propertyName)
|
||||||
|
|
||||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||||
@@ -71,7 +71,7 @@ object CreateLocalVariableActionFactory: KotlinSingleIntentionActionFactory() {
|
|||||||
)
|
)
|
||||||
val propertyInfo = PropertyInfo(propertyName, TypeInfo.Empty, typeInfo, varExpected, Collections.singletonList(actualContainer))
|
val propertyInfo = PropertyInfo(propertyName, TypeInfo.Empty, typeInfo, varExpected, Collections.singletonList(actualContainer))
|
||||||
|
|
||||||
with (CallableBuilderConfiguration(listOfNotNull(propertyInfo), originalElement, file, editor).createBuilder()) {
|
with(CallableBuilderConfiguration(listOfNotNull(propertyInfo), originalElement, file, editor).createBuilder()) {
|
||||||
placement = CallablePlacement.NoReceiver(actualContainer)
|
placement = CallablePlacement.NoReceiver(actualContainer)
|
||||||
project.executeCommand(text) { build() }
|
project.executeCommand(text) { build() }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user