Create from Usage: Fix exception in "Create class" quickfix applied to unresolved references in type arguments. Create class body when necessary
#KT-12777 Fixed (cherry picked from commit dc90ec9)
This commit is contained in:
+3
-2
@@ -531,8 +531,9 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
return Math.max(lineBreaksNeeded - lineBreaksPresent, 0)
|
||||
}
|
||||
|
||||
val actualContainer = (containingElement as? KtClassOrObject)?.getOrCreateBody() ?: containingElement
|
||||
|
||||
fun addNextToOriginalElementContainer(addBefore: Boolean): KtNamedDeclaration {
|
||||
val actualContainer = (containingElement as? KtClassOrObject)?.getBody() ?: containingElement
|
||||
val sibling = config.originalElement.parentsWithSelf.first { it.parent == actualContainer }
|
||||
return if (addBefore) {
|
||||
actualContainer.addBefore(declaration, sibling)
|
||||
@@ -543,7 +544,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
}
|
||||
|
||||
val declarationInPlace = when {
|
||||
containingElement.isAncestor(config.originalElement, true) -> {
|
||||
actualContainer.isAncestor(config.originalElement, true) -> {
|
||||
val insertToBlock = containingElement is KtBlockExpression
|
||||
if (insertToBlock) {
|
||||
val parent = containingElement.parent
|
||||
|
||||
Reference in New Issue
Block a user