Refactored intentions to replace special name calls with operators

This commit is contained in:
Valentin Kipyatkov
2015-05-12 13:53:27 +03:00
parent fbc3fa2b09
commit 8095aabd42
42 changed files with 172 additions and 390 deletions
@@ -1 +1 @@
org.jetbrains.kotlin.idea.intentions.TestableReplaceBinaryInfixIntention
org.jetbrains.kotlin.idea.intentions.attributeCallReplacements.ReplaceBinaryInfixIntention
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: skipped.defaults
// IS_APPLICABLE: false
fun test() {
class Test{
fun plus(a: Int=1, b: Int=2) : Int = 0
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: vararg.not.last
// IS_APPLICABLE: false
fun test() {
class Test{
fun plus(vararg b: Int, c: Int = 0): Int = 0
@@ -1 +1 @@
org.jetbrains.kotlin.idea.intentions.TestableReplaceContainsIntention
org.jetbrains.kotlin.idea.intentions.attributeCallReplacements.ReplaceContainsIntention
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: invalid.arguments
// IS_APPLICABLE: false
// ERROR: Cannot find a parameter with this name: c
fun test() {
class Test{
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: duplicate.or.missing.arguments
// IS_APPLICABLE: false
// ERROR: No value passed for parameter b
fun test() {
class Test{
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: skipped.defaults
// IS_APPLICABLE: false
fun test() {
class Test{
fun contains(a: Int=1, b: Int=2) : Boolean = true
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: vararg.not.last
// IS_APPLICABLE: false
fun test() {
class Test{
fun contains(vararg b: Int, c: Int = 0): Boolean = true
@@ -1 +1 @@
org.jetbrains.kotlin.idea.intentions.TestableReplaceGetIntention
org.jetbrains.kotlin.idea.intentions.attributeCallReplacements.ReplaceGetIntention
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: duplicate.or.missing.arguments
// IS_APPLICABLE: false
// ERROR: An argument is already passed for this parameter
// ERROR: No value passed for parameter b
fun test() {
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: invalid.arguments
// IS_APPLICABLE: false
// ERROR: Cannot find a parameter with this name: c
fun test() {
class Test{
@@ -1,9 +0,0 @@
// SHOULD_FAIL_WITH: duplicate.or.missing.arguments
// ERROR: No value passed for parameter b
fun test() {
class Test{
fun get(a: Int, b: Int) : Int = 0
}
val test = Test()
test.g<caret>et(0)
}
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: skipped.defaults
// IS_APPLICABLE: false
fun test() {
class Test{
fun get(a: Int=1, b: Int=2) : Int = 0
@@ -1,9 +0,0 @@
fun test() {
class Test{
fun get(a: Int, b: Int, c: Int = 1, d: Int = 1, fn: (i: Int) -> Int) : Int = 0
}
val test = Test()
test.g<caret>et(a=1, c=3, b=2, d=4) { i ->
i
}
}
@@ -1,9 +0,0 @@
fun test() {
class Test{
fun get(a: Int, b: Int, c: Int = 1, d: Int = 1, fn: (i: Int) -> Int) : Int = 0
}
val test = Test()
test[1, 2, 3, 4, { i ->
i
}]
}
@@ -1,7 +0,0 @@
fun test() {
class Test{
fun get(a: Int) : Int = 0
}
val test = Test()
test.g<caret>et(a=1)
}
@@ -1,7 +0,0 @@
fun test() {
class Test{
fun get(a: Int) : Int = 0
}
val test = Test()
test[1]
}
@@ -1,4 +1,4 @@
// SHOULD_FAIL_WITH: vararg.not.last
// IS_APPLICABLE: false
fun test() {
class Test{
fun get(a: Int, vararg b: Int, c: Int = 0) : Int = 0
@@ -1,3 +1,4 @@
// IS_APPLICABLE: false
fun test() {
class Test{
fun get(a: Int = 0, b: Int = 1, c: Int = 2, d: Int = 3) : Int = 0
@@ -1,7 +0,0 @@
fun test() {
class Test{
fun get(a: Int = 0, b: Int = 1, c: Int = 2, d: Int = 3) : Int = 0
}
val test = Test()
test[1, 2, 3]
}
@@ -1 +1 @@
org.jetbrains.kotlin.idea.intentions.TestableReplaceInvokeIntention
org.jetbrains.kotlin.idea.intentions.attributeCallReplacements.ReplaceInvokeIntention
@@ -0,0 +1,7 @@
fun test() {
class Test(val v: Int)
fun Test.invoke(): Unit = Unit
Test(1).i<caret>nvoke()
}
@@ -0,0 +1,7 @@
fun test() {
class Test(val v: Int)
fun Test.invoke(): Unit = Unit
Test(1)<caret>()
}
@@ -1 +1 @@
org.jetbrains.kotlin.idea.intentions.TestableReplaceUnaryPrefixIntention
org.jetbrains.kotlin.idea.intentions.attributeCallReplacements.ReplaceUnaryPrefixIntention
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '-' prefix
// INTENTION_TEXT: Replace with '-' operator
fun test() {
class Test {
fun minus(): Test = Test()
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '-' prefix
// INTENTION_TEXT: Replace with '-' operator
fun test() {
class Test {
fun minus(): Test = Test()
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '!' prefix
// INTENTION_TEXT: Replace with '!' operator
fun test() {
class Test {
fun not(): Test = Test()
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '!' prefix
// INTENTION_TEXT: Replace with '!' operator
fun test() {
class Test {
fun not(): Test = Test()
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '+' prefix
// INTENTION_TEXT: Replace with '+' operator
fun test() {
class Test {
fun plus(): Test = Test()
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '+' prefix
// INTENTION_TEXT: Replace with '+' operator
fun test() {
class Test {
fun plus(): Test = Test()