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

index 74d1b7063d8f7059263c076e8bc28a1519307bda..9ede8a93c4d45f9ef88af913cf51f5c87e25c822 100644 (file)
@@ -24,7 +24,6 @@ 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;
@@ -228,12 +227,6 @@ 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());
-            }
-          }
         }
       }
 
@@ -241,6 +234,13 @@ public class XmlRefCountHolder {
         myHolder.registerIdReference(value);
       }
 
+      String s = value.getValue();
+      if (s != null) {
+        int pos = s.indexOf(':');
+        if (pos > 0) {
+          myHolder.addUsedPrefix(s.substring(0, pos));
+        }
+      }
       super.visitXmlAttributeValue(value);
     }