add bound property renaming by renaming xml attribute value

This commit is contained in:
Mikhail Mutcianko
2014-08-03 16:56:21 +04:00
committed by Yan Zhulanow
parent 621193681f
commit 885d963c3f
2 changed files with 9 additions and 2 deletions
@@ -64,7 +64,7 @@ abstract class AndroidUIXmlProcessor(val project: Project) {
protected abstract val androidAppPackage: String
private val fileCache = HashMap<PsiFile, String>()
private var lastCachedPsi: JetFile? = null
var lastCachedPsi: JetFile? = null
protected val fileModificationTime: HashMap<PsiFile, Long> = HashMap()
protected val filesToProcess: Queue<PsiFile> = ConcurrentLinkedQueue()
@@ -59,7 +59,14 @@ public class AndroidRenameProcessor : RenamePsiElementProcessor() {
private fun renameAttributeValue(attribute: XmlAttributeValue, newName: String?, allRenames: MutableMap<PsiElement, String>, scope: SearchScope) {
val element1 = LazyValueResourceElementWrapper.computeLazyElement(attribute);
val processor = ServiceManager.getService(attribute.getProject(), javaClass<AndroidUIXmlProcessor>())
if (element1 == null) return
val id = AndroidResourceUtil.getResourceNameByReferenceText(attribute.getValue()!!)
val oldPropName = AndroidResourceUtil.getResourceNameByReferenceText(attribute.getValue()!!)
val newPropName = processor!!.resourceManager.idToName(newName!!)
val props = processor.lastCachedPsi?.findChildrenByClass(javaClass<JetProperty>())
val matchedProps = props?.filter { it.getName() == oldPropName } ?: arrayListOf()
for (prop in matchedProps) {
allRenames[prop] = newPropName
}
}
}