JspAbsolutePathInspection
authorDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Wed, 21 Dec 2011 12:54:20 +0000 (16:54 +0400)
committerDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Mon, 26 Dec 2011 06:40:03 +0000 (10:40 +0400)
xml/impl/src/com/intellij/codeInsight/completion/ExtendedTagInsertHandler.java
xml/impl/src/com/intellij/xml/DefaultXmlExtension.java
xml/impl/src/com/intellij/xml/XmlExtension.java

index f774f5c7a1fb9fb48077ce849ab62a2d9f227710..644dcb93a2cd2879f2c664f56aff49d0c68850df 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.codeInsight.completion;
 
 import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.featureStatistics.FeatureUsageTracker;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
@@ -26,13 +27,11 @@ import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.xml.XmlFile;
 import com.intellij.psi.xml.XmlTag;
-import com.intellij.psi.xml.XmlDocument;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.xml.XmlElementDescriptor;
 import com.intellij.xml.XmlExtension;
 import com.intellij.xml.XmlSchemaProvider;
 import com.intellij.xml.impl.schema.AnyXmlElementDescriptor;
-import com.intellij.featureStatistics.FeatureUsageTracker;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.Collections;
@@ -126,9 +125,7 @@ public class ExtendedTagInsertHandler extends XmlTagInsertHandler {
 
   @Nullable
   public static String getPrefixByNamespace(XmlFile file, final String namespace) {
-    final XmlDocument document = file.getDocument();
-    assert document != null;
-    final XmlTag tag = document.getRootTag();
+    final XmlTag tag = file.getRootTag();
     return tag == null ? null : tag.getPrefixByNamespace(namespace);
   }
 
index d204ac54e55c4f369ad986824e8d7c348c1d1e99..d9024199edac77735146f730d1c9c85150e9b7c0 100644 (file)
@@ -160,7 +160,7 @@ public class DefaultXmlExtension extends XmlExtension {
   }
 
   public void insertNamespaceDeclaration(@NotNull final XmlFile file,
-                                         @NotNull final Editor editor,
+                                         @Nullable final Editor editor,
                                          @NotNull final Set<String> possibleNamespaces,
                                          @Nullable String nsPrefix,
                                          @Nullable final Runner<String, IncorrectOperationException> runAfter) throws IncorrectOperationException {
@@ -235,7 +235,7 @@ public class DefaultXmlExtension extends XmlExtension {
     }
     XmlUtil.reformatTagStart(rootTag);
     
-    if (namespace.length() == 0) {
+    if (editor != null && namespace.length() == 0) {
       final XmlAttribute xmlAttribute = rootTag.getAttribute(qname);
       if (xmlAttribute != null) {
         final XmlAttributeValue value = xmlAttribute.getValueElement();
index 93b3f22720c8c12ec46b437e7b32abb36a0e8eab..7dcc882d230b120814489cbc32506e272ce758c7 100644 (file)
@@ -92,7 +92,7 @@ public abstract class XmlExtension {
   }
 
   public abstract void insertNamespaceDeclaration(@NotNull final XmlFile file,
-                                                    @NotNull final Editor editor,
+                                                    @Nullable final Editor editor,
                                                     @NonNls @NotNull final Set<String> possibleNamespaces,
                                                     @NonNls @Nullable final String nsPrefix,
                                                     @Nullable Runner<String, IncorrectOperationException> runAfter) throws IncorrectOperationException;