Rename: Implement Rename conflict analysis for properties. Qualify property references to resove rename conflicts when possible

#KT-8732 Fixed
 #KT-12543 Fixed
(cherry picked from commit e23029d)
This commit is contained in:
Alexey Sedunov
2016-06-14 15:07:52 +03:00
parent 43f5da0ece
commit 77b0bb9849
41 changed files with 878 additions and 9 deletions
@@ -0,0 +1,10 @@
package test
class ShadeKotlin {
val name1 = 1;
fun inner() {
val <caret>name2 = 2;
print(name1)
print(name2)
}
}
@@ -0,0 +1,10 @@
package test
class ShadeKotlin {
val name1 = 1;
fun inner() {
val name1 = 2;
print(this.name1)
print(name1)
}
}
@@ -0,0 +1,6 @@
package test
class A {
val foo = 1
val /*rename*/bar = 2
}
@@ -0,0 +1,7 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "foo",
"withRuntime": "true",
"hint": "Property 'foo' is already declared in class 'A'"
}
@@ -0,0 +1,10 @@
package test
class ShadeKotlin {
val name2 = 1;
fun inner() {
val name2 = 2;
print(this.name2)
print(name2)
}
}
@@ -0,0 +1,10 @@
package test
class ShadeKotlin {
val /*rename*/name1 = 1;
fun inner() {
val name2 = 2;
print(name1)
print(name2)
}
}
@@ -0,0 +1,6 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "name2",
"withRuntime": "true"
}
@@ -0,0 +1,17 @@
package test
class X {
val x: Int get() = 1
inner class A {
val xx: Int get() = 1
inner class XX {
val xx: Int get() = 1
fun test() {
this@A.xx
}
}
}
}
@@ -0,0 +1,17 @@
package test
class X {
val x: Int get() = 1
inner class A {
val /*rename*/a: Int get() = 1
inner class XX {
val xx: Int get() = 1
fun test() {
a
}
}
}
}
@@ -0,0 +1,6 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "xx",
"withRuntime": "true"
}
@@ -0,0 +1,17 @@
package test
class X {
val x: Int get() = 1
inner class A {
val x: Int get() = 1
inner class XX {
val xx: Int get() = 1
fun test() {
x
}
}
}
}
@@ -0,0 +1,17 @@
package test
class X {
val x: Int get() = 1
inner class A {
val /*rename*/a: Int get() = 1
inner class XX {
val xx: Int get() = 1
fun test() {
a
}
}
}
}
@@ -0,0 +1,6 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "x",
"withRuntime": "true"
}
@@ -0,0 +1,9 @@
package test
open class A {
val /*rename*/foo = 1
}
open class B : A() {
val bar = 2
}
@@ -0,0 +1,7 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "bar",
"withRuntime": "true",
"hint": "Property after rename will clash with existing property 'bar' in class 'B'"
}
@@ -0,0 +1,9 @@
package test
open class A {
val foo = 1
}
open class B : A() {
val /*rename*/bar = 2
}
@@ -0,0 +1,7 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "foo",
"withRuntime": "true",
"hint": "Property after rename will clash with existing property 'foo' in class 'A'"
}
@@ -0,0 +1,7 @@
package test
open class A(val /*rename*/foo: Int)
open class B : A() {
val bar = 2
}
@@ -0,0 +1,7 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "bar",
"withRuntime": "true",
"hint": "Parameter after rename will clash with existing property 'bar' in class 'B'"
}
@@ -0,0 +1,7 @@
package test
open class A(val foo: Int)
open class B : A() {
val /*rename*/bar = 2
}
@@ -0,0 +1,7 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "foo",
"withRuntime": "true",
"hint": "Property after rename will clash with existing parameter 'foo' in class 'A'"
}
@@ -0,0 +1,5 @@
package test
class Foo(val /*rename*/a: Int) {
val b = 1
}
@@ -0,0 +1,7 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "b",
"withRuntime": "true",
"hint": "Property 'b' is already declared in class 'Foo'"
}
@@ -0,0 +1,5 @@
package test
class Foo(val a: Int) {
val /*rename*/b = 1
}
@@ -0,0 +1,7 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "a",
"withRuntime": "true",
"hint": "Parameter 'a' is already declared in class 'Foo'"
}
@@ -0,0 +1,4 @@
package test
val foo = 1
val /*rename*/bar = 2
@@ -0,0 +1,7 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "foo",
"withRuntime": "true",
"hint": "Property 'foo' is already declared in package 'test'"
}