diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt
index 1556b1d265f..41b2dd3fc35 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt
@@ -262,7 +262,10 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m
}
fun createPropertySetter(expression: KtExpression): KtPropertyAccessor {
- val property = createProperty("val x get() = 1\nset(value) = TODO()")
+ val property = if (expression is KtBlockExpression)
+ createProperty("val x get() = 1\nset(value) {\n field = value\n }")
+ else
+ createProperty("val x get() = 1\nset(value) = TODO()")
val setter = property.setter!!
val bodyExpression = setter.bodyExpression!!
diff --git a/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/after.kt.template b/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/after.kt.template
new file mode 100644
index 00000000000..828d605ac89
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/after.kt.template
@@ -0,0 +1,5 @@
+var x = 1
+ get() = field
+ set(value) {
+ field = value
+ }
diff --git a/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/before.kt.template b/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/before.kt.template
new file mode 100644
index 00000000000..88be1a7aed2
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/before.kt.template
@@ -0,0 +1 @@
+var x = 1
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/description.html b/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/description.html
new file mode 100644
index 00000000000..fc7ddb23fa2
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertyAccessorsIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention adds a property getter and setter.
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/AddPropertyGetterIntention/after.kt.template b/idea/resources/intentionDescriptions/AddPropertyGetterIntention/after.kt.template
new file mode 100644
index 00000000000..1a671a2855d
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertyGetterIntention/after.kt.template
@@ -0,0 +1,2 @@
+val x = 1
+ get() = field
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/AddPropertyGetterIntention/before.kt.template b/idea/resources/intentionDescriptions/AddPropertyGetterIntention/before.kt.template
new file mode 100644
index 00000000000..562d3a070f6
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertyGetterIntention/before.kt.template
@@ -0,0 +1 @@
+val x = 1
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/AddPropertyGetterIntention/description.html b/idea/resources/intentionDescriptions/AddPropertyGetterIntention/description.html
new file mode 100644
index 00000000000..65ad1c60dc1
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertyGetterIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention adds a property getter.
+
+
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/AddPropertySetterIntention/after.kt.template b/idea/resources/intentionDescriptions/AddPropertySetterIntention/after.kt.template
new file mode 100644
index 00000000000..00b53beb6e5
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertySetterIntention/after.kt.template
@@ -0,0 +1,4 @@
+var x = 1
+ set(value) {
+ field = value
+ }
diff --git a/idea/resources/intentionDescriptions/AddPropertySetterIntention/before.kt.template b/idea/resources/intentionDescriptions/AddPropertySetterIntention/before.kt.template
new file mode 100644
index 00000000000..88be1a7aed2
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertySetterIntention/before.kt.template
@@ -0,0 +1 @@
+var x = 1
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/AddPropertySetterIntention/description.html b/idea/resources/intentionDescriptions/AddPropertySetterIntention/description.html
new file mode 100644
index 00000000000..dda3ceb0045
--- /dev/null
+++ b/idea/resources/intentionDescriptions/AddPropertySetterIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention adds a property setter.
+
+
\ No newline at end of file
diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 58ea2be399e..01318addadd 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -1630,6 +1630,21 @@
Kotlin
+
+ org.jetbrains.kotlin.idea.intentions.AddPropertyAccessorsIntention
+ Kotlin
+
+
+
+ org.jetbrains.kotlin.idea.intentions.AddPropertyGetterIntention
+ Kotlin
+
+
+
+ org.jetbrains.kotlin.idea.intentions.AddPropertySetterIntention
+ Kotlin
+
+
(KtProperty::class.java, createFamilyName(addGetter, addSetter)) {
+
+ override fun applicabilityRange(element: KtProperty): TextRange? {
+ if (element.isLocal || element.isAbstract() || element.hasDelegate() ||
+ element.hasModifier(KtTokens.LATEINIT_KEYWORD) ||
+ element.hasModifier(KtTokens.HEADER_KEYWORD) ||
+ element.hasModifier(KtTokens.CONST_KEYWORD)) {
+ return null
+ }
+ if (addSetter && (!element.isVar || element.setter != null)) return null
+ if (addGetter && element.getter != null) return null
+ return element.nameIdentifier?.textRange
+ }
+
+ override fun applyTo(element: KtProperty, editor: Editor?) {
+ val psiFactory = KtPsiFactory(element)
+ if (addGetter) {
+ val expression = psiFactory.createExpression("field")
+ val getter = psiFactory.createPropertyGetter(expression)
+ if (element.setter != null)
+ element.addBefore(getter, element.setter)
+ else
+ element.add(getter)
+ }
+ if (addSetter) {
+ val expression = psiFactory.createBlock("field = value")
+ val setter = psiFactory.createPropertySetter(expression)
+ element.add(setter)
+ }
+ }
+}
+
+private fun createFamilyName(addGetter: Boolean, addSetter: Boolean): String = when {
+ addGetter && addSetter -> "Add getter and setter"
+ addGetter -> "Add getter"
+ addSetter -> "Add setter"
+ else -> throw AssertionError("At least one from (addGetter, addSetter) should be true")
+}
+
+class AddPropertyAccessorsIntention : AbstractAddAccessorsIntention(true, true), LowPriorityAction
+
+class AddPropertyGetterIntention : AbstractAddAccessorsIntention(true, false)
+
+class AddPropertySetterIntention : AbstractAddAccessorsIntention(false, true)
diff --git a/idea/testData/intentions/addPropertyAccessors/both/.intention b/idea/testData/intentions/addPropertyAccessors/both/.intention
new file mode 100644
index 00000000000..eb5fbe7a82b
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/.intention
@@ -0,0 +1 @@
+org.jetbrains.kotlin.idea.intentions.AddPropertyAccessorsIntention
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/abstract.kt b/idea/testData/intentions/addPropertyAccessors/both/abstract.kt
new file mode 100644
index 00000000000..f7e2d69c718
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/abstract.kt
@@ -0,0 +1,4 @@
+// IS_APPLICABLE: false
+abstract class Test {
+ abstract var x: Int
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/delegate.kt b/idea/testData/intentions/addPropertyAccessors/both/delegate.kt
new file mode 100644
index 00000000000..8990eb2d83d
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/delegate.kt
@@ -0,0 +1,9 @@
+// IS_APPLICABLE: false
+import kotlin.reflect.KProperty
+class Test {
+ var x: String by Delegate()
+}
+class Delegate {
+ operator fun getValue(thisRef: Any?, property: KProperty<*>): String = ""
+ operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {}
+}
diff --git a/idea/testData/intentions/addPropertyAccessors/both/hasAccessor.kt b/idea/testData/intentions/addPropertyAccessors/both/hasAccessor.kt
new file mode 100644
index 00000000000..8e86a2614bf
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/hasAccessor.kt
@@ -0,0 +1,8 @@
+// IS_APPLICABLE: false
+class Test {
+ var x = 1
+ get() = field
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/hasGetter.kt b/idea/testData/intentions/addPropertyAccessors/both/hasGetter.kt
new file mode 100644
index 00000000000..f01acc33015
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/hasGetter.kt
@@ -0,0 +1,5 @@
+// IS_APPLICABLE: false
+class Test {
+ var x = 1
+ get() = field
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/hasSetter.kt b/idea/testData/intentions/addPropertyAccessors/both/hasSetter.kt
new file mode 100644
index 00000000000..a18d0fd5a35
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/hasSetter.kt
@@ -0,0 +1,7 @@
+// IS_APPLICABLE: false
+class Test {
+ var x = 1
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/lateinit.kt b/idea/testData/intentions/addPropertyAccessors/both/lateinit.kt
new file mode 100644
index 00000000000..1c3f3df2b05
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/lateinit.kt
@@ -0,0 +1,5 @@
+// IS_APPLICABLE: false
+class Foo
+class Test {
+ lateinit var x: Foo
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/local.kt b/idea/testData/intentions/addPropertyAccessors/both/local.kt
new file mode 100644
index 00000000000..4e9ed2ad22e
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/local.kt
@@ -0,0 +1,6 @@
+// IS_APPLICABLE: false
+class Test {
+ fun test() {
+ var x = 1
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/top.kt b/idea/testData/intentions/addPropertyAccessors/both/top.kt
new file mode 100644
index 00000000000..30816e19a53
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/top.kt
@@ -0,0 +1 @@
+var x = 1
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/top.kt.after b/idea/testData/intentions/addPropertyAccessors/both/top.kt.after
new file mode 100644
index 00000000000..e7d68448185
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/top.kt.after
@@ -0,0 +1,5 @@
+var x = 1
+ get() = field
+ set(value) {
+ field = value
+ }
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/val.kt b/idea/testData/intentions/addPropertyAccessors/both/val.kt
new file mode 100644
index 00000000000..dc6c15db859
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/val.kt
@@ -0,0 +1,4 @@
+// IS_APPLICABLE: false
+class Test {
+ val x = 1
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/var.kt b/idea/testData/intentions/addPropertyAccessors/both/var.kt
new file mode 100644
index 00000000000..910e3184e74
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/var.kt
@@ -0,0 +1,3 @@
+class Test {
+ var x = 1
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/both/var.kt.after b/idea/testData/intentions/addPropertyAccessors/both/var.kt.after
new file mode 100644
index 00000000000..ee22118537f
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/both/var.kt.after
@@ -0,0 +1,7 @@
+class Test {
+ var x = 1
+ get() = field
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/.intention b/idea/testData/intentions/addPropertyAccessors/getter/.intention
new file mode 100644
index 00000000000..6b78c5a619b
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/.intention
@@ -0,0 +1 @@
+org.jetbrains.kotlin.idea.intentions.AddPropertyGetterIntention
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/abstract.kt b/idea/testData/intentions/addPropertyAccessors/getter/abstract.kt
new file mode 100644
index 00000000000..f7e2d69c718
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/abstract.kt
@@ -0,0 +1,4 @@
+// IS_APPLICABLE: false
+abstract class Test {
+ abstract var x: Int
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/delegate.kt b/idea/testData/intentions/addPropertyAccessors/getter/delegate.kt
new file mode 100644
index 00000000000..8990eb2d83d
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/delegate.kt
@@ -0,0 +1,9 @@
+// IS_APPLICABLE: false
+import kotlin.reflect.KProperty
+class Test {
+ var x: String by Delegate()
+}
+class Delegate {
+ operator fun getValue(thisRef: Any?, property: KProperty<*>): String = ""
+ operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {}
+}
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/hasAccessor.kt b/idea/testData/intentions/addPropertyAccessors/getter/hasAccessor.kt
new file mode 100644
index 00000000000..8e86a2614bf
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/hasAccessor.kt
@@ -0,0 +1,8 @@
+// IS_APPLICABLE: false
+class Test {
+ var x = 1
+ get() = field
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/hasGetter.kt b/idea/testData/intentions/addPropertyAccessors/getter/hasGetter.kt
new file mode 100644
index 00000000000..f01acc33015
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/hasGetter.kt
@@ -0,0 +1,5 @@
+// IS_APPLICABLE: false
+class Test {
+ var x = 1
+ get() = field
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/hasSetter.kt b/idea/testData/intentions/addPropertyAccessors/getter/hasSetter.kt
new file mode 100644
index 00000000000..53c51f43edd
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/hasSetter.kt
@@ -0,0 +1,6 @@
+class Test {
+ var x = 1
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/hasSetter.kt.after b/idea/testData/intentions/addPropertyAccessors/getter/hasSetter.kt.after
new file mode 100644
index 00000000000..ee22118537f
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/hasSetter.kt.after
@@ -0,0 +1,7 @@
+class Test {
+ var x = 1
+ get() = field
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/lateinit.kt b/idea/testData/intentions/addPropertyAccessors/getter/lateinit.kt
new file mode 100644
index 00000000000..1c3f3df2b05
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/lateinit.kt
@@ -0,0 +1,5 @@
+// IS_APPLICABLE: false
+class Foo
+class Test {
+ lateinit var x: Foo
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/local.kt b/idea/testData/intentions/addPropertyAccessors/getter/local.kt
new file mode 100644
index 00000000000..4e9ed2ad22e
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/local.kt
@@ -0,0 +1,6 @@
+// IS_APPLICABLE: false
+class Test {
+ fun test() {
+ var x = 1
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/top.kt b/idea/testData/intentions/addPropertyAccessors/getter/top.kt
new file mode 100644
index 00000000000..30816e19a53
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/top.kt
@@ -0,0 +1 @@
+var x = 1
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/top.kt.after b/idea/testData/intentions/addPropertyAccessors/getter/top.kt.after
new file mode 100644
index 00000000000..86eb6371b86
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/top.kt.after
@@ -0,0 +1,2 @@
+var x = 1
+ get() = field
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/val.kt b/idea/testData/intentions/addPropertyAccessors/getter/val.kt
new file mode 100644
index 00000000000..ee03eb2965b
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/val.kt
@@ -0,0 +1,3 @@
+class Test {
+ val x = 1
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/val.kt.after b/idea/testData/intentions/addPropertyAccessors/getter/val.kt.after
new file mode 100644
index 00000000000..67ce43fb397
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/val.kt.after
@@ -0,0 +1,4 @@
+class Test {
+ val x = 1
+ get() = field
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/var.kt b/idea/testData/intentions/addPropertyAccessors/getter/var.kt
new file mode 100644
index 00000000000..910e3184e74
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/var.kt
@@ -0,0 +1,3 @@
+class Test {
+ var x = 1
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/getter/var.kt.after b/idea/testData/intentions/addPropertyAccessors/getter/var.kt.after
new file mode 100644
index 00000000000..5774c8a5395
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/getter/var.kt.after
@@ -0,0 +1,4 @@
+class Test {
+ var x = 1
+ get() = field
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/.intention b/idea/testData/intentions/addPropertyAccessors/setter/.intention
new file mode 100644
index 00000000000..d919f6ccbf4
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/.intention
@@ -0,0 +1 @@
+org.jetbrains.kotlin.idea.intentions.AddPropertySetterIntention
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/abstract.kt b/idea/testData/intentions/addPropertyAccessors/setter/abstract.kt
new file mode 100644
index 00000000000..f7e2d69c718
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/abstract.kt
@@ -0,0 +1,4 @@
+// IS_APPLICABLE: false
+abstract class Test {
+ abstract var x: Int
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/delegate.kt b/idea/testData/intentions/addPropertyAccessors/setter/delegate.kt
new file mode 100644
index 00000000000..8990eb2d83d
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/delegate.kt
@@ -0,0 +1,9 @@
+// IS_APPLICABLE: false
+import kotlin.reflect.KProperty
+class Test {
+ var x: String by Delegate()
+}
+class Delegate {
+ operator fun getValue(thisRef: Any?, property: KProperty<*>): String = ""
+ operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {}
+}
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/hasAccessor.kt b/idea/testData/intentions/addPropertyAccessors/setter/hasAccessor.kt
new file mode 100644
index 00000000000..8e86a2614bf
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/hasAccessor.kt
@@ -0,0 +1,8 @@
+// IS_APPLICABLE: false
+class Test {
+ var x = 1
+ get() = field
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/hasGetter.kt b/idea/testData/intentions/addPropertyAccessors/setter/hasGetter.kt
new file mode 100644
index 00000000000..5774c8a5395
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/hasGetter.kt
@@ -0,0 +1,4 @@
+class Test {
+ var x = 1
+ get() = field
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/hasGetter.kt.after b/idea/testData/intentions/addPropertyAccessors/setter/hasGetter.kt.after
new file mode 100644
index 00000000000..ee22118537f
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/hasGetter.kt.after
@@ -0,0 +1,7 @@
+class Test {
+ var x = 1
+ get() = field
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/hasSetter.kt b/idea/testData/intentions/addPropertyAccessors/setter/hasSetter.kt
new file mode 100644
index 00000000000..a18d0fd5a35
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/hasSetter.kt
@@ -0,0 +1,7 @@
+// IS_APPLICABLE: false
+class Test {
+ var x = 1
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/lateinit.kt b/idea/testData/intentions/addPropertyAccessors/setter/lateinit.kt
new file mode 100644
index 00000000000..1c3f3df2b05
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/lateinit.kt
@@ -0,0 +1,5 @@
+// IS_APPLICABLE: false
+class Foo
+class Test {
+ lateinit var x: Foo
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/local.kt b/idea/testData/intentions/addPropertyAccessors/setter/local.kt
new file mode 100644
index 00000000000..4e9ed2ad22e
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/local.kt
@@ -0,0 +1,6 @@
+// IS_APPLICABLE: false
+class Test {
+ fun test() {
+ var x = 1
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/top.kt b/idea/testData/intentions/addPropertyAccessors/setter/top.kt
new file mode 100644
index 00000000000..30816e19a53
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/top.kt
@@ -0,0 +1 @@
+var x = 1
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/top.kt.after b/idea/testData/intentions/addPropertyAccessors/setter/top.kt.after
new file mode 100644
index 00000000000..eccca1d5c29
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/top.kt.after
@@ -0,0 +1,4 @@
+var x = 1
+ set(value) {
+ field = value
+ }
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/val.kt b/idea/testData/intentions/addPropertyAccessors/setter/val.kt
new file mode 100644
index 00000000000..dc6c15db859
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/val.kt
@@ -0,0 +1,4 @@
+// IS_APPLICABLE: false
+class Test {
+ val x = 1
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/var.kt b/idea/testData/intentions/addPropertyAccessors/setter/var.kt
new file mode 100644
index 00000000000..910e3184e74
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/var.kt
@@ -0,0 +1,3 @@
+class Test {
+ var x = 1
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/addPropertyAccessors/setter/var.kt.after b/idea/testData/intentions/addPropertyAccessors/setter/var.kt.after
new file mode 100644
index 00000000000..53c51f43edd
--- /dev/null
+++ b/idea/testData/intentions/addPropertyAccessors/setter/var.kt.after
@@ -0,0 +1,6 @@
+class Test {
+ var x = 1
+ set(value) {
+ field = value
+ }
+}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
index 5a74aa93130..244c7613fce 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
@@ -738,6 +738,222 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
}
}
+ @TestMetadata("idea/testData/intentions/addPropertyAccessors")
+ @TestDataPath("$PROJECT_ROOT")
+ @RunWith(JUnit3RunnerWithInners.class)
+ public static class AddPropertyAccessors extends AbstractIntentionTest {
+ public void testAllFilesPresentInAddPropertyAccessors() throws Exception {
+ KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/addPropertyAccessors"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
+ }
+
+ @TestMetadata("idea/testData/intentions/addPropertyAccessors/both")
+ @TestDataPath("$PROJECT_ROOT")
+ @RunWith(JUnit3RunnerWithInners.class)
+ public static class Both extends AbstractIntentionTest {
+ @TestMetadata("abstract.kt")
+ public void testAbstract() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/abstract.kt");
+ doTest(fileName);
+ }
+
+ public void testAllFilesPresentInBoth() throws Exception {
+ KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/addPropertyAccessors/both"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
+ }
+
+ @TestMetadata("delegate.kt")
+ public void testDelegate() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/delegate.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasAccessor.kt")
+ public void testHasAccessor() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/hasAccessor.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasGetter.kt")
+ public void testHasGetter() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/hasGetter.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasSetter.kt")
+ public void testHasSetter() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/hasSetter.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("lateinit.kt")
+ public void testLateinit() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/lateinit.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("local.kt")
+ public void testLocal() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/local.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("top.kt")
+ public void testTop() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/top.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("val.kt")
+ public void testVal() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/val.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("var.kt")
+ public void testVar() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/both/var.kt");
+ doTest(fileName);
+ }
+ }
+
+ @TestMetadata("idea/testData/intentions/addPropertyAccessors/getter")
+ @TestDataPath("$PROJECT_ROOT")
+ @RunWith(JUnit3RunnerWithInners.class)
+ public static class Getter extends AbstractIntentionTest {
+ @TestMetadata("abstract.kt")
+ public void testAbstract() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/abstract.kt");
+ doTest(fileName);
+ }
+
+ public void testAllFilesPresentInGetter() throws Exception {
+ KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/addPropertyAccessors/getter"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
+ }
+
+ @TestMetadata("delegate.kt")
+ public void testDelegate() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/delegate.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasAccessor.kt")
+ public void testHasAccessor() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/hasAccessor.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasGetter.kt")
+ public void testHasGetter() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/hasGetter.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasSetter.kt")
+ public void testHasSetter() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/hasSetter.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("lateinit.kt")
+ public void testLateinit() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/lateinit.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("local.kt")
+ public void testLocal() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/local.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("top.kt")
+ public void testTop() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/top.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("val.kt")
+ public void testVal() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/val.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("var.kt")
+ public void testVar() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/var.kt");
+ doTest(fileName);
+ }
+ }
+
+ @TestMetadata("idea/testData/intentions/addPropertyAccessors/setter")
+ @TestDataPath("$PROJECT_ROOT")
+ @RunWith(JUnit3RunnerWithInners.class)
+ public static class Setter extends AbstractIntentionTest {
+ @TestMetadata("abstract.kt")
+ public void testAbstract() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/abstract.kt");
+ doTest(fileName);
+ }
+
+ public void testAllFilesPresentInSetter() throws Exception {
+ KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/addPropertyAccessors/setter"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
+ }
+
+ @TestMetadata("delegate.kt")
+ public void testDelegate() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/delegate.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasAccessor.kt")
+ public void testHasAccessor() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/hasAccessor.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasGetter.kt")
+ public void testHasGetter() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/hasGetter.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("hasSetter.kt")
+ public void testHasSetter() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/hasSetter.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("lateinit.kt")
+ public void testLateinit() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/lateinit.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("local.kt")
+ public void testLocal() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/local.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("top.kt")
+ public void testTop() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/top.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("val.kt")
+ public void testVal() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/val.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("var.kt")
+ public void testVar() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/setter/var.kt");
+ doTest(fileName);
+ }
+ }
+ }
+
@TestMetadata("idea/testData/intentions/addValOrVar")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)