diff --git a/platform/lang-impl/src/com/intellij/xml/index/XsdNamespaceBuilder.java b/platform/lang-impl/src/com/intellij/xml/index/XsdNamespaceBuilder.java index b98a605ea2e3..448f373367e0 100644 --- a/platform/lang-impl/src/com/intellij/xml/index/XsdNamespaceBuilder.java +++ b/platform/lang-impl/src/com/intellij/xml/index/XsdNamespaceBuilder.java @@ -19,6 +19,7 @@ package com.intellij.xml.index; import com.intellij.openapi.util.Comparing; import com.intellij.util.xml.NanoXmlUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.io.InputStream; @@ -97,7 +98,7 @@ public class XsdNamespaceBuilder extends NanoXmlUtil.IXMLBuilderAdapter implemen return Comparing.compare(myNamespace, o.myNamespace); } - public int getRating(String tagName, String version) { + public int getRating(@Nullable String tagName, @Nullable String version) { int rate = 0; if (tagName != null && myTags.contains(tagName)) { rate |= 0x02; diff --git a/xml/impl/src/com/intellij/xml/index/XmlNamespaceIndex.java b/xml/impl/src/com/intellij/xml/index/XmlNamespaceIndex.java index 473f27bf187d..cb2035cac55b 100644 --- a/xml/impl/src/com/intellij/xml/index/XmlNamespaceIndex.java +++ b/xml/impl/src/com/intellij/xml/index/XmlNamespaceIndex.java @@ -142,7 +142,7 @@ public class XmlNamespaceIndex extends XmlIndex { public static IndexedRelevantResource guessSchema(String namespace, @Nullable final String tagName, @Nullable final String version, - Module module) { + @Nullable Module module) { if (module == null) return null; @@ -175,7 +175,12 @@ public class XmlNamespaceIndex extends XmlIndex { IndexedRelevantResource resource = guessSchema(namespace, tagName, version, ModuleUtilCore.findModuleForPsiElement(file)); if (resource == null) return null; - PsiFile psiFile = file.getManager().findFile(resource.getFile()); + return findSchemaFile(resource.getFile(), file); + } + + @Nullable + private static XmlFile findSchemaFile(VirtualFile resourceFile, PsiFile baseFile) { + PsiFile psiFile = baseFile.getManager().findFile(resourceFile); return psiFile instanceof XmlFile ? (XmlFile)psiFile : null; } @@ -189,6 +194,6 @@ public class XmlNamespaceIndex extends XmlIndex { String dtdFileName = new File(dtdUri).getName(); List> list = getResourcesByNamespace(dtdFileName, baseFile.getProject(), ModuleUtilCore.findModuleForPsiElement(baseFile)); - return list.isEmpty() ? null : (XmlFile)baseFile.getManager().findFile(list.get(0).getFile()); + return list.isEmpty() ? null : findSchemaFile(list.get(0).getFile(), baseFile); } }