private static Object[] completeNamespace(PsiElement myElement) {
    final XmlFile file = (XmlFile)myElement.getContainingFile();
    PsiElement parent = myElement.getParent();
    Set<String> list = new HashSet<>();
    for (XmlSchemaProvider provider : XmlSchemaProvider.EP_NAME.getExtensionList()) {
      if (provider.isAvailable(file)) {
        list.addAll(provider.getAvailableNamespaces(file, null));
      }
    }
    if (!list.isEmpty()) {
      return ArrayUtil.toObjectArray(list);
    }
    Set<String> set = new HashSet<>(ExternalResourceManagerEx.getInstanceEx().getUrlsByNamespace(myElement.getProject()).keySet());
    Set<String> fromIndex =
      XmlNamespaceIndex.getAllResources(null, myElement.getProject()).stream()
        .filter(resource -> "xsd".equals(resource.getFile().getExtension())).map(resource -> resource.getValue().getNamespace())
        .collect(Collectors.toSet());
    ContainerUtil.addAllNotNull(set, fromIndex);
    Object[] resourceUrls = set.toArray();
    final XmlDocument document = file.getDocument();
    assert document != null;
    XmlTag rootTag = document.getRootTag();
    final List<String> additionalNs = new ArrayList<>();
    if (rootTag != null) {
      URLReference.processWsdlSchemas(rootTag, xmlTag -> {
        final String s = xmlTag.getAttributeValue(URLReference.TARGET_NAMESPACE_ATTR_NAME);
        if (s != null) { additionalNs.add(s); }
        return true;
      });
    }
    resourceUrls = ArrayUtil.mergeArrays(resourceUrls, ArrayUtilRt.toStringArray(additionalNs));

    final Set<Object> preferred = new HashSet<>();
    if (parent instanceof XmlAttribute && "xmlns".equals(((XmlAttribute)parent).getName())) {
      XmlNamespaceHelper helper = XmlNamespaceHelper.getHelper(file);
      preferred.addAll(helper.guessUnboundNamespaces(parent.getParent(), file));
    }
    return ContainerUtil.map2Array(resourceUrls, o -> {
      LookupElementBuilder builder = LookupElementBuilder.create(o);
      return preferred.contains(o) ? PrioritizedLookupElement.withPriority(builder, 100) : builder;
    });
  }
private static Object[] completeNamespace(PsiElement myElement)