From ff29e581dbe1e6e9d341abafa18e54eecf465098 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 26 Sep 2014 19:31:12 +0400 Subject: [PATCH] Create Function From Usage: Add empty lines when inserting new function --- .../createFunction/functionBuilder.kt | 79 +++++++++++-------- .../binaryOperations/afterPlusExtraArgs.kt | 1 + .../binaryOperations/afterPlusMissingArgs.kt | 1 + .../binaryOperations/afterPlusOnLibType.kt | 1 + .../call/afterCallWithLambdaArg.kt | 2 +- .../call/afterCallWithLambdaArgOnly.kt | 2 +- .../createFromUsage/call/afterFunExtraArgs.kt | 1 + .../call/afterFunMissingArgs.kt | 1 + .../call/afterFunOnClassObject.kt | 2 +- .../call/afterFunOnLibObject.kt | 1 + .../createFromUsage/call/afterFunOnLibType.kt | 1 + .../call/afterLocalFunNoReceiver.kt | 1 + .../call/afterMemberFunNoReceiver.kt | 1 + .../call/afterObjectMemberFunNoReceiver.kt | 1 + .../createFromUsage/call/afterThisInClass.kt | 1 + .../call/afterThisInNestedClass1.kt | 1 + .../call/afterThisInNestedClass2.kt | 1 + .../call/afterTopLevelFunNoReceiver.kt | 1 + .../afterCreateComponentFromUsage1.kt | 1 + .../afterCreateComponentFromUsage2.kt | 1 + .../afterCreateComponentFromUsage3.kt | 1 + .../get/afterCreateGetFromUsage1.kt | 1 + .../get/afterCreateGetFromUsage10.kt | 1 + .../get/afterCreateGetFromUsage13.kt | 1 + .../get/afterCreateGetFromUsage2.kt | 3 +- .../get/afterCreateGetFromUsage3.kt | 1 + .../get/afterCreateGetFromUsage4.kt | 1 + .../get/afterCreateGetFromUsage5.kt | 1 + .../get/afterCreateGetFromUsage7.kt | 1 + .../get/afterCreateGetFromUsage8.kt | 1 + .../get/afterCreateGetFromUsage9.kt | 1 + .../hasNext/afterCreateHasNextFromUsage1.kt | 1 + .../hasNext/afterCreateHasNextFromUsage2.kt | 1 + .../invoke/afterInvokeOnLibType.kt | 1 + .../iterator/afterCreateIteratorFromUsage3.kt | 1 + .../next/afterCreateNextFromUsage1.kt | 1 + .../next/afterCreateNextFromUsage2.kt | 1 + .../set/afterCreateSetFromUsage1.kt | 1 + .../set/afterCreateSetFromUsage2.kt | 3 +- .../unaryOperations/afterMinusMissingArgs.kt | 1 + .../unaryOperations/afterMinusOnLibType.kt | 1 + 41 files changed, 90 insertions(+), 36 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/createFromUsage/createFunction/functionBuilder.kt b/idea/src/org/jetbrains/jet/plugin/quickfix/createFromUsage/createFunction/functionBuilder.kt index bba6e602139..f3eb20de8eb 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/createFromUsage/createFunction/functionBuilder.kt +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/createFromUsage/createFunction/functionBuilder.kt @@ -53,6 +53,11 @@ import org.jetbrains.jet.plugin.refactoring.CollectingValidator import org.jetbrains.jet.plugin.util.isUnit import org.jetbrains.jet.plugin.refactoring.runWriteAction import com.intellij.util.ArrayUtil +import com.intellij.psi.PsiWhiteSpace +import org.jetbrains.jet.plugin.refactoring.isMultiLine +import org.jetbrains.jet.plugin.refactoring.getLineCount +import com.intellij.psi.PsiElement +import org.jetbrains.jet.lexer.JetTokens private val TYPE_PARAMETER_LIST_VARIABLE_NAME = "typeParameterList" private val TEMPLATE_FROM_USAGE_FUNCTION_BODY = "New Kotlin Function Body.kt" @@ -238,42 +243,54 @@ class FunctionBuilder(val config: FunctionBuilderConfiguration) { with (config) { val parametersString = functionInfo.parameterInfos.indices.map { i -> "p$i: Any" }.joinToString(", ") val returnTypeString = if (isUnit) "" else ": Any" + val ownerTypeString = if (isExtension) "${receiverTypeCandidate!!.renderedType!!}." else "" val psiFactory = JetPsiFactory(currentFile) - if (isExtension) { - // create as extension function - val ownerTypeString = receiverTypeCandidate!!.renderedType!! - val func = psiFactory.createFunction( - "fun $ownerTypeString.${functionInfo.name}($parametersString)$returnTypeString { }" - ) - return currentFile.add(func) as JetNamedFunction + val func = psiFactory.createFunction("fun $ownerTypeString${functionInfo.name}($parametersString)$returnTypeString { }") + val newLine = psiFactory.createNewLine() + + fun prepend(element: PsiElement, elementBeforeStart: PsiElement): PsiElement { + val parent = elementBeforeStart.getParent()!! + val anchor = PsiTreeUtil.skipSiblingsForward(elementBeforeStart, javaClass()) + val addedElement = parent.addBefore(element, anchor)!! + parent.addAfter(newLine, addedElement) + parent.addAfter(newLine, addedElement) + return addedElement } - else { - // create as regular function - val func = psiFactory.createFunction("fun ${functionInfo.name}($parametersString)$returnTypeString { }") - when (containingElement) { - is JetFile -> { - return currentFile.add(func) as JetNamedFunction - } - - is JetClassOrObject -> { - var classBody = containingElement.getBody() - if (classBody == null) { - classBody = containingElement.add(psiFactory.createEmptyClassBody()) as JetClassBody - containingElement.addBefore(psiFactory.createWhiteSpace(), classBody) + fun append(element: PsiElement, elementAfterEnd: PsiElement, skipInitial: Boolean): PsiElement { + val parent = elementAfterEnd.getParent()!! + val anchor = + if (!skipInitial && elementAfterEnd !is PsiWhiteSpace) { + elementAfterEnd } - val rBrace = classBody!!.getRBrace() - - //TODO: Assert rbrace not null? It can be if the class isn't closed. - return classBody!!.addBefore(func, rBrace) as JetNamedFunction - } - - is JetBlockExpression -> { - return containingElement.addAfter(func, containingElement.getLBrace()) as JetNamedFunction - } - - else -> throw AssertionError("Invalid containing element: ${containingElement.getText()}") + else { + PsiTreeUtil.skipSiblingsBackward(elementAfterEnd, javaClass()) + } + val addedElement = parent.addAfter(element, anchor)!! + if (anchor?.getNode()?.getElementType() != JetTokens.LBRACE) { + parent.addAfter(newLine, anchor) + parent.addAfter(newLine, anchor) } + return addedElement + } + + when (containingElement) { + is JetFile -> return append(func, containingElement.getLastChild()!!, false) as JetNamedFunction + + is JetClassOrObject -> { + var classBody = containingElement.getBody() + if (classBody == null) { + classBody = containingElement.add(psiFactory.createEmptyClassBody()) as JetClassBody + containingElement.addBefore(psiFactory.createWhiteSpace(), classBody) + } + val rBrace = classBody!!.getRBrace() + return (rBrace?.let { append(func, it, true) } + ?: append(func, classBody!!.getLastChild()!!, false)) as JetNamedFunction + } + + is JetBlockExpression -> return prepend(func, containingElement.getLBrace()!!) as JetNamedFunction + + else -> throw AssertionError("Invalid containing element: ${containingElement.getText()}") } } } diff --git a/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusExtraArgs.kt b/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusExtraArgs.kt index 72110a178fc..311a4f413fd 100644 --- a/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusExtraArgs.kt +++ b/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusExtraArgs.kt @@ -2,6 +2,7 @@ class A(val n: T) { fun plus(): A = throw Exception() + fun plus(arg: T): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusMissingArgs.kt b/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusMissingArgs.kt index f7b5bc2aa1c..1a895afde90 100644 --- a/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusMissingArgs.kt +++ b/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusMissingArgs.kt @@ -2,6 +2,7 @@ class A(val n: T) { fun plus(i: Int, s: String): A = throw Exception() + fun plus(arg: T): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusOnLibType.kt b/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusOnLibType.kt index 610eeebfa20..05c5fdc2519 100644 --- a/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusOnLibType.kt +++ b/idea/testData/quickfix/createFromUsage/binaryOperations/afterPlusOnLibType.kt @@ -5,6 +5,7 @@ class A(val n: T) fun test() { val a: A = 2 + A(1) } + fun Int.plus(A: A): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/call/afterCallWithLambdaArg.kt b/idea/testData/quickfix/createFromUsage/call/afterCallWithLambdaArg.kt index 056fe0b071e..7dece4bba31 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterCallWithLambdaArg.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterCallWithLambdaArg.kt @@ -1,10 +1,10 @@ // "Create function 'foo' from usage" "true" class A(val n: T) { - fun foo(arg: T, s: String, function: Function1): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } + } fun test() { diff --git a/idea/testData/quickfix/createFromUsage/call/afterCallWithLambdaArgOnly.kt b/idea/testData/quickfix/createFromUsage/call/afterCallWithLambdaArgOnly.kt index 96a0126f058..8ebf1214a38 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterCallWithLambdaArgOnly.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterCallWithLambdaArgOnly.kt @@ -1,10 +1,10 @@ // "Create function 'foo' from usage" "true" class A(val n: T) { - fun foo(function: Function1): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } + } fun test() { diff --git a/idea/testData/quickfix/createFromUsage/call/afterFunExtraArgs.kt b/idea/testData/quickfix/createFromUsage/call/afterFunExtraArgs.kt index 2a58044d97b..63e5a7b384f 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterFunExtraArgs.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterFunExtraArgs.kt @@ -2,6 +2,7 @@ class A(val n: T) { fun foo(a: Int): A = throw Exception() + fun foo(arg: T, s: String): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/call/afterFunMissingArgs.kt b/idea/testData/quickfix/createFromUsage/call/afterFunMissingArgs.kt index 98794fbb55d..c43a19fb4ea 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterFunMissingArgs.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterFunMissingArgs.kt @@ -2,6 +2,7 @@ class A(val n: T) { fun foo(i: Int, s: String): A = throw Exception() + fun foo(arg: T): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/call/afterFunOnClassObject.kt b/idea/testData/quickfix/createFromUsage/call/afterFunOnClassObject.kt index 57402cb6b9d..5732bd7b504 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterFunOnClassObject.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterFunOnClassObject.kt @@ -2,10 +2,10 @@ class A(val n: T) { class object { - fun foo(i: Int): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } + } } diff --git a/idea/testData/quickfix/createFromUsage/call/afterFunOnLibObject.kt b/idea/testData/quickfix/createFromUsage/call/afterFunOnLibObject.kt index 1a83ac84c42..2c6781152cc 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterFunOnLibObject.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterFunOnLibObject.kt @@ -3,6 +3,7 @@ fun test() { val a: Int = Unit.foo(2) } + fun Unit.foo(i: Int): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/call/afterFunOnLibType.kt b/idea/testData/quickfix/createFromUsage/call/afterFunOnLibType.kt index 524ede7151e..3275f1a4898 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterFunOnLibType.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterFunOnLibType.kt @@ -5,6 +5,7 @@ class A(val n: T) fun test() { val a: A = 2.foo(A(1)) } + fun Int.foo(A: A): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/call/afterLocalFunNoReceiver.kt b/idea/testData/quickfix/createFromUsage/call/afterLocalFunNoReceiver.kt index f85ad47fb0c..770e3388e5b 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterLocalFunNoReceiver.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterLocalFunNoReceiver.kt @@ -4,6 +4,7 @@ fun test() { fun foo(i: Int, s: String): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } + fun nestedTest(): Int { return foo(2, "2") } diff --git a/idea/testData/quickfix/createFromUsage/call/afterMemberFunNoReceiver.kt b/idea/testData/quickfix/createFromUsage/call/afterMemberFunNoReceiver.kt index 1a5e7a1ff09..b7468c39abd 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterMemberFunNoReceiver.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterMemberFunNoReceiver.kt @@ -5,6 +5,7 @@ class A { fun test(): Int { return foo(2, "2") } + fun foo(i: Int, s: String): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/call/afterObjectMemberFunNoReceiver.kt b/idea/testData/quickfix/createFromUsage/call/afterObjectMemberFunNoReceiver.kt index ba21868622d..ad5204af3fb 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterObjectMemberFunNoReceiver.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterObjectMemberFunNoReceiver.kt @@ -5,6 +5,7 @@ class A { fun test(): Int { return foo(2, "2") } + fun foo(i: Int, s: String): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/call/afterThisInClass.kt b/idea/testData/quickfix/createFromUsage/call/afterThisInClass.kt index 1b125a55d90..ccd985dacd6 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterThisInClass.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterThisInClass.kt @@ -4,6 +4,7 @@ class A(val n: T) { fun test(): A { return this.foo(2, "2") } + fun foo(i: Int, s: String): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/call/afterThisInNestedClass1.kt b/idea/testData/quickfix/createFromUsage/call/afterThisInNestedClass1.kt index 1aaaaff6af4..2b10bb4b339 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterThisInNestedClass1.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterThisInNestedClass1.kt @@ -5,6 +5,7 @@ class A(val n: T) { fun test(): A { return this.foo(2, "2") } + fun foo(i: Int, s: String): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/call/afterThisInNestedClass2.kt b/idea/testData/quickfix/createFromUsage/call/afterThisInNestedClass2.kt index 9811ea97b73..74e82ebb3df 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterThisInNestedClass2.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterThisInNestedClass2.kt @@ -6,6 +6,7 @@ class A(val n: T) { return this@A.foo(2, "2") } } + fun foo(i: Int, s: String): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/call/afterTopLevelFunNoReceiver.kt b/idea/testData/quickfix/createFromUsage/call/afterTopLevelFunNoReceiver.kt index 4f706dc17a7..88f106920ba 100644 --- a/idea/testData/quickfix/createFromUsage/call/afterTopLevelFunNoReceiver.kt +++ b/idea/testData/quickfix/createFromUsage/call/afterTopLevelFunNoReceiver.kt @@ -3,6 +3,7 @@ fun test(): Int { return foo(2, "2") } + fun foo(i: Int, s: String): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage1.kt b/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage1.kt index fea659b5f7f..d0b24951abd 100644 --- a/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage1.kt @@ -2,6 +2,7 @@ class Foo { fun component1(): Int { return 0 } fun component2(): Int { return 0 } + fun component3(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage2.kt b/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage2.kt index 654b2b0f728..ba7cdde6b96 100644 --- a/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage2.kt @@ -2,6 +2,7 @@ class Foo { fun component1(): Int { return 0 } fun component2(): Int { return 0 } + fun component3(): String { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage3.kt b/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage3.kt index ec065712113..4292f11f8f4 100644 --- a/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage3.kt +++ b/idea/testData/quickfix/createFromUsage/component/afterCreateComponentFromUsage3.kt @@ -16,6 +16,7 @@ fun Any.component1(): Int { fun foo() { for ((i: Int, j: Int) in Foo()) { } } + fun Any.component2(): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage1.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage1.kt index b9bba27b830..d326224f75a 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage1.kt @@ -3,6 +3,7 @@ class Foo { fun x (y: Foo>) { val z: Iterable = y[""] } + fun get(s: String): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage10.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage10.kt index c382e8ea21f..09e7f9b5b89 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage10.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage10.kt @@ -3,6 +3,7 @@ class Foo { fun x (y: Foo>, w: java.util.ArrayList) { val z: Iterable = y["", w] } + fun get(s: String, w: T): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage13.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage13.kt index 9326291c2b7..54c6df3fe1c 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage13.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage13.kt @@ -7,6 +7,7 @@ class Foo { val z = y["", w] bar(z) } + fun get(s: String, w: ArrayList): String { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage2.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage2.kt index bb3346e55ff..b93a024840c 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage2.kt @@ -2,6 +2,7 @@ fun x (y: Any) { val z: Any = y[""] } + fun Any.get(s: String): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage3.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage3.kt index 7e2eda1e05a..3e823c2e24e 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage3.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage3.kt @@ -3,6 +3,7 @@ class Foo { fun x (y: Foo>) { val z: Iterable = y[""] } + fun get(s: String): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage4.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage4.kt index 1a7a9c74bf6..31d4c0599b7 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage4.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage4.kt @@ -3,6 +3,7 @@ class Foo> { fun x (y: Foo>) { val z: U = y[""] } + fun get(s: String): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage5.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage5.kt index b04845a5917..7c82c49d026 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage5.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage5.kt @@ -3,6 +3,7 @@ class Foo { fun x (y: Foo>, w: Iterable) { val z: Iterable = y["", w] } + fun get(s: String, w: Iterable): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage7.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage7.kt index 74ab6f31993..e4864d2f2b0 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage7.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage7.kt @@ -5,6 +5,7 @@ class Foo { fun x (y: Foo>, w: ArrayList, v: T) { val z: Iterable = y["", w, v] } + fun get(s: String, w: ArrayList, v: T1): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage8.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage8.kt index 5697c984d88..682d5d68df9 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage8.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage8.kt @@ -5,6 +5,7 @@ class Foo { fun x (y: Foo>, w: ArrayList) { val z: Iterable = y["", w] } + fun get(s: String, w: T): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage9.kt b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage9.kt index 595ca53ddba..e8bcc00360b 100644 --- a/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage9.kt +++ b/idea/testData/quickfix/createFromUsage/get/afterCreateGetFromUsage9.kt @@ -5,6 +5,7 @@ class Foo { fun x (y: Foo>, w: ArrayList) { val z: Iterable = y["", w] } + fun get(s: String, w: S): S { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/hasNext/afterCreateHasNextFromUsage1.kt b/idea/testData/quickfix/createFromUsage/hasNext/afterCreateHasNextFromUsage1.kt index 61499fd5802..8c722b9f7da 100644 --- a/idea/testData/quickfix/createFromUsage/hasNext/afterCreateHasNextFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/hasNext/afterCreateHasNextFromUsage1.kt @@ -3,6 +3,7 @@ class FooIterator { fun next(): Int { throw Exception("not implemented") } + fun hasNext(): Boolean { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/hasNext/afterCreateHasNextFromUsage2.kt b/idea/testData/quickfix/createFromUsage/hasNext/afterCreateHasNextFromUsage2.kt index 3ae6aac17ee..b60e370bf75 100644 --- a/idea/testData/quickfix/createFromUsage/hasNext/afterCreateHasNextFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/hasNext/afterCreateHasNextFromUsage2.kt @@ -3,6 +3,7 @@ class FooIterator { fun next(): T { throw Exception("not implemented") } + fun hasNext(): Boolean { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/invoke/afterInvokeOnLibType.kt b/idea/testData/quickfix/createFromUsage/invoke/afterInvokeOnLibType.kt index c57a8a55272..ae46ce07bf9 100644 --- a/idea/testData/quickfix/createFromUsage/invoke/afterInvokeOnLibType.kt +++ b/idea/testData/quickfix/createFromUsage/invoke/afterInvokeOnLibType.kt @@ -5,6 +5,7 @@ class A(val n: T) fun test(): A { return 1(2, "2") } + fun Int.invoke(i: Int, s: String): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/iterator/afterCreateIteratorFromUsage3.kt b/idea/testData/quickfix/createFromUsage/iterator/afterCreateIteratorFromUsage3.kt index 3c7b5edc152..a2c4f227b1b 100644 --- a/idea/testData/quickfix/createFromUsage/iterator/afterCreateIteratorFromUsage3.kt +++ b/idea/testData/quickfix/createFromUsage/iterator/afterCreateIteratorFromUsage3.kt @@ -1,6 +1,7 @@ // "Create function 'next' from usage" "true" class FooIterator { fun hasNext(): Boolean { return false } + fun next(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/next/afterCreateNextFromUsage1.kt b/idea/testData/quickfix/createFromUsage/next/afterCreateNextFromUsage1.kt index c4af609d658..846e0d320d5 100644 --- a/idea/testData/quickfix/createFromUsage/next/afterCreateNextFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/next/afterCreateNextFromUsage1.kt @@ -1,6 +1,7 @@ // "Create function 'next' from usage" "true" class FooIterator { fun hasNext(): Boolean { return false } + fun next(): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/next/afterCreateNextFromUsage2.kt b/idea/testData/quickfix/createFromUsage/next/afterCreateNextFromUsage2.kt index f1232096bc7..c2728c13263 100644 --- a/idea/testData/quickfix/createFromUsage/next/afterCreateNextFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/next/afterCreateNextFromUsage2.kt @@ -1,6 +1,7 @@ // "Create function 'next' from usage" "true" class FooIterator { fun hasNext(): Boolean { return false } + fun next(): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/set/afterCreateSetFromUsage1.kt b/idea/testData/quickfix/createFromUsage/set/afterCreateSetFromUsage1.kt index 89f11450828..61554b0e63f 100644 --- a/idea/testData/quickfix/createFromUsage/set/afterCreateSetFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/set/afterCreateSetFromUsage1.kt @@ -3,6 +3,7 @@ class Foo { fun x (y: Foo>, w: java.util.ArrayList) { y["", w] = w } + fun set(s: String, w: T, value: T) { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/set/afterCreateSetFromUsage2.kt b/idea/testData/quickfix/createFromUsage/set/afterCreateSetFromUsage2.kt index f66da360eab..842df9921fb 100644 --- a/idea/testData/quickfix/createFromUsage/set/afterCreateSetFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/set/afterCreateSetFromUsage2.kt @@ -6,6 +6,7 @@ class Foo { y["", w] = w } } + fun Any.set(s: String, w: ArrayList, value: ArrayList) { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/createFromUsage/unaryOperations/afterMinusMissingArgs.kt b/idea/testData/quickfix/createFromUsage/unaryOperations/afterMinusMissingArgs.kt index 76e4c41ee85..479e01f57cd 100644 --- a/idea/testData/quickfix/createFromUsage/unaryOperations/afterMinusMissingArgs.kt +++ b/idea/testData/quickfix/createFromUsage/unaryOperations/afterMinusMissingArgs.kt @@ -2,6 +2,7 @@ class A(val n: T) { fun minus(n: Int): A = throw Exception() + fun minus(): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/idea/testData/quickfix/createFromUsage/unaryOperations/afterMinusOnLibType.kt b/idea/testData/quickfix/createFromUsage/unaryOperations/afterMinusOnLibType.kt index 75ff700ca2a..7ae56abbd9f 100644 --- a/idea/testData/quickfix/createFromUsage/unaryOperations/afterMinusOnLibType.kt +++ b/idea/testData/quickfix/createFromUsage/unaryOperations/afterMinusOnLibType.kt @@ -3,6 +3,7 @@ fun test() { val a = -false } + fun Boolean.minus(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } \ No newline at end of file