IDEA-76958: "Optimize Imports" during commit removes XML namespace declarations
authorDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Mon, 26 Dec 2011 10:33:28 +0000 (14:33 +0400)
committerDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Mon, 26 Dec 2011 10:35:27 +0000 (14:35 +0400)
xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java

index 9ede8a93c4d45f9ef88af913cf51f5c87e25c822..18ed3e1cc0a8db59d3e7f7edf99dd464ce03af14 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.psi.*;
 import com.intellij.psi.impl.source.resolve.reference.impl.providers.IdReferenceProvider;
 import com.intellij.psi.impl.source.xml.PossiblePrefixReference;
 import com.intellij.psi.impl.source.xml.SchemaPrefix;
+import com.intellij.psi.impl.source.xml.SchemaPrefixReference;
 import com.intellij.psi.templateLanguages.OuterLanguageElement;
 import com.intellij.psi.util.CachedValue;
 import com.intellij.psi.util.CachedValueProvider;
@@ -227,6 +228,12 @@ public class XmlRefCountHolder {
           if (r instanceof IdReferenceProvider.GlobalAttributeValueSelfReference /*&& !r.isSoft()*/) {
             updateMap(attribute, value, r.isSoft());
           }
+          else if (r instanceof SchemaPrefixReference) {
+            SchemaPrefix prefix = ((SchemaPrefixReference)r).resolve();
+            if (prefix != null) {
+              myHolder.addUsedPrefix(prefix.getName());
+            }
+          }
         }
       }