internal val indexedPropertyFqn = "groovy.transform.IndexedProperty"
internal val indexedPropertyOriginInfo = "by @IndexedProperty"
-internal val indexedMethodKind = "groovy.transform.IndexedProperty.kind"
+val indexedMethodKind = "groovy.transform.IndexedProperty.kind"
internal fun GrField.getIndexedComponentType() = CachedValuesManager.getCachedValue(this) {
Result.create(doGetIndexedComponentType(this), containingFile)
<astTransformationSupport
implementation="org.jetbrains.plugins.groovy.transformations.indexedProperty.IndexedPropertyTransformationSupport"
/>
+ <astTransformationRenameHelper implementation="org.jetbrains.plugins.groovy.transformations.impl.IndexedPropertyRenameHelper"/>
<customAnnotationChecker
implementation="org.jetbrains.plugins.groovy.transformations.indexedProperty.IndexedPropertyAnnotationChecker"
/>
--- /dev/null
+/*
+ * 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.GrLightMethodBuilder
+import org.jetbrains.plugins.groovy.transformations.AstTransformationRenameHelper
+import org.jetbrains.plugins.groovy.transformations.indexedProperty.indexedMethodKind
+
+class IndexedPropertyRenameHelper : AstTransformationRenameHelper {
+
+ override fun getNewMemberName(member: PsiMember, newName: String): String? {
+ if (member !is GrLightMethodBuilder || member.methodKind != indexedMethodKind) return null
+ arrayOf("get", "set").filter {
+ member.name.startsWith(it)
+ }.forEach {
+ return it + newName.capitalize()
+ }
+ return null
+ }
+}
\ No newline at end of file
checkHighlighting()
}
}
+
+ void 'test indexed property rename'() {
+ fixture.with {
+ configureByText '_.groovy', '''\
+import groovy.transform.IndexedProperty
+class A {
+ @IndexedProperty List<String> strin<caret>gList
+}
+def a = new A()
+a.stringList
+a.getStringList()
+a.stringList = []
+a.setStringList([])
+a.getStringList(0)
+a.setStringList(0, "")
+'''
+ renameElementAtCaret 'newName'
+ checkResult '''\
+import groovy.transform.IndexedProperty
+class A {
+ @IndexedProperty List<String> newName
+}
+def a = new A()
+a.newName
+a.getNewName()
+a.newName = []
+a.setNewName([])
+a.getNewName(0)
+a.setNewName(0, "")
+'''
+ }
+ }
}