Let Implement Quickfix: Launch "Implement Members" dialog after applying #KT-11836 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
9bf395a4cd
commit
56fd2d28b8
@@ -18,8 +18,10 @@ package org.jetbrains.kotlin.idea.quickfix
|
|||||||
|
|
||||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
|
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
|
import org.jetbrains.kotlin.idea.core.overrideImplement.ImplementMembersHandler
|
||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.containsStarProjections
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.containsStarProjections
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.idea.util.ShortenReferences
|
import org.jetbrains.kotlin.idea.util.ShortenReferences
|
||||||
@@ -73,5 +75,15 @@ class LetImplementInterfaceFix(
|
|||||||
val superTypeEntry = KtPsiFactory(element).createSuperTypeEntry(expectedTypeNameSourceCode)
|
val superTypeEntry = KtPsiFactory(element).createSuperTypeEntry(expectedTypeNameSourceCode)
|
||||||
val entryElement = element.addSuperTypeListEntry(superTypeEntry)
|
val entryElement = element.addSuperTypeListEntry(superTypeEntry)
|
||||||
ShortenReferences.DEFAULT.process(entryElement)
|
ShortenReferences.DEFAULT.process(entryElement)
|
||||||
|
|
||||||
|
val implementMembersHandler = ImplementMembersHandler()
|
||||||
|
if (implementMembersHandler.collectMembersToGenerate(element).isEmpty()) return
|
||||||
|
|
||||||
|
if (editor != null) {
|
||||||
|
editor.caretModel.moveToOffset(element.textRange.startOffset)
|
||||||
|
val containingFile = element.containingFile
|
||||||
|
FileEditorManager.getInstance(project).openFile(containingFile.virtualFile, true)
|
||||||
|
implementMembersHandler.invoke(project, editor, containingFile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,7 @@ fun bar() {
|
|||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface A
|
interface A {
|
||||||
|
fun gav()
|
||||||
|
}
|
||||||
class B
|
class B
|
||||||
@@ -2,12 +2,18 @@
|
|||||||
package let.implement
|
package let.implement
|
||||||
|
|
||||||
fun bar() {
|
fun bar() {
|
||||||
foo(B()<caret>)
|
foo(B())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface A
|
interface A {
|
||||||
class B : A
|
fun gav()
|
||||||
|
}
|
||||||
|
class B : A {
|
||||||
|
override fun gav() {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user