diff --git a/annotations/com/intellij/refactoring/rename/annotations.xml b/annotations/com/intellij/refactoring/rename/annotations.xml
index 7c596a8c959..019c99d18fb 100644
--- a/annotations/com/intellij/refactoring/rename/annotations.xml
+++ b/annotations/com/intellij/refactoring/rename/annotations.xml
@@ -14,4 +14,8 @@
name='com.intellij.refactoring.rename.RenamePsiElementProcessor void prepareRenaming(com.intellij.psi.PsiElement, java.lang.String, java.util.Map<com.intellij.psi.PsiElement,java.lang.String>, com.intellij.psi.search.SearchScope) 3'>
+ -
+
+
\ No newline at end of file
diff --git a/annotations/com/intellij/refactoring/rename/inplace/annotations.xml b/annotations/com/intellij/refactoring/rename/inplace/annotations.xml
new file mode 100644
index 00000000000..772ce204215
--- /dev/null
+++ b/annotations/com/intellij/refactoring/rename/inplace/annotations.xml
@@ -0,0 +1,10 @@
+
+ -
+
+
+ -
+
+
+
\ No newline at end of file
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
index 7cd4c377777..564107ea403 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2013 JetBrains s.r.o.
+ * Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -387,10 +387,12 @@ public class PropertyCodegen extends GenerationStateAware {
}
}
+ @NotNull
public static String getterName(Name propertyName) {
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
}
+ @NotNull
public static String setterName(Name propertyName) {
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
}
diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java
index c0157d27657..be2fc3a4568 100644
--- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java
+++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2013 JetBrains s.r.o.
+ * Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/OverridingUtil.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/OverridingUtil.java
index aab5441bb5d..793728e0e65 100644
--- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/OverridingUtil.java
+++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/OverridingUtil.java
@@ -22,6 +22,7 @@ import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.ReadOnly;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.PropertyAccessorDescriptorImpl;
@@ -748,4 +749,15 @@ public class OverridingUtil {
}
return result;
}
+
+ @NotNull
+ @ReadOnly
+ public static Set getDeepestSuperDeclarations(T functionDescriptor) {
+ Set overriddenDeclarations = getAllOverriddenDeclarations(functionDescriptor);
+ if (overriddenDeclarations.isEmpty()) {
+ return Collections.singleton(functionDescriptor);
+ }
+
+ return filterOutOverriding(overriddenDeclarations);
+ }
}
diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 1fd9b6e8928..18464131428 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -240,6 +240,9 @@
+
diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/changeSignature/JetChangeSignature.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/changeSignature/JetChangeSignature.kt
index c6eddae7818..fed56b8fef7 100644
--- a/idea/src/org/jetbrains/jet/plugin/refactoring/changeSignature/JetChangeSignature.kt
+++ b/idea/src/org/jetbrains/jet/plugin/refactoring/changeSignature/JetChangeSignature.kt
@@ -70,7 +70,7 @@ public class JetChangeSignature(val project: Project,
val closestModifiableDescriptors = getClosestModifiableDescriptors()
assert(!closestModifiableDescriptors.isEmpty(), "Should contain functionDescriptor itself or some of its super declarations")
- val deepestSuperDeclarations = getDeepestSuperDeclarations()
+ val deepestSuperDeclarations = OverridingUtil.getDeepestSuperDeclarations(functionDescriptor)
if (ApplicationManager.getApplication()!!.isUnitTestMode()) {
showChangeSignatureDialog(deepestSuperDeclarations)
return
@@ -112,15 +112,6 @@ public class JetChangeSignature(val project: Project,
}
}
- fun getDeepestSuperDeclarations(): Set {
- val overriddenDeclarations = OverridingUtil.getAllOverriddenDeclarations(functionDescriptor)
- if (overriddenDeclarations.isEmpty()) {
- return Collections.singleton(functionDescriptor)
- }
-
- return OverridingUtil.filterOutOverriding(overriddenDeclarations)
- }
-
private fun showChangeSignatureDialog(descriptorsForSignatureChange: Collection) {
val dialog = createChangeSignatureDialog(descriptorsForSignatureChange)
if (dialog == null) {
@@ -238,5 +229,5 @@ TestOnly public fun getChangeSignatureDialog(project: Project,
bindingContext: BindingContext,
defaultValueContext: PsiElement): JetChangeSignatureDialog? {
val jetChangeSignature = JetChangeSignature(project, functionDescriptor, configuration, bindingContext, defaultValueContext, null)
- return jetChangeSignature.createChangeSignatureDialog(jetChangeSignature.getDeepestSuperDeclarations())
+ return jetChangeSignature.createChangeSignatureDialog(OverridingUtil.getDeepestSuperDeclarations(functionDescriptor))
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/rename/RenameKotlinPropertyProcessor.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/rename/RenameKotlinPropertyProcessor.kt
new file mode 100644
index 00000000000..76c29c44c93
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/refactoring/rename/RenameKotlinPropertyProcessor.kt
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2010-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.refactoring.rename
+
+import com.intellij.refactoring.rename.RenamePsiElementProcessor
+import com.intellij.psi.PsiElement
+import org.jetbrains.jet.lang.psi.JetProperty
+import com.intellij.psi.search.SearchScope
+import com.intellij.openapi.application.ApplicationManager
+import org.jetbrains.jet.asJava.LightClassUtil
+import com.intellij.psi.search.searches.OverridingMethodsSearch
+import com.intellij.openapi.util.Computable
+import org.jetbrains.jet.asJava.LightClassUtil.PropertyAccessorsPsiMethods
+import com.intellij.psi.PsiMethod
+import com.intellij.psi.SyntheticElement
+import com.intellij.refactoring.util.RefactoringUtil
+import com.intellij.refactoring.rename.RenameProcessor
+import org.jetbrains.jet.codegen.PropertyCodegen
+import org.jetbrains.jet.lang.resolve.name.Name
+import com.intellij.usageView.UsageInfo
+import com.intellij.refactoring.listeners.RefactoringElementListener
+import com.intellij.openapi.editor.Editor
+import org.jetbrains.jet.lexer.JetTokens
+import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
+import org.jetbrains.jet.lang.resolve.BindingContextUtils
+import org.jetbrains.jet.lang.resolve.BindingContext
+import org.jetbrains.jet.lang.psi.JetClassOrObject
+import com.intellij.openapi.ui.Messages
+import org.jetbrains.jet.lang.resolve.OverridingUtil
+import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
+import org.jetbrains.jet.asJava.namedUnwrappedElement
+
+public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
+ override fun canProcessElement(element: PsiElement): Boolean = element.namedUnwrappedElement is JetProperty
+
+ /* Can't properly update getters and setters in Java */
+ override fun isInplaceRenameSupported() = false
+
+ override fun substituteElementToRename(element: PsiElement?, editor: Editor?): PsiElement? {
+ val jetProperty = element?.namedUnwrappedElement as? JetProperty
+ if (jetProperty == null) throw IllegalStateException("Can't be for element $element there because of canProcessElement()")
+
+ val deepestSuperProperty = findDeepestOverriddenProperty(jetProperty)
+ if (deepestSuperProperty == null || deepestSuperProperty == jetProperty) {
+ return jetProperty
+ }
+
+ if (ApplicationManager.getApplication()!!.isUnitTestMode()) {
+ return deepestSuperProperty
+ }
+
+ val containsText: String? =
+ deepestSuperProperty.getFqName()?.parent()?.asString() ?:
+ (deepestSuperProperty.getParent() as? JetClassOrObject)?.getName()
+
+ val result = Messages.showYesNoCancelDialog(
+ deepestSuperProperty.getProject(),
+ if (containsText != null) "Do you want to rename base property from \n$containsText" else "Do you want to rename base property",
+ "Rename warning",
+ Messages.getQuestionIcon())
+
+ return when (result) {
+ Messages.YES -> deepestSuperProperty
+ Messages.NO -> jetProperty
+ else -> /* Cancel rename */ null
+ }
+ }
+
+ override fun prepareRenaming(element: PsiElement?, newName: String?, allRenames: MutableMap, scope: SearchScope) {
+ val jetProperty = element?.namedUnwrappedElement as? JetProperty
+ if (jetProperty == null) throw IllegalStateException("Can't be for element $element there because of canProcessElement()")
+
+ val propertyMethods = ApplicationManager.getApplication()!!.runReadAction(Computable {
+ LightClassUtil.getLightClassPropertyMethods(jetProperty)
+ })!!
+
+ for (propertyMethod in propertyMethods) {
+ addRenameElements(propertyMethod, jetProperty.getName(), newName, allRenames, scope)
+ }
+ }
+
+ override fun renameElement(element: PsiElement?, newName: String?, usages: Array, listener: RefactoringElementListener?) {
+ if (element !is JetProperty) {
+ super.renameElement(element, newName, usages, listener)
+ return
+ }
+
+ enum class UsageKind {
+ SIMPLE_PROPERTY_USAGE
+ GETTER_USAGE
+ SETTER_USAGE
+ }
+
+ val oldGetterName = PropertyCodegen.getterName(element.getNameAsName())
+ val oldSetterName = PropertyCodegen.setterName(element.getNameAsName())
+
+ val refKindUsages = usages.toList().groupBy { (usage: UsageInfo): UsageKind ->
+ val refElement = usage.getReference()!!.resolve()
+ if (refElement is PsiMethod) {
+ when (refElement.getName()) {
+ oldGetterName -> UsageKind.GETTER_USAGE
+ oldSetterName -> UsageKind.SETTER_USAGE
+ else -> UsageKind.SIMPLE_PROPERTY_USAGE
+ }
+ }
+ else {
+ UsageKind.SIMPLE_PROPERTY_USAGE
+ }
+ }
+
+ super.renameElement(element, PropertyCodegen.setterName(Name.identifier(newName!!)),
+ refKindUsages[UsageKind.SETTER_USAGE]?.copyToArray() ?: array(),
+ null)
+
+ super.renameElement(element, PropertyCodegen.getterName(Name.identifier(newName)),
+ refKindUsages[UsageKind.GETTER_USAGE]?.copyToArray() ?: array(),
+ null)
+
+ super.renameElement(element, newName,
+ refKindUsages[UsageKind.SIMPLE_PROPERTY_USAGE]?.copyToArray() ?: array(),
+ null)
+
+ listener?.elementRenamed(element)
+ }
+
+ private fun addRenameElements(psiMethod: PsiMethod?,
+ oldName: String?, newName: String?,
+ allRenames: MutableMap,
+ scope: SearchScope) {
+ if (psiMethod == null) return
+
+ OverridingMethodsSearch.search(psiMethod, scope, true).forEach { overrider ->
+ val overriderElement = overrider.namedUnwrappedElement
+
+ if (overriderElement != null && !(overriderElement is SyntheticElement)) {
+ RenameProcessor.assertNonCompileElement(overriderElement)
+
+ val overriderName = overriderElement.getName()
+
+ if (overriderElement is PsiMethod) {
+ if (newName != null && Name.isValidIdentifier(newName)) {
+ val isGetter = overriderElement.getParameterList().getParametersCount() == 0
+ val name = Name.identifier(newName)
+
+ allRenames[overriderElement] = if (isGetter) PropertyCodegen.getterName(name) else PropertyCodegen.setterName(name)
+ }
+ }
+ else {
+ val newOverriderName = RefactoringUtil.suggestNewOverriderName(overriderName, oldName, newName)
+ if (newOverriderName != null) {
+ allRenames[overriderElement] = newOverriderName
+ }
+ }
+ }
+
+ true
+ }
+ }
+
+ private fun findDeepestOverriddenProperty(jetProperty: JetProperty): JetProperty? {
+ if (jetProperty.getModifierList()?.hasModifier(JetTokens.OVERRIDE_KEYWORD) == true) {
+ val bindingContext = AnalyzerFacadeWithCache.getContextForElement(jetProperty)
+ val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, jetProperty]
+
+ if (descriptor != null) {
+ assert(descriptor is PropertyDescriptor, "Property descriptor is expected")
+
+ val supers = OverridingUtil.getDeepestSuperDeclarations(descriptor as PropertyDescriptor)
+
+ // Take one of supers for now - API doesn't support substitute to several elements (IDEA-48796)
+ val deepest = supers.first()
+ if (deepest != descriptor) {
+ val superPsiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, deepest)
+ return superPsiElement as? JetProperty
+ }
+ }
+ }
+
+ return null
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinValProperty/after/RenameKotlinValProperty.kt b/idea/testData/refactoring/rename/renameKotlinValProperty/after/RenameKotlinValProperty.kt
new file mode 100644
index 00000000000..b1ffdefd379
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinValProperty/after/RenameKotlinValProperty.kt
@@ -0,0 +1,29 @@
+package testing.rename
+
+trait AP {
+ val second: Int // <--- Rename base here
+}
+
+public open class BP: AP {
+ override val second: Int get() = 12 // <-- Rename with Java getter here
+}
+
+class CP: BP() {
+ override val second = 2 // <--- Rename overriden here
+}
+
+class CPOther {
+ val first: Int = 111
+}
+
+fun usagesProp() {
+ val b = BP()
+ val a: AP = b
+ val c = CP()
+
+ a.second
+ b.second
+ c.second
+
+ CPOther().first
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinValProperty/after/testing/JavaClient.java b/idea/testData/refactoring/rename/renameKotlinValProperty/after/testing/JavaClient.java
new file mode 100644
index 00000000000..60d5759ffab
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinValProperty/after/testing/JavaClient.java
@@ -0,0 +1,32 @@
+package testing;
+
+import testing.rename.*;
+
+class JavaClient {
+ public void foo(AP ap, DP dp) {
+ ap.getSecond();
+ new BP().getSecond();
+ new CP().getSecond();
+
+ dp.getSecond();
+ new EP().getSecond();
+ new FP().getSecond();
+ }
+
+ public interface DP extends AP {
+ }
+
+ public static class EP implements DP {
+ @Override
+ public int getSecond() {
+ return 3;
+ }
+ }
+
+ public static class FP extends EP {
+ @Override
+ public int getSecond() {
+ return 4;
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinValProperty/before/RenameKotlinValProperty.kt b/idea/testData/refactoring/rename/renameKotlinValProperty/before/RenameKotlinValProperty.kt
new file mode 100644
index 00000000000..47e90bf92ec
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinValProperty/before/RenameKotlinValProperty.kt
@@ -0,0 +1,29 @@
+package testing.rename
+
+trait AP {
+ val first: Int // <--- Rename base here
+}
+
+public open class BP: AP {
+ override val first: Int get() = 12 // <-- Rename with Java getter here
+}
+
+class CP: BP() {
+ override val first = 2 // <--- Rename overriden here
+}
+
+class CPOther {
+ val first: Int = 111
+}
+
+fun usagesProp() {
+ val b = BP()
+ val a: AP = b
+ val c = CP()
+
+ a.first
+ b.first
+ c.first
+
+ CPOther().first
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinValProperty/before/testing/JavaClient.java b/idea/testData/refactoring/rename/renameKotlinValProperty/before/testing/JavaClient.java
new file mode 100644
index 00000000000..44e3ba9c45d
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinValProperty/before/testing/JavaClient.java
@@ -0,0 +1,32 @@
+package testing;
+
+import testing.rename.*;
+
+class JavaClient {
+ public void foo(AP ap, DP dp) {
+ ap.getFirst();
+ new BP().getFirst();
+ new CP().getFirst();
+
+ dp.getFirst();
+ new EP().getFirst();
+ new FP().getFirst();
+ }
+
+ public interface DP extends AP {
+ }
+
+ public static class EP implements DP {
+ @Override
+ public int getFirst() {
+ return 3;
+ }
+ }
+
+ public static class FP extends EP {
+ @Override
+ public int getFirst() {
+ return 4;
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinValProperty/renameAsJavaGetterForExplicitGetter.test b/idea/testData/refactoring/rename/renameKotlinValProperty/renameAsJavaGetterForExplicitGetter.test
new file mode 100644
index 00000000000..7d797059863
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinValProperty/renameAsJavaGetterForExplicitGetter.test
@@ -0,0 +1,6 @@
+{
+ "type": "JAVA_METHOD",
+ "classFQN": "testing.rename.BP",
+ "methodSignature": "int getFirst()",
+ "newName": "second"
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinValProperty/renameBase.test b/idea/testData/refactoring/rename/renameKotlinValProperty/renameBase.test
new file mode 100644
index 00000000000..1c05659839e
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinValProperty/renameBase.test
@@ -0,0 +1,6 @@
+{
+ "type": "KOTLIN_PROPERTY",
+ "classFQN": "testing.rename.AP",
+ "oldName": "first",
+ "newName": "second"
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinValProperty/renameOverriden.test b/idea/testData/refactoring/rename/renameKotlinValProperty/renameOverriden.test
new file mode 100644
index 00000000000..6dc1146a601
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinValProperty/renameOverriden.test
@@ -0,0 +1,6 @@
+{
+ "type": "KOTLIN_PROPERTY",
+ "classFQN": "testing.rename.CP",
+ "oldName": "first",
+ "newName": "second"
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinVarProperty/after/RenameKotlinVarProperty.kt b/idea/testData/refactoring/rename/renameKotlinVarProperty/after/RenameKotlinVarProperty.kt
new file mode 100644
index 00000000000..ac273835aee
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinVarProperty/after/RenameKotlinVarProperty.kt
@@ -0,0 +1,33 @@
+package testing.rename
+
+trait AP {
+ var second: Int // <--- Rename base here, rename as Java getter and setter here
+}
+
+public open class BP: AP {
+ override var second = 1 // <--- Rename overriden here
+}
+
+class CP: BP() {
+ override var second = 2
+}
+
+class CPOther {
+ var first: Int = 111
+}
+
+fun usagesProp() {
+ val b = BP()
+ val a: AP = b
+ val c = CP()
+
+ a.second
+ b.second
+ c.second
+
+ a.second = 1
+ b.second = 2
+ c.second = 3
+
+ CPOther().first
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinVarProperty/after/testing/JavaClient.java b/idea/testData/refactoring/rename/renameKotlinVarProperty/after/testing/JavaClient.java
new file mode 100644
index 00000000000..4692fb607c1
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinVarProperty/after/testing/JavaClient.java
@@ -0,0 +1,36 @@
+package testing;
+
+import testing.rename.*;
+
+class JavaClient {
+ public void foo(AP ap, DP dp) {
+ ap.getSecond();
+ new BP().getSecond();
+ new CP().getSecond();
+
+ dp.getSecond();
+ new EP().getSecond();
+ new FP().getSecond();
+ }
+
+ public interface DP extends AP {
+ }
+
+ public static class EP implements DP {
+ @Override
+ public int getSecond() {
+ return 3;
+ }
+ }
+
+ public static class FP extends EP {
+ @Override
+ public int getSecond() {
+ return 4;
+ }
+
+ @Override
+ public void setSecond(int value) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinVarProperty/before/RenameKotlinVarProperty.kt b/idea/testData/refactoring/rename/renameKotlinVarProperty/before/RenameKotlinVarProperty.kt
new file mode 100644
index 00000000000..94a344dda52
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinVarProperty/before/RenameKotlinVarProperty.kt
@@ -0,0 +1,33 @@
+package testing.rename
+
+trait AP {
+ var first: Int // <--- Rename base here, rename as Java getter and setter here
+}
+
+public open class BP: AP {
+ override var first = 1 // <--- Rename overriden here
+}
+
+class CP: BP() {
+ override var first = 2
+}
+
+class CPOther {
+ var first: Int = 111
+}
+
+fun usagesProp() {
+ val b = BP()
+ val a: AP = b
+ val c = CP()
+
+ a.first
+ b.first
+ c.first
+
+ a.first = 1
+ b.first = 2
+ c.first = 3
+
+ CPOther().first
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinVarProperty/before/testing/JavaClient.java b/idea/testData/refactoring/rename/renameKotlinVarProperty/before/testing/JavaClient.java
new file mode 100644
index 00000000000..3b7790bef8e
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinVarProperty/before/testing/JavaClient.java
@@ -0,0 +1,36 @@
+package testing;
+
+import testing.rename.*;
+
+class JavaClient {
+ public void foo(AP ap, DP dp) {
+ ap.getFirst();
+ new BP().getFirst();
+ new CP().getFirst();
+
+ dp.getFirst();
+ new EP().getFirst();
+ new FP().getFirst();
+ }
+
+ public interface DP extends AP {
+ }
+
+ public static class EP implements DP {
+ @Override
+ public int getFirst() {
+ return 3;
+ }
+ }
+
+ public static class FP extends EP {
+ @Override
+ public int getFirst() {
+ return 4;
+ }
+
+ @Override
+ public void setFirst(int value) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinVarProperty/renameAsJavaGetter.test b/idea/testData/refactoring/rename/renameKotlinVarProperty/renameAsJavaGetter.test
new file mode 100644
index 00000000000..f46433034e1
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinVarProperty/renameAsJavaGetter.test
@@ -0,0 +1,6 @@
+{
+ "type": "JAVA_METHOD",
+ "classFQN": "testing.rename.AP",
+ "methodSignature": "int getFirst()",
+ "newName": "second"
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinVarProperty/renameAsJavaSetter.test b/idea/testData/refactoring/rename/renameKotlinVarProperty/renameAsJavaSetter.test
new file mode 100644
index 00000000000..9e7c32d4031
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinVarProperty/renameAsJavaSetter.test
@@ -0,0 +1,6 @@
+{
+ "type": "JAVA_METHOD",
+ "classFQN": "testing.rename.AP",
+ "methodSignature": "void setFirst(int value)",
+ "newName": "second"
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinVarProperty/renameBase.test b/idea/testData/refactoring/rename/renameKotlinVarProperty/renameBase.test
new file mode 100644
index 00000000000..1c05659839e
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinVarProperty/renameBase.test
@@ -0,0 +1,6 @@
+{
+ "type": "KOTLIN_PROPERTY",
+ "classFQN": "testing.rename.AP",
+ "oldName": "first",
+ "newName": "second"
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/rename/renameKotlinVarProperty/renameOverriden.test b/idea/testData/refactoring/rename/renameKotlinVarProperty/renameOverriden.test
new file mode 100644
index 00000000000..e24e5b24769
--- /dev/null
+++ b/idea/testData/refactoring/rename/renameKotlinVarProperty/renameOverriden.test
@@ -0,0 +1,6 @@
+{
+ "type": "KOTLIN_PROPERTY",
+ "classFQN": "testing.rename.BP",
+ "oldName": "first",
+ "newName": "second"
+}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/plugin/refactoring/rename/RenameTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/refactoring/rename/RenameTestGenerated.java
index 71574a04230..9e4507c0604 100644
--- a/idea/tests/org/jetbrains/jet/plugin/refactoring/rename/RenameTestGenerated.java
+++ b/idea/tests/org/jetbrains/jet/plugin/refactoring/rename/RenameTestGenerated.java
@@ -16,17 +16,11 @@
package org.jetbrains.jet.plugin.refactoring.rename;
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.jetbrains.jet.JetTestUtils;
+import org.jetbrains.jet.test.TestMetadata;
import java.io.File;
import java.util.regex.Pattern;
-import org.jetbrains.jet.JetTestUtils;
-import org.jetbrains.jet.test.InnerTestClasses;
-import org.jetbrains.jet.test.TestMetadata;
-
-import org.jetbrains.jet.plugin.refactoring.rename.AbstractRenameTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@@ -126,4 +120,39 @@ public class RenameTestGenerated extends AbstractRenameTest {
doTest("idea/testData/refactoring/rename/renameKotlinPackageFunctionFromJava/renameKotlinPackageFunctionFromJava.test");
}
+ @TestMetadata("renameKotlinValProperty/renameAsJavaGetterForExplicitGetter.test")
+ public void testRenameKotlinValProperty_RenameAsJavaGetterForExplicitGetter() throws Exception {
+ doTest("idea/testData/refactoring/rename/renameKotlinValProperty/renameAsJavaGetterForExplicitGetter.test");
+ }
+
+ @TestMetadata("renameKotlinValProperty/renameBase.test")
+ public void testRenameKotlinValProperty_RenameBase() throws Exception {
+ doTest("idea/testData/refactoring/rename/renameKotlinValProperty/renameBase.test");
+ }
+
+ @TestMetadata("renameKotlinValProperty/renameOverriden.test")
+ public void testRenameKotlinValProperty_RenameOverriden() throws Exception {
+ doTest("idea/testData/refactoring/rename/renameKotlinValProperty/renameOverriden.test");
+ }
+
+ @TestMetadata("renameKotlinVarProperty/renameAsJavaGetter.test")
+ public void testRenameKotlinVarProperty_RenameAsJavaGetter() throws Exception {
+ doTest("idea/testData/refactoring/rename/renameKotlinVarProperty/renameAsJavaGetter.test");
+ }
+
+ @TestMetadata("renameKotlinVarProperty/renameAsJavaSetter.test")
+ public void testRenameKotlinVarProperty_RenameAsJavaSetter() throws Exception {
+ doTest("idea/testData/refactoring/rename/renameKotlinVarProperty/renameAsJavaSetter.test");
+ }
+
+ @TestMetadata("renameKotlinVarProperty/renameBase.test")
+ public void testRenameKotlinVarProperty_RenameBase() throws Exception {
+ doTest("idea/testData/refactoring/rename/renameKotlinVarProperty/renameBase.test");
+ }
+
+ @TestMetadata("renameKotlinVarProperty/renameOverriden.test")
+ public void testRenameKotlinVarProperty_RenameOverriden() throws Exception {
+ doTest("idea/testData/refactoring/rename/renameKotlinVarProperty/renameOverriden.test");
+ }
+
}