Functions to objects
This commit is contained in:
@@ -73,11 +73,8 @@ class ChangeVariableTypeFix(element: KtVariableDeclaration, private val type: Ko
|
|||||||
ShortenReferences.DEFAULT.process(toShorten)
|
ShortenReferences.DEFAULT.process(toShorten)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
object ComponentFunctionReturnTypeMismatchFactory : KotlinSingleIntentionActionFactory() {
|
||||||
|
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||||
fun createFactoryForComponentFunctionReturnTypeMismatch(): KotlinSingleIntentionActionFactory {
|
|
||||||
return object : KotlinSingleIntentionActionFactory() {
|
|
||||||
public override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
|
||||||
val entry = ChangeFunctionReturnTypeFix.getDestructuringDeclarationEntryThatTypeMismatchComponentFunction(diagnostic)
|
val entry = ChangeFunctionReturnTypeFix.getDestructuringDeclarationEntryThatTypeMismatchComponentFunction(diagnostic)
|
||||||
val context = entry.analyze()
|
val context = entry.analyze()
|
||||||
val resolvedCall = context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry) ?: return null
|
val resolvedCall = context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry) ?: return null
|
||||||
@@ -86,10 +83,8 @@ class ChangeVariableTypeFix(element: KtVariableDeclaration, private val type: Ko
|
|||||||
return ChangeVariableTypeFix(entry, expectedType)
|
return ChangeVariableTypeFix(entry, expectedType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun createFactoryForPropertyOrReturnTypeMismatchOnOverride(): KotlinIntentionActionsFactory {
|
object PropertyOrReturnTypeMismatchOnOverrideFactory : KotlinIntentionActionsFactory() {
|
||||||
return object : KotlinIntentionActionsFactory() {
|
|
||||||
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
|
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
|
||||||
val actions = LinkedList<IntentionAction>()
|
val actions = LinkedList<IntentionAction>()
|
||||||
|
|
||||||
@@ -134,6 +129,4 @@ class ChangeVariableTypeFix(element: KtVariableDeclaration, private val type: Ko
|
|||||||
return actions
|
return actions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,11 +219,11 @@ class QuickFixRegistrar : QuickFixContributor {
|
|||||||
|
|
||||||
NOT_AN_ANNOTATION_CLASS.registerFactory(MakeClassAnAnnotationClassFix)
|
NOT_AN_ANNOTATION_CLASS.registerFactory(MakeClassAnAnnotationClassFix)
|
||||||
|
|
||||||
val changeVariableTypeFix = ChangeVariableTypeFix.createFactoryForPropertyOrReturnTypeMismatchOnOverride()
|
val changeVariableTypeFix = ChangeVariableTypeFix.PropertyOrReturnTypeMismatchOnOverrideFactory
|
||||||
RETURN_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
|
RETURN_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
|
||||||
PROPERTY_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
|
PROPERTY_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
|
||||||
VAR_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
|
VAR_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
|
||||||
COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH.registerFactory(ChangeVariableTypeFix.createFactoryForComponentFunctionReturnTypeMismatch())
|
COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH.registerFactory(ChangeVariableTypeFix.ComponentFunctionReturnTypeMismatchFactory)
|
||||||
|
|
||||||
val changeFunctionReturnTypeFix = ChangeFunctionReturnTypeFix.createFactoryForChangingReturnTypeToUnit()
|
val changeFunctionReturnTypeFix = ChangeFunctionReturnTypeFix.createFactoryForChangingReturnTypeToUnit()
|
||||||
RETURN_TYPE_MISMATCH.registerFactory(changeFunctionReturnTypeFix)
|
RETURN_TYPE_MISMATCH.registerFactory(changeFunctionReturnTypeFix)
|
||||||
|
|||||||
Reference in New Issue
Block a user