Search in sources :

Example 1 with XmlProperty

use of com.intellij.lang.properties.xml.XmlProperty in project intellij-community by JetBrains.

the class ResourceBundlePropertiesUpdateManager method deletePropertyIfExist.

public void deletePropertyIfExist(String key, PropertiesFile file) {
    final IProperty property = file.findPropertyByKey(key);
    if (property != null && myKeysOrder != null) {
        boolean keyExistInOtherPropertiesFiles = false;
        for (PropertiesFile propertiesFile : myResourceBundle.getPropertiesFiles()) {
            if (!propertiesFile.equals(file) && propertiesFile.findPropertyByKey(key) != null) {
                keyExistInOtherPropertiesFiles = true;
                break;
            }
        }
        if (!keyExistInOtherPropertiesFiles) {
            myKeysOrder.remove(key);
        }
    }
    if (property != null) {
        PsiElement anElement = property.getPsiElement();
        if (anElement instanceof PomTargetPsiElement) {
            final PomTarget xmlProperty = ((PomTargetPsiElement) anElement).getTarget();
            LOG.assertTrue(xmlProperty instanceof XmlProperty);
            anElement = ((XmlProperty) xmlProperty).getNavigationElement();
        }
        anElement.delete();
    }
}
Also used : PomTarget(com.intellij.pom.PomTarget) IProperty(com.intellij.lang.properties.IProperty) XmlProperty(com.intellij.lang.properties.xml.XmlProperty) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PsiElement(com.intellij.psi.PsiElement)

Aggregations

IProperty (com.intellij.lang.properties.IProperty)1 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)1 XmlProperty (com.intellij.lang.properties.xml.XmlProperty)1 PomTarget (com.intellij.pom.PomTarget)1 PomTargetPsiElement (com.intellij.pom.PomTargetPsiElement)1 PsiElement (com.intellij.psi.PsiElement)1