예제 #1
0
 public String[] knownNamespaces() {
   final PsiElement parentElement = getParent();
   BidirectionalMap<String, String> map = initNamespaceMaps(parentElement);
   Set<String> known = Collections.emptySet();
   if (map != null) {
     known = new HashSet<String>(map.values());
   }
   if (parentElement instanceof XmlTag) {
     if (known.isEmpty()) return ((XmlTag) parentElement).knownNamespaces();
     ContainerUtil.addAll(known, ((XmlTag) parentElement).knownNamespaces());
   } else {
     XmlExtension xmlExtension = XmlExtension.getExtensionByElement(this);
     if (xmlExtension != null) {
       final XmlFile xmlFile = xmlExtension.getContainingFile(this);
       if (xmlFile != null) {
         final XmlTag rootTag = xmlFile.getRootTag();
         if (rootTag != null && rootTag != this) {
           if (known.isEmpty()) return rootTag.knownNamespaces();
           ContainerUtil.addAll(known, rootTag.knownNamespaces());
         }
       }
     }
   }
   return ArrayUtil.toStringArray(known);
 }
예제 #2
0
 @Nullable
 private PsiMetaOwner retrieveOwner(final XmlFile file, final String namespace) {
   if (file == null) {
     return namespace.equals(XmlUtil.getTargetSchemaNsFromTag(this)) ? this : null;
   }
   return file.getDocument();
 }
예제 #3
0
 @Nullable
 private static XmlNSDescriptor getDtdDescriptor(@NotNull XmlFile containingFile) {
   final XmlDocument document = containingFile.getDocument();
   if (document == null) {
     return null;
   }
   final String url = XmlUtil.getDtdUri(document);
   if (url == null) {
     return null;
   }
   return document.getDefaultNSDescriptor(url, true);
 }