Pull Up: Do not suggest indirect superinterfaces in the Pull Up dialog. Prefer superclass over superinterface as pull-up target
#KT-9543 Fixed
This commit is contained in:
Generated
-22
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AntConfiguration">
|
||||
<buildFile url="file://$PROJECT_DIR$/compiler/frontend/buildLexer.xml" />
|
||||
<buildFile url="file://$PROJECT_DIR$/build.xml">
|
||||
<antCommandLine value="-J-XX:MaxPermSize=100m" />
|
||||
<maximumHeapSize value="1024" />
|
||||
</buildFile>
|
||||
<buildFile url="file://$PROJECT_DIR$/update_dependencies.xml" />
|
||||
<buildFile url="file://$PROJECT_DIR$/TeamCityBuild.xml">
|
||||
<maximumHeapSize value="512" />
|
||||
</buildFile>
|
||||
<buildFile url="file://$PROJECT_DIR$/idea-runner/runner.xml" />
|
||||
<buildFile url="file://$PROJECT_DIR$/replicate_versions.xml" />
|
||||
<buildFile url="file://$PROJECT_DIR$/libraries/build-docs.xml">
|
||||
<maximumHeapSize value="1024" />
|
||||
<properties>
|
||||
<property name="dokka.path" value="../../dokka" />
|
||||
</properties>
|
||||
</buildFile>
|
||||
</component>
|
||||
</project>
|
||||
@@ -709,3 +709,5 @@ public fun KtClass.createPrimaryConstructorParameterListIfAbsent(): KtParameterL
|
||||
if (parameterList != null) return parameterList
|
||||
return constructor.add(KtPsiFactory(project).createParameterList("()")) as KtParameterList
|
||||
}
|
||||
|
||||
fun PsiNamedElement.isInterfaceClass(): Boolean = this is KtClass && isInterface() || this is PsiClass && isInterface
|
||||
|
||||
+11
-9
@@ -79,14 +79,16 @@ public class KotlinMemberInfoStorage(
|
||||
&& !(it is KtObjectDeclaration && it.isCompanion())
|
||||
&& myFilter.includeMember(it) }
|
||||
.mapTo(temp) { KotlinMemberInfo(it as KtNamedDeclaration) }
|
||||
aClass.getDelegationSpecifiers()
|
||||
.filterIsInstance<KtDelegatorToSuperClass>()
|
||||
.map {
|
||||
val type = context[BindingContext.TYPE, it.typeReference]
|
||||
val classDescriptor = type?.constructor?.declarationDescriptor as? ClassDescriptor
|
||||
classDescriptor?.source?.getPsi() as? KtClass
|
||||
}
|
||||
.filter { it != null && it.isInterface() }
|
||||
.mapTo(temp) { KotlinMemberInfo(it!!, true) }
|
||||
if (aClass == myClass) {
|
||||
aClass.getDelegationSpecifiers()
|
||||
.filterIsInstance<KtDelegatorToSuperClass>()
|
||||
.map {
|
||||
val type = context[BindingContext.TYPE, it.typeReference]
|
||||
val classDescriptor = type?.constructor?.declarationDescriptor as? ClassDescriptor
|
||||
classDescriptor?.source?.getPsi() as? KtClass
|
||||
}
|
||||
.filter { it != null && it.isInterface() }
|
||||
.mapTo(temp) { KotlinMemberInfo(it!!, true) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import com.intellij.refactoring.classMembers.AbstractMemberInfoModel
|
||||
import com.intellij.refactoring.memberPullUp.PullUpProcessor
|
||||
import com.intellij.refactoring.util.DocCommentPolicy
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.idea.core.refactoring.isInterfaceClass
|
||||
import org.jetbrains.kotlin.idea.refactoring.memberInfo.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
@@ -89,7 +90,7 @@ public class KotlinPullUpDialog(
|
||||
|
||||
override fun createMemberInfoModel() = MemberInfoModelImpl()
|
||||
|
||||
override fun getPreselection() = mySuperClasses.firstOrNull()
|
||||
override fun getPreselection() = mySuperClasses.firstOrNull { !it.isInterfaceClass() } ?: mySuperClasses.firstOrNull()
|
||||
|
||||
override fun createMemberSelectionTable(infos: MutableList<KotlinMemberInfo>) =
|
||||
KotlinMemberSelectionTable(infos, null, "Make abstract")
|
||||
|
||||
Reference in New Issue
Block a user