2 intentions for moving lambda functions;
moves lambda functions in function calls inside and outside of the
parenthesis: foo({ it }) <-> foo() { it }
This commit is contained in:
@@ -366,6 +366,8 @@ fun main(args: Array<String>) {
|
|||||||
model("intentions/replaceWithInfixFunctionCall", testMethod = "doTestReplaceWithInfixFunctionCall")
|
model("intentions/replaceWithInfixFunctionCall", testMethod = "doTestReplaceWithInfixFunctionCall")
|
||||||
model("intentions/removeCurlyBracesFromTemplate", testMethod = "doTestRemoveCurlyFromTemplate")
|
model("intentions/removeCurlyBracesFromTemplate", testMethod = "doTestRemoveCurlyFromTemplate")
|
||||||
model("intentions/insertCurlyBracestsToTemplate", testMethod = "doTestInsertCurlyToTemplate")
|
model("intentions/insertCurlyBracestsToTemplate", testMethod = "doTestInsertCurlyToTemplate")
|
||||||
|
model("intentions/moveLambdaInsideParentheses", testMethod = "doTestMoveLambdaInsideParentheses")
|
||||||
|
model("intentions/moveLambdaOutsideParentheses", testMethod = "doTestMoveLambdaOutsideParentheses")
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractHierarchyTest>()) {
|
testClass(javaClass<AbstractHierarchyTest>()) {
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
<spot>bar(2, { it * 3 })</spot>
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
<spot>bar(2) { it * 3 }</spot>
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
This intention moves a lambda expression inside parentheses
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
<spot>bar(2) { it * 3 }</spot>
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
<spot>bar(2, { it * 3 })</spot>
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
This intention moves a lambda expression outside parentheses
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -491,6 +491,16 @@
|
|||||||
<category>Kotlin</category>
|
<category>Kotlin</category>
|
||||||
</intentionAction>
|
</intentionAction>
|
||||||
|
|
||||||
|
<intentionAction>
|
||||||
|
<className>org.jetbrains.jet.plugin.intentions.MoveLambdaInsideParenthesesIntention</className>
|
||||||
|
<category>Kotlin</category>
|
||||||
|
</intentionAction>
|
||||||
|
|
||||||
|
<intentionAction>
|
||||||
|
<className>org.jetbrains.jet.plugin.intentions.MoveLambdaOutsideParenthesesIntention</className>
|
||||||
|
<category>Kotlin</category>
|
||||||
|
</intentionAction>
|
||||||
|
|
||||||
<intentionAction>
|
<intentionAction>
|
||||||
<className>org.jetbrains.jet.plugin.intentions.declarations.SplitPropertyDeclarationIntention</className>
|
<className>org.jetbrains.jet.plugin.intentions.declarations.SplitPropertyDeclarationIntention</className>
|
||||||
<category>Kotlin</category>
|
<category>Kotlin</category>
|
||||||
|
|||||||
@@ -233,6 +233,10 @@ replace.with.dot.qualified.method.call.intention=Replace with simple method call
|
|||||||
replace.with.dot.qualified.method.call.intention.family=Replace with simple method call
|
replace.with.dot.qualified.method.call.intention.family=Replace with simple method call
|
||||||
replace.with.infix.function.call.intention=Replace with infix function call
|
replace.with.infix.function.call.intention=Replace with infix function call
|
||||||
replace.with.infix.function.call.intention.family=Replace with infix function call
|
replace.with.infix.function.call.intention.family=Replace with infix function call
|
||||||
|
move.lambda.inside.parentheses=Move lambda function into parentheses
|
||||||
|
move.lambda.inside.parentheses.family=Move lambda function into parentheses
|
||||||
|
move.lambda.outside.parentheses=Move lambda expression out of parentheses
|
||||||
|
move.lambda.outside.parentheses.family=Move lambda expression out of parentheses
|
||||||
|
|
||||||
property.is.implemented.too.many=Has implementations
|
property.is.implemented.too.many=Has implementations
|
||||||
property.is.overridden.too.many=Is overridden in subclasses
|
property.is.overridden.too.many=Is overridden in subclasses
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.plugin.intentions
|
||||||
|
|
||||||
|
import com.intellij.openapi.editor.Editor
|
||||||
|
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||||
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
|
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
|
import org.jetbrains.jet.lang.psi.JetFile
|
||||||
|
|
||||||
|
public class MoveLambdaInsideParenthesesIntention : JetSelfTargetingIntention<JetCallExpression>(
|
||||||
|
"move.lambda.inside.parentheses", javaClass()) {
|
||||||
|
|
||||||
|
override fun isApplicableTo(element: JetCallExpression): Boolean = !element.getFunctionLiteralArguments().isEmpty()
|
||||||
|
|
||||||
|
override fun applyTo(element: JetCallExpression, editor: Editor) {
|
||||||
|
val funName = element.getCalleeExpression()?.getText()
|
||||||
|
if (funName == null) return
|
||||||
|
val sb = StringBuilder()
|
||||||
|
sb.append("(")
|
||||||
|
for (value in element.getValueArguments()) {
|
||||||
|
if (value.getArgumentName() != null) {
|
||||||
|
sb.append("${value.getArgumentName()?.getText()} = ${value.getArgumentExpression()?.getText()},")
|
||||||
|
} else {
|
||||||
|
sb.append("${value.getArgumentExpression()?.getText()},")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (element.getValueArguments().any { it.getArgumentName() != null}) {
|
||||||
|
val context = AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingFile() as JetFile).getBindingContext()
|
||||||
|
val resolvedCall = context[BindingContext.RESOLVED_CALL, element.getCalleeExpression()]
|
||||||
|
val literalName = resolvedCall?.getResultingDescriptor()?.getValueParameters()?.last?.getName().toString()
|
||||||
|
sb.append("$literalName = ")
|
||||||
|
}
|
||||||
|
val newExpression = "$funName${sb.toString()}${element.getFunctionLiteralArguments()[0].getText()})"
|
||||||
|
element.replace(JetPsiFactory.createExpression(element.getProject(),newExpression))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.plugin.intentions
|
||||||
|
|
||||||
|
import com.intellij.openapi.editor.Editor
|
||||||
|
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||||
|
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression
|
||||||
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
|
|
||||||
|
public class MoveLambdaOutsideParenthesesIntention : JetSelfTargetingIntention<JetCallExpression>(
|
||||||
|
"move.lambda.outside.parentheses", javaClass()) {
|
||||||
|
|
||||||
|
override fun isApplicableTo(element: JetCallExpression): Boolean {
|
||||||
|
val args = element.getValueArguments()
|
||||||
|
return args.size > 0 && args.last?.getArgumentExpression() is JetFunctionLiteralExpression
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun applyTo(element: JetCallExpression, editor: Editor) {
|
||||||
|
val args = element.getValueArguments()
|
||||||
|
val literal = args.last!!.getArgumentExpression()?.getText() // we know args.last is non null
|
||||||
|
val callText = element.getText()
|
||||||
|
if (callText == null || literal == null) return
|
||||||
|
val endIndex = Math.max(callText.lastIndexOf(","), callText.indexOf("(") + 1) // in case of single parameter
|
||||||
|
element.replace(JetPsiFactory.createExpression(element.getProject(), "${callText.substring(0,endIndex)})$literal"))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo() {
|
||||||
|
bar(<caret>{ it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(x: Int) {
|
||||||
|
if (x == 1) <caret>{
|
||||||
|
println(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(2) <caret>{
|
||||||
|
it * 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(2, {
|
||||||
|
it * 3
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(2) <caret>{it * 3}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(2, { it * 3 })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(2) <caret>{
|
||||||
|
val x = 3
|
||||||
|
it * x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(2, {
|
||||||
|
val x = 3
|
||||||
|
it * x
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(a = 2) <caret>{
|
||||||
|
val x = 3
|
||||||
|
it * x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(a = 2, b = {
|
||||||
|
val x = 3
|
||||||
|
it * x
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar() <caret>{ it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar({ it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(name1 = 3) <caret>{ it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int->Int) : Int {
|
||||||
|
return name2(name1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(name1 = 3, name2 = { it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int->Int) : Int {
|
||||||
|
return name2(name1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(name1 = 3, name2 = 2, name3 = 1) <caret>{ it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int, name3: Int, name4: Int->Int) : Int {
|
||||||
|
return name4(name1) + name2 + name3
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(name1 = 3, name2 = 2, name3 = 1, name4 = { it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int, name3: Int, name4: Int->Int) : Int {
|
||||||
|
return name4(name1) + name2 + name3
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(3, 2, 1) <caret>{ it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int, name3: Int, name4: Int->Int) : Int {
|
||||||
|
return name4(name1) + name2 + name3
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(3, 2, 1, { it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int, name3: Int, name4: Int->Int) : Int {
|
||||||
|
return name4(name1) + name2 + name3
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar <caret>{ it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int->Int) : Int {
|
||||||
|
return a(1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar({ it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int->Int) : Int {
|
||||||
|
return a(1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo() {
|
||||||
|
bar(<caret>) { it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(x: Int) {
|
||||||
|
if (x == 1) <caret>{
|
||||||
|
println(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(x: Int) {
|
||||||
|
if (x == 1) {
|
||||||
|
println(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun x() <caret>{ println("x") }
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar<caret>(2, { it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar<caret>(2) { it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar<caret>(a = 2, b = { it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar<caret>(a = 2) { it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar<caret>({ it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar() { it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar<caret>(2, {
|
||||||
|
val x = 3
|
||||||
|
it * x
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(2) {
|
||||||
|
val x = 3
|
||||||
|
it * x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: Int, b: Int->Int) {
|
||||||
|
return b(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar<caret>(name1 = 3, name2 = 2, name3 = 1, name4 = { it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int, name3: Int, name4: Int->Int) : Int {
|
||||||
|
return name4(name1) + name2 + name3
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(name1 = 3, name2 = 2, name3 = 1) { it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int, name3: Int, name4: Int->Int) : Int {
|
||||||
|
return name4(name1) + name2 + name3
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar<caret>(3, 2, 1, { it })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int, name3: Int, name4: Int->Int) : Int {
|
||||||
|
return name4(name1) + name2 + name3
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: true
|
||||||
|
fun foo() {
|
||||||
|
bar(3, 2, 1) { it }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(name1: Int, name2: Int, name3: Int, name4: Int->Int) : Int {
|
||||||
|
return name4(name1) + name2 + name3
|
||||||
|
}
|
||||||
@@ -118,6 +118,14 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
|
|||||||
doTestIntention(path, new InsertCurlyBracesToTemplateIntention());
|
doTestIntention(path, new InsertCurlyBracesToTemplateIntention());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void doTestMoveLambdaInsideParentheses(@NotNull String path) throws Exception {
|
||||||
|
doTestIntention(path, new MoveLambdaInsideParenthesesIntention());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doTestMoveLambdaOutsideParentheses(@NotNull String path) throws Exception {
|
||||||
|
doTestIntention(path, new MoveLambdaOutsideParenthesesIntention());
|
||||||
|
}
|
||||||
|
|
||||||
public void doTestConvertMemberToExtension(@NotNull String path) throws Exception {
|
public void doTestConvertMemberToExtension(@NotNull String path) throws Exception {
|
||||||
doTestIntention(path, new ConvertMemberToExtension());
|
doTestIntention(path, new ConvertMemberToExtension());
|
||||||
}
|
}
|
||||||
|
|||||||
+119
-1
@@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.intentions.AbstractCodeTransformationTest;
|
|||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@InnerTestClasses({CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class})
|
@InnerTestClasses({CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class})
|
||||||
public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest {
|
public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest {
|
||||||
@TestMetadata("idea/testData/intentions/branched/folding/ifToAssignment")
|
@TestMetadata("idea/testData/intentions/branched/folding/ifToAssignment")
|
||||||
public static class IfToAssignment extends AbstractCodeTransformationTest {
|
public static class IfToAssignment extends AbstractCodeTransformationTest {
|
||||||
@@ -1362,6 +1362,122 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/intentions/moveLambdaInsideParentheses")
|
||||||
|
public static class MoveLambdaInsideParentheses extends AbstractCodeTransformationTest {
|
||||||
|
public void testAllFilesPresentInMoveLambdaInsideParentheses() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/moveLambdaInsideParentheses"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicable1.kt")
|
||||||
|
public void testInapplicable1() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/inapplicable1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicable2.kt")
|
||||||
|
public void testInapplicable2() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/inapplicable2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda1.kt")
|
||||||
|
public void testMoveLambda1() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda2.kt")
|
||||||
|
public void testMoveLambda2() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda3.kt")
|
||||||
|
public void testMoveLambda3() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda4.kt")
|
||||||
|
public void testMoveLambda4() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda4.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda5.kt")
|
||||||
|
public void testMoveLambda5() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda5.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda6.kt")
|
||||||
|
public void testMoveLambda6() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda6.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda7.kt")
|
||||||
|
public void testMoveLambda7() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda7.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda8.kt")
|
||||||
|
public void testMoveLambda8() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda8.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda9.kt")
|
||||||
|
public void testMoveLambda9() throws Exception {
|
||||||
|
doTestMoveLambdaInsideParentheses("idea/testData/intentions/moveLambdaInsideParentheses/moveLambda9.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/intentions/moveLambdaOutsideParentheses")
|
||||||
|
public static class MoveLambdaOutsideParentheses extends AbstractCodeTransformationTest {
|
||||||
|
public void testAllFilesPresentInMoveLambdaOutsideParentheses() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/moveLambdaOutsideParentheses"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicable1.kt")
|
||||||
|
public void testInapplicable1() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/inapplicable1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicable2.kt")
|
||||||
|
public void testInapplicable2() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/inapplicable2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicable3.kt")
|
||||||
|
public void testInapplicable3() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/inapplicable3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda1.kt")
|
||||||
|
public void testMoveLambda1() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/moveLambda1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda2.kt")
|
||||||
|
public void testMoveLambda2() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/moveLambda2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda3.kt")
|
||||||
|
public void testMoveLambda3() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/moveLambda3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda4.kt")
|
||||||
|
public void testMoveLambda4() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/moveLambda4.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda7.kt")
|
||||||
|
public void testMoveLambda7() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/moveLambda7.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveLambda8.kt")
|
||||||
|
public void testMoveLambda8() throws Exception {
|
||||||
|
doTestMoveLambdaOutsideParentheses("idea/testData/intentions/moveLambdaOutsideParentheses/moveLambda8.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite("CodeTransformationTestGenerated");
|
TestSuite suite = new TestSuite("CodeTransformationTestGenerated");
|
||||||
suite.addTestSuite(IfToAssignment.class);
|
suite.addTestSuite(IfToAssignment.class);
|
||||||
@@ -1389,6 +1505,8 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
|||||||
suite.addTestSuite(ReplaceWithDotQualifiedMethodCall.class);
|
suite.addTestSuite(ReplaceWithDotQualifiedMethodCall.class);
|
||||||
suite.addTestSuite(ReplaceWithInfixFunctionCall.class);
|
suite.addTestSuite(ReplaceWithInfixFunctionCall.class);
|
||||||
suite.addTestSuite(RemoveCurlyBracesFromTemplate.class);
|
suite.addTestSuite(RemoveCurlyBracesFromTemplate.class);
|
||||||
|
suite.addTestSuite(MoveLambdaInsideParentheses.class);
|
||||||
|
suite.addTestSuite(MoveLambdaOutsideParentheses.class);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user