Rename: Initial support of naming conventions

This commit is contained in:
Alexey Sedunov
2014-08-07 14:32:19 +04:00
parent d226a11c8e
commit 67606c55e7
53 changed files with 804 additions and 158 deletions
@@ -0,0 +1,11 @@
class A(val n: Int) {
fun foo(other: A): Int = n.compareTo(other.n)
}
fun test() {
A(0) foo A(1)
A(0).foo(A(1)) < 0
A(0).foo(A(1)) <= 0
A(0).foo(A(1)) > 0
A(0).foo(A(1)) >= 0
}
@@ -0,0 +1,11 @@
class A(val n: Int) {
fun compareTo(other: A): Int = n.compareTo(other.n)
}
fun test() {
A(0) compareTo A(1)
A(0) < A(1)
A(0) <= A(1)
A(0) > A(1)
A(0) >= A(1)
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "compareTo",
"newName": "foo",
"mainFile": "compareTo.kt"
}
@@ -0,0 +1,9 @@
class A(val n: Int) {
fun foo(k: Int): Boolean = k <= n
}
fun test() {
A(2) foo 1
A(2).foo(1)
!A(2).foo(1)
}
@@ -0,0 +1,9 @@
class A(val n: Int) {
fun contains(k: Int): Boolean = k <= n
}
fun test() {
A(2) contains 1
1 in A(2)
1 !in A(2)
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "contains",
"newName": "foo",
"mainFile": "contains.kt"
}
@@ -0,0 +1,13 @@
class A(val n: Int) {
fun contains(k: Int): Boolean = k <= n
}
fun test() {
A(2) contains 1
1 in A(2)
1 !in A(2)
when (1) {
in A(2) -> {}
!in A(2) -> {}
}
}
@@ -0,0 +1,8 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "contains",
"newName": "foo",
"mainFile": "containsWithConflicts.kt",
"hint": "Naming conventions will be violated after rename\nNaming conventions will be violated after rename"
}
@@ -0,0 +1,11 @@
class A(val n: Int) {
override fun foo(other: Any?): Boolean = other is A && other.n == n
}
fun test() {
A(0).foo(A(1))
!A(0).foo(A(1))
A(0) foo A(1)
A(0) === A(1)
A(0) !== A(1)
}
@@ -0,0 +1,11 @@
class A(val n: Int) {
override fun equals(other: Any?): Boolean = other is A && other.n == n
}
fun test() {
A(0) == A(1)
A(0) != A(1)
A(0) equals A(1)
A(0) === A(1)
A(0) !== A(1)
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "equals",
"newName": "foo",
"mainFile": "equals.kt"
}
@@ -0,0 +1,12 @@
class A(val n: Int, val s: String, val o: Any) {
fun component1(): Int = n
fun component2(): String = s
fun component3(): Any = o
}
fun test() {
val a = A(1, "2", Any())
a.n
a.component1()
val (x, y, z) = a
}
@@ -0,0 +1,8 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "component1",
"newName": "foo",
"mainFile": "explicitComponentFunction.kt",
"hint": "Naming conventions will be violated after rename"
}
@@ -0,0 +1,8 @@
class A(val n: Int) {
fun foo(i: Int): A = A(i)
}
fun test() {
A(1).foo(2)
A(1).foo(2)
}
@@ -0,0 +1,8 @@
class A(val n: Int) {
fun get(i: Int): A = A(i)
}
fun test() {
A(1).get(2)
A(1)[2]
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "get",
"newName": "foo",
"mainFile": "get.kt"
}
@@ -0,0 +1,10 @@
class A(val n: Int) {
fun inc(): A = A(n + 1)
}
fun test() {
var a = A(1)
a.inc()
++a
a++
}
@@ -0,0 +1,8 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "inc",
"newName": "foo",
"mainFile": "inc.kt",
"hint": "Naming conventions will be violated after rename\nNaming conventions will be violated after rename"
}
@@ -0,0 +1,8 @@
class A(val n: Int) {
fun foo(i: Int): A = A(i)
}
fun test() {
A(1).foo(2)
A(1).foo(2)
}
@@ -0,0 +1,8 @@
class A(val n: Int) {
fun invoke(i: Int): A = A(i)
}
fun test() {
A(1).invoke(2)
A(1)(2)
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "invoke",
"newName": "foo",
"mainFile": "invoke.kt"
}
@@ -0,0 +1,8 @@
class A {
public fun iterator(): Iterator<String> = throw IllegalStateException("")
}
fun test() {
for (a in A<String>()) {}
a.iterator()
}
@@ -0,0 +1,8 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "iterator",
"newName": "foo",
"mainFile": "iterator.kt",
"hint": "Naming conventions will be violated after rename"
}
@@ -0,0 +1,12 @@
class A(val n: Int) {
fun foo(m: Int): A = A(n + m)
}
fun test() {
A(1).foo(2)
A(1) foo 2
A(1).foo(2)
var a = A(0)
a = a.foo(1)
}
@@ -0,0 +1,12 @@
class A(val n: Int) {
fun plus(m: Int): A = A(n + m)
}
fun test() {
A(1) + 2
A(1) plus 2
A(1).plus(2)
var a = A(0)
a += 1
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "plus",
"newName": "foo",
"mainFile": "plus.kt"
}
@@ -0,0 +1,11 @@
class A(var n: Int) {
fun foo(m: Int) {
n += m
}
}
fun test() {
val a = A(0)
a.foo(1)
a.foo(1)
}
@@ -0,0 +1,11 @@
class A(var n: Int) {
fun plusAssign(m: Int) {
n += m
}
}
fun test() {
val a = A(0)
a.plusAssign(1)
a += 1
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "plusAssign",
"newName": "foo",
"mainFile": "plusAssign.kt"
}
@@ -0,0 +1,10 @@
class A(val n: Int) {
fun foo(i: Int, a: A) {}
}
fun test() {
var a = A(1)
a.foo(2, A(2))
a.foo(2, A(2))
a[2]
}
@@ -0,0 +1,10 @@
class A(val n: Int) {
fun set(i: Int, a: A) {}
}
fun test() {
var a = A(1)
a.set(2, A(2))
a[2] = A(2)
a[2]
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "set",
"newName": "foo",
"mainFile": "set.kt"
}
@@ -0,0 +1,8 @@
data class A(val foo: Int, val s: String, val o: Any)
fun test() {
val a = A(1, "2", Any())
a.foo
a.component1()
val (x, y, z) = a
}
@@ -0,0 +1,8 @@
data class A(val n: Int, val s: String, val o: Any)
fun test() {
val a = A(1, "2", Any())
a.n
a.component1()
val (x, y, z) = a
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_PROPERTY",
"classFQN": "A",
"oldName": "n",
"newName": "foo",
"mainFile": "synthesizedComponentFunction.kt"
}
@@ -0,0 +1,8 @@
class A(val n: Int) {
fun foo(): A = this
}
fun test() {
A(1).foo()
A(1).foo()
}
@@ -0,0 +1,8 @@
class A(val n: Int) {
fun minus(): A = this
}
fun test() {
A(1).minus()
-A(1)
}
@@ -0,0 +1,7 @@
{
"type": "KOTLIN_FUNCTION",
"classFQN": "A",
"oldName": "minus",
"newName": "foo",
"mainFile": "unaryMinus.kt"
}