LetImplementInterfaceFix: fix PIEAE
#EA-214415 Fixed
This commit is contained in:
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
|||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral
|
import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
@@ -73,14 +74,17 @@ class LetImplementInterfaceFix(
|
|||||||
|
|
||||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||||
val element = element ?: return
|
val element = element ?: return
|
||||||
|
val point = element.createSmartPointer()
|
||||||
|
|
||||||
val superTypeEntry = KtPsiFactory(element).createSuperTypeEntry(expectedTypeNameSourceCode)
|
val superTypeEntry = KtPsiFactory(element).createSuperTypeEntry(expectedTypeNameSourceCode)
|
||||||
runWriteAction {
|
runWriteAction {
|
||||||
val entryElement = element.addSuperTypeListEntry(superTypeEntry)
|
val entryElement = element.addSuperTypeListEntry(superTypeEntry)
|
||||||
ShortenReferences.DEFAULT.process(entryElement)
|
ShortenReferences.DEFAULT.process(entryElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val newElement = point.element ?: return
|
||||||
val implementMembersHandler = ImplementMembersHandler()
|
val implementMembersHandler = ImplementMembersHandler()
|
||||||
if (implementMembersHandler.collectMembersToGenerate(element).isEmpty()) return
|
if (implementMembersHandler.collectMembersToGenerate(newElement).isEmpty()) return
|
||||||
|
|
||||||
if (editor != null) {
|
if (editor != null) {
|
||||||
editor.caretModel.moveToOffset(element.textRange.startOffset)
|
editor.caretModel.moveToOffset(element.textRange.startOffset)
|
||||||
|
|||||||
Reference in New Issue
Block a user