add bound property renaming by renaming xml attribute value
This commit is contained in:
committed by
Yan Zhulanow
parent
621193681f
commit
885d963c3f
+1
-1
@@ -64,7 +64,7 @@ abstract class AndroidUIXmlProcessor(val project: Project) {
|
|||||||
protected abstract val androidAppPackage: String
|
protected abstract val androidAppPackage: String
|
||||||
|
|
||||||
private val fileCache = HashMap<PsiFile, 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 fileModificationTime: HashMap<PsiFile, Long> = HashMap()
|
||||||
|
|
||||||
protected val filesToProcess: Queue<PsiFile> = ConcurrentLinkedQueue()
|
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) {
|
private fun renameAttributeValue(attribute: XmlAttributeValue, newName: String?, allRenames: MutableMap<PsiElement, String>, scope: SearchScope) {
|
||||||
val element1 = LazyValueResourceElementWrapper.computeLazyElement(attribute);
|
val element1 = LazyValueResourceElementWrapper.computeLazyElement(attribute);
|
||||||
|
val processor = ServiceManager.getService(attribute.getProject(), javaClass<AndroidUIXmlProcessor>())
|
||||||
if (element1 == null) return
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user