+ * Example: + *
+ * class A {
+ * def foo
+ * }
+ * new A().getFoo()
+ *
+ * {@code getFoo} references accessor method generated from original foo field.
+ * Suppose we are renaming the field to bar.
+ * Then {@code member} will be the referenced accessor method and {@code newOriginalName} is the new name of the field, i.e. bar.
+ * Given this information {@link DefaultRenameHelper} returns the name of the new accessor
+ * that will be generated after rename, i.e. getBar.
+ *
+ * @param member currently resolved member.
+ * @param newOriginalName new name of original member.
+ * @return name of new member which will be generated after original member changes its name to {@code newOriginalName}.
+ * @see DefaultRenameHelper
+ */
+ @Nullable
+ String getNewMemberName(@NotNull PsiMember member, @NotNull String newOriginalName);
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/impl/DefaultRenameHelper.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/impl/DefaultRenameHelper.kt
new file mode 100644
index 000000000000..d4d94b0ad122
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/impl/DefaultRenameHelper.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2016 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.plugins.groovy.transformations.impl
+
+import com.intellij.psi.PsiMember
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils.getAccessorName
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils.getSetterName
+import org.jetbrains.plugins.groovy.transformations.AstTransformationRenameHelper
+
+class DefaultRenameHelper : AstTransformationRenameHelper {
+
+ override fun getNewMemberName(member: PsiMember, newOriginalName: String): String? {
+ if (member !is GrAccessorMethod) return null
+ return if (member.isSetter) {
+ getSetterName(newOriginalName)
+ }
+ else {
+ getAccessorName(if (member.name.startsWith("is")) "is" else "get", newOriginalName)
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/impl/TraitRenameHelper.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/impl/TraitRenameHelper.kt
new file mode 100644
index 000000000000..15c2a078b92b
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/impl/TraitRenameHelper.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2016 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.plugins.groovy.transformations.impl
+
+import com.intellij.psi.PsiMember
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrTraitField
+import org.jetbrains.plugins.groovy.lang.psi.util.GrTraitUtil
+import org.jetbrains.plugins.groovy.transformations.AstTransformationRenameHelper
+
+class TraitRenameHelper : AstTransformationRenameHelper {
+
+ override fun getNewMemberName(member: PsiMember, newOriginalName: String): String? {
+ if (member !is GrTraitField) return null
+ val prototype = member.prototype
+ val containingClass = prototype.containingClass ?: return null
+ return GrTraitUtil.getTraitFieldPrefix(containingClass) + newOriginalName
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/renameHelper.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/renameHelper.kt
new file mode 100644
index 000000000000..075b65c2b2f2
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/transformations/renameHelper.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2016 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.plugins.groovy.transformations
+
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiMember
+
+fun PsiElement?.getNewNameFromTransformations(newName: String) = (this as? PsiMember)?.let {
+ doGetNewNameFromTransformations(it, newName)
+} ?: newName
+
+private fun doGetNewNameFromTransformations(member: PsiMember, newName: String): String? {
+ @Suppress("LoopToCallChain")
+ for (helper in AstTransformationRenameHelper.EP_NAME.extensions) {
+ val newMemberName = helper.getNewMemberName(member, newName)
+ if (newMemberName != null) return newMemberName
+ }
+ return null
+}
\ No newline at end of file