Create from Usage: Drop "Create package" quick-fix
#KT-7138 Fixed
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||
import java.util.Arrays
|
||||
import java.util.Collections
|
||||
|
||||
public object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFactory<JetSimpleNameExpression>(true) {
|
||||
public object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFactory<JetSimpleNameExpression>() {
|
||||
override fun getElementOfInterest(diagnostic: Diagnostic): JetSimpleNameExpression? {
|
||||
val refExpr = diagnostic.psiElement as? JetSimpleNameExpression ?: return null
|
||||
if (refExpr.getNonStrictParentOfType<JetTypeReference>() != null) return null
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import java.util.Collections
|
||||
|
||||
public object CreateClassFromTypeReferenceActionFactory : CreateClassFromUsageFactory<JetUserType>(true) {
|
||||
public object CreateClassFromTypeReferenceActionFactory : CreateClassFromUsageFactory<JetUserType>() {
|
||||
override fun getElementOfInterest(diagnostic: Diagnostic): JetUserType? {
|
||||
return QuickFixUtil.getParentElementOfType(diagnostic, javaClass<JetUserType>())
|
||||
}
|
||||
|
||||
+2
-13
@@ -22,11 +22,8 @@ import org.jetbrains.kotlin.idea.quickfix.NullQuickFix
|
||||
import org.jetbrains.kotlin.idea.quickfix.QuickFixWithDelegateFactory
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.CreateFromUsageFactory
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.JetUserType
|
||||
|
||||
abstract class CreateClassFromUsageFactory<E : JetElement>(
|
||||
val createPackageIsAvailable: Boolean = false
|
||||
) : CreateFromUsageFactory<E, ClassInfo>() {
|
||||
abstract class CreateClassFromUsageFactory<E : JetElement> : CreateFromUsageFactory<E, ClassInfo>() {
|
||||
protected abstract fun getPossibleClassKinds(element: E, diagnostic: Diagnostic): List<ClassKind>
|
||||
|
||||
override fun createQuickFixes(
|
||||
@@ -46,14 +43,6 @@ abstract class CreateClassFromUsageFactory<E : JetElement>(
|
||||
}
|
||||
}
|
||||
|
||||
if (!createPackageIsAvailable) return classFixes
|
||||
val refExpr = (originalElement as? JetUserType)?.referenceExpression ?: return classFixes
|
||||
val packageFix = QuickFixWithDelegateFactory {
|
||||
quickFixDataFactory(originalElementPointer)?.let {
|
||||
refExpr.getCreatePackageFixIfApplicable(it.targetParent)
|
||||
} ?: NullQuickFix
|
||||
}
|
||||
|
||||
return classFixes + packageFix
|
||||
return classFixes
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user