Extract Interface: Red-highlight members inherited from a super-interface when that interface reference itself is not extracted
#KT-15598 Fixed
This commit is contained in:
@@ -483,6 +483,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
|||||||
- [`KT-15639`](https://youtrack.jetbrains.com/issue/KT-15639) Extract Superclass/Interface/Pull Up: Add spaces between 'abstract' modifier and annotations
|
- [`KT-15639`](https://youtrack.jetbrains.com/issue/KT-15639) Extract Superclass/Interface/Pull Up: Add spaces between 'abstract' modifier and annotations
|
||||||
- [`KT-15606`](https://youtrack.jetbrains.com/issue/KT-15606) Extract Interface/Pull Up: Warn about private members with usages in the original class
|
- [`KT-15606`](https://youtrack.jetbrains.com/issue/KT-15606) Extract Interface/Pull Up: Warn about private members with usages in the original class
|
||||||
- [`KT-15635`](https://youtrack.jetbrains.com/issue/KT-15635) Extract Superclass/Interface: Fix bogus visibility warning inside a member when it's being moved as abstract
|
- [`KT-15635`](https://youtrack.jetbrains.com/issue/KT-15635) Extract Superclass/Interface: Fix bogus visibility warning inside a member when it's being moved as abstract
|
||||||
|
- [`KT-15598`](https://youtrack.jetbrains.com/issue/KT-15598) Extract Interface: Red-highlight members inherited from a super-interface when that interface reference itself is not extracted
|
||||||
|
|
||||||
#### Intention actions, inspections and quickfixes
|
#### Intention actions, inspections and quickfixes
|
||||||
|
|
||||||
|
|||||||
+22
@@ -16,15 +16,19 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.ui
|
package org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.ui
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiClass
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.PsiMethod
|
||||||
import com.intellij.refactoring.HelpID
|
import com.intellij.refactoring.HelpID
|
||||||
import com.intellij.refactoring.JavaRefactoringSettings
|
import com.intellij.refactoring.JavaRefactoringSettings
|
||||||
import com.intellij.refactoring.RefactoringBundle
|
import com.intellij.refactoring.RefactoringBundle
|
||||||
|
import com.intellij.refactoring.classMembers.MemberInfoModel
|
||||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.ExtractSuperInfo
|
import org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.ExtractSuperInfo
|
||||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.KotlinExtractInterfaceHandler
|
import org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.KotlinExtractInterfaceHandler
|
||||||
import org.jetbrains.kotlin.idea.refactoring.isConstructorDeclaredProperty
|
import org.jetbrains.kotlin.idea.refactoring.isConstructorDeclaredProperty
|
||||||
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
|
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
|
||||||
import org.jetbrains.kotlin.idea.refactoring.memberInfo.extractClassMembers
|
import org.jetbrains.kotlin.idea.refactoring.memberInfo.extractClassMembers
|
||||||
|
import org.jetbrains.kotlin.idea.refactoring.memberInfo.lightElementForMemberInfo
|
||||||
import org.jetbrains.kotlin.idea.refactoring.pullUp.getInterfaceContainmentVerifier
|
import org.jetbrains.kotlin.idea.refactoring.pullUp.getInterfaceContainmentVerifier
|
||||||
import org.jetbrains.kotlin.idea.refactoring.pullUp.isAbstractInInterface
|
import org.jetbrains.kotlin.idea.refactoring.pullUp.isAbstractInInterface
|
||||||
import org.jetbrains.kotlin.idea.refactoring.pullUp.mustBeAbstractInInterface
|
import org.jetbrains.kotlin.idea.refactoring.pullUp.mustBeAbstractInInterface
|
||||||
@@ -79,6 +83,24 @@ class KotlinExtractInterfaceDialog(
|
|||||||
val member = memberInfo.member
|
val member = memberInfo.member
|
||||||
return member is KtProperty || member.isAbstractInInterface(originalClass) || member.isConstructorDeclaredProperty()
|
return member is KtProperty || member.isAbstractInInterface(originalClass) || member.isConstructorDeclaredProperty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun checkForProblems(memberInfo: KotlinMemberInfo): Int {
|
||||||
|
val result = super.checkForProblems(memberInfo)
|
||||||
|
if (result != MemberInfoModel.OK) return result
|
||||||
|
|
||||||
|
if (!memberInfo.isSuperClass || memberInfo.overrides != false || memberInfo.isChecked) return result
|
||||||
|
|
||||||
|
val psiSuperInterface = lightElementForMemberInfo(memberInfo.member) as? PsiClass ?: return result
|
||||||
|
|
||||||
|
for (info in memberInfos) {
|
||||||
|
if (!info.isChecked || info.isToAbstract) continue
|
||||||
|
val member = info.member ?: continue
|
||||||
|
val psiMethodToCheck = lightElementForMemberInfo(member) as? PsiMethod ?: continue
|
||||||
|
if (psiSuperInterface.findMethodBySignature(psiMethodToCheck, true) != null) return MemberInfoModel.ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user