Search in sources :

Example 6 with ValueResourceElementWrapper

use of org.jetbrains.android.dom.wrappers.ValueResourceElementWrapper in project android by JetBrains.

the class AndroidResourceRenameResourceProcessor method prepareIdRenaming.

private static void prepareIdRenaming(XmlAttributeValue value, String newName, Map<PsiElement, String> allRenames, AndroidFacet facet) {
    LocalResourceManager manager = facet.getLocalResourceManager();
    allRenames.remove(value);
    String id = AndroidResourceUtil.getResourceNameByReferenceText(value.getValue());
    assert id != null;
    List<XmlAttributeValue> idDeclarations = manager.findIdDeclarations(id);
    for (XmlAttributeValue idDeclaration : idDeclarations) {
        // framework which looks related to elements getting modified multiple times.
        if (!ATTR_ID.equals(((XmlAttribute) idDeclaration.getParent()).getLocalName())) {
            continue;
        }
        allRenames.put(new ValueResourceElementWrapper(idDeclaration), newName);
    }
    String name = AndroidResourceUtil.getResourceNameByReferenceText(newName);
    if (name != null) {
        for (PsiField resField : AndroidResourceUtil.findIdFields(value)) {
            allRenames.put(resField, AndroidResourceUtil.getFieldNameByResourceName(name));
        }
    }
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) LocalResourceManager(org.jetbrains.android.resourceManagers.LocalResourceManager) XmlAttributeValue(com.intellij.psi.xml.XmlAttributeValue) LazyValueResourceElementWrapper(org.jetbrains.android.dom.wrappers.LazyValueResourceElementWrapper) ValueResourceElementWrapper(org.jetbrains.android.dom.wrappers.ValueResourceElementWrapper)

Aggregations

ValueResourceElementWrapper (org.jetbrains.android.dom.wrappers.ValueResourceElementWrapper)6 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)5 XmlAttribute (com.intellij.psi.xml.XmlAttribute)4 XmlTag (com.intellij.psi.xml.XmlTag)4 LazyValueResourceElementWrapper (org.jetbrains.android.dom.wrappers.LazyValueResourceElementWrapper)3 Project (com.intellij.openapi.project.Project)2 LocalResourceManager (org.jetbrains.android.resourceManagers.LocalResourceManager)2 ResourceItem (com.android.ide.common.res2.ResourceItem)1 ResourceType (com.android.resources.ResourceType)1 Predicate (com.google.common.base.Predicate)1 Module (com.intellij.openapi.module.Module)1 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)1 XmlElement (com.intellij.psi.xml.XmlElement)1 RenameDialog (com.intellij.refactoring.rename.RenameDialog)1 RenameJavaVariableProcessor (com.intellij.refactoring.rename.RenameJavaVariableProcessor)1 RenameProcessor (com.intellij.refactoring.rename.RenameProcessor)1 JBCheckBox (com.intellij.ui.components.JBCheckBox)1 UsageInfo (com.intellij.usageView.UsageInfo)1 DomElement (com.intellij.util.xml.DomElement)1 ActionEvent (java.awt.event.ActionEvent)1