Minor refactoring
This commit is contained in:
@@ -97,26 +97,21 @@ public class AutoImportFix(element: JetSimpleNameExpression) : JetHintAction<Jet
|
||||
|
||||
private fun createAction(project: Project, editor: Editor) = KotlinAddImportAction(project, editor, element, suggestions)
|
||||
|
||||
companion object {
|
||||
private val ERRORS = setOf(Errors.UNRESOLVED_REFERENCE, Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER)
|
||||
|
||||
public fun createFactory(): JetSingleIntentionActionFactory {
|
||||
return object : JetSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): JetIntentionAction<JetSimpleNameExpression>? {
|
||||
// There could be different psi elements (i.e. JetArrayAccessExpression), but we can fix only JetSimpleNameExpression case
|
||||
val psiElement = diagnostic.getPsiElement()
|
||||
if (psiElement is JetSimpleNameExpression) {
|
||||
return AutoImportFix(psiElement)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
override fun isApplicableForCodeFragment()
|
||||
= true
|
||||
companion object : JetSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): JetIntentionAction<JetSimpleNameExpression>? {
|
||||
// There could be different psi elements (i.e. JetArrayAccessExpression), but we can fix only JetSimpleNameExpression case
|
||||
val psiElement = diagnostic.getPsiElement()
|
||||
if (psiElement is JetSimpleNameExpression) {
|
||||
return AutoImportFix(psiElement)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
override fun isApplicableForCodeFragment() = true
|
||||
|
||||
private val ERRORS = setOf(Errors.UNRESOLVED_REFERENCE, Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER)
|
||||
|
||||
public fun computeSuggestions(element: JetSimpleNameExpression): Collection<DeclarationDescriptor> {
|
||||
if (!element.isValid()) return listOf()
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClas
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateLocalVariableActionFactory
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByRefActionFactory
|
||||
import org.jetbrains.kotlin.idea.quickfix.migration.*
|
||||
import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageFix
|
||||
import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageInWholeProjectFix
|
||||
import org.jetbrains.kotlin.lexer.JetTokens.*
|
||||
@@ -131,9 +130,8 @@ public class QuickFixRegistrar : QuickFixContributor {
|
||||
NO_BACKING_FIELD_CUSTOM_ACCESSORS.registerFactory(changeToPropertyNameFactory)
|
||||
INACCESSIBLE_BACKING_FIELD.registerFactory(changeToPropertyNameFactory)
|
||||
|
||||
val unresolvedReferenceFactory = AutoImportFix.createFactory()
|
||||
UNRESOLVED_REFERENCE.registerFactory(unresolvedReferenceFactory)
|
||||
UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(unresolvedReferenceFactory)
|
||||
UNRESOLVED_REFERENCE.registerFactory(AutoImportFix)
|
||||
UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(AutoImportFix)
|
||||
|
||||
val removeImportFixFactory = RemovePsiElementSimpleFix.createRemoveImportFactory()
|
||||
CONFLICTING_IMPORT.registerFactory(removeImportFixFactory)
|
||||
|
||||
Reference in New Issue
Block a user