Improve Create property from Usage

Place generated property next to other properties
 #KT-14886 Fixed
This commit is contained in:
Dmitry Gridin
2019-02-26 18:45:12 +03:00
parent 5d599ee2ff
commit c89d1af9fa
35 changed files with 228 additions and 85 deletions
@@ -1,9 +1,9 @@
// "Create abstract property 'foo'" "true"
abstract class A {
fun bar(b: Boolean) {}
abstract val foo: Boolean<caret>
fun bar(b: Boolean) {}
fun test() {
bar(foo)
}
@@ -1,9 +1,9 @@
// "Create abstract property 'A.foo'" "true"
abstract class A {
fun bar(b: Boolean) {}
abstract val foo: Boolean<caret>
fun bar(b: Boolean) {}
fun test(a: A) {
bar(a.foo)
}
@@ -1,9 +1,9 @@
// "Create abstract property 'foo'" "true"
interface A {
fun bar(b: Boolean) {}
val foo: Boolean<caret>
fun bar(b: Boolean) {}
fun test() {
bar(foo)
}
@@ -3,14 +3,14 @@
import package1.A
private val package2.A.foo: Any
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
class X {
init {
val y = package2.A()
val foo = y.foo
}
}
private val package2.A.foo: Any
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
@@ -1,11 +1,11 @@
// "Create extension property 'A.foo'" "true"
// ERROR: Unresolved reference: foo
fun test(): String? {
return A().foo
}
private val A.foo: String?
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
fun test(): String? {
return A().foo
}
@@ -1,11 +1,11 @@
// "Create extension property 'A.foo'" "true"
// ERROR: Unresolved reference: foo
fun test(): String? {
return A().foo
}
private val A.foo: String?
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
fun test(): String? {
return A().foo
}
@@ -1,11 +1,11 @@
private val <T> T.bar: Int
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
// "Create extension property 'T.bar'" "true"
fun consume(n: Int) {}
fun <T> foo(t: T) {
consume(t.bar)
}
private val <T> T.bar: Int
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
@@ -1,4 +1,4 @@
class K {
lateinit var foo: String
lateinit var foo: String
}
@@ -1,5 +1,5 @@
class K {
@JvmField
var foo: String = TODO("initialize me")
}
@@ -1,6 +1,6 @@
@file:JvmName("TestKt")
fun test() {}
@JvmField
var foo: String = TODO("initialize me")
fun test() {}
@@ -3,8 +3,8 @@ import kotlin.properties.ReadOnlyProperty
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
val foo: ReadOnlyProperty<Nothing?, Int>
fun test() {
val x: Int by foo
}
val foo: ReadOnlyProperty<Nothing?, Int>
@@ -1,11 +1,11 @@
private val String?.notExistingVal: Int
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
// "Create extension property 'String?.notExistingVal'" "true"
fun foo(n: Int) {}
fun context(p: String?) {
foo(p.notExistingVal)
}
private val String?.notExistingVal: Int
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
@@ -1,7 +1,7 @@
val `!u00A0`: Int
// "Create property '!u00A0'" "true"
// ERROR: Property must be initialized
fun test() {
val t: Int = `!u00A0`
}
val `!u00A0`: Int
}
@@ -1,9 +1,9 @@
val foo: Cyclic<*>
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
class Cyclic<E : Cyclic<E>>
fun test() {
val c : Cyclic<*> = foo
}
val foo: Cyclic<*>
}
@@ -1,8 +1,8 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
val foo: String
fun test() {
println("a = $foo")
}
val foo: String
}
@@ -0,0 +1,12 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized or be abstract
class Test {
fun test(): Int {
return <caret>foo
}
val foo1 = 1
}
val bar = 1
@@ -0,0 +1,13 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized or be abstract
class Test {
fun test(): Int {
return foo
}
private val foo: Int
val foo1 = 1
}
val bar = 1
@@ -0,0 +1,14 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized or be abstract
class Test {
val foo1 = 1
fun test(): Int {
return <caret>foo
}
val foo2 = 42
}
val bar = 1
@@ -0,0 +1,15 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized or be abstract
class Test {
private val foo: Int
val foo1 = 1
fun test(): Int {
return foo
}
val foo2 = 42
}
val bar = 1
@@ -0,0 +1,12 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized or be abstract
class Test {
val foo1 = 1
fun test(): Int {
return <caret>foo
}
}
val bar = 1
@@ -0,0 +1,13 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized or be abstract
class Test {
private val foo: Int
val foo1 = 1
fun test(): Int {
return foo
}
}
val bar = 1
@@ -1,8 +1,8 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
val foo: Int
fun test(): Int {
return foo
}
val foo: Int
@@ -0,0 +1,8 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
fun test(): Int {
return <caret>foo
}
val bar = 1
@@ -0,0 +1,9 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
fun test(): Int {
return foo
}
val foo: Int
val bar = 1
@@ -0,0 +1,8 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
val bar = 1
fun test(): Int {
return <caret>foo
}
@@ -0,0 +1,9 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
val foo: Int
val bar = 1
fun test(): Int {
return foo
}
@@ -3,8 +3,8 @@
package foo
val foo: Int
fun test(): Int {
return foo
}
val foo: Int
@@ -3,8 +3,8 @@
class A<T>(val n: T) {
companion object {
val foo: Int
val foo: Int
}
}
@@ -1,11 +1,11 @@
// "Create extension property 'Unit.foo'" "true"
// WITH_RUNTIME
fun test() {
val a: Int = Unit.foo
}
private val Unit.foo: Int
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
fun test() {
val a: Int = Unit.foo
}
@@ -1,13 +1,13 @@
// "Create extension property 'Int.foo'" "true"
// WITH_RUNTIME
private val Int.foo: A<Int>
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
class A<T>(val n: T)
fun test() {
val a: A<Int> = 2.foo
}
private val Int.foo: A<Int>
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -1,14 +1,14 @@
// "Create extension property 'Int.foo'" "true"
// WITH_RUNTIME
class A<T>(val n: T)
fun test() {
2.foo = A("2")
}
private var Int.foo: A<String>
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
set() {}
class A<T>(val n: T)
fun test() {
2.foo = A("2")
}