@Override
  public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
    PsiReference reference = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());
    if (reference instanceof URLReference) {
      if (((URLReference)reference).isSchemaLocation()) {
        Object[] objects = completeSchemaLocation(reference.getElement());
        result.addAllElements(ContainerUtil.map(objects, MAPPING));
        if (objects.length > 0) result.stopHere();
        return;
      }
      Object[] objects = completeNamespace(reference.getElement());
      result.addAllElements(ContainerUtil.map(objects, MAPPING));
      if (objects.length > 0) result.stopHere();
      return;
    }
    if (reference instanceof PsiMultiReference) reference = ((PsiMultiReference)reference).getReferences()[0];
    if (reference instanceof DependentNSReference) {
      MultiMap<String, String> map = ExternalResourceManagerEx.getInstanceEx().getUrlsByNamespace(parameters.getOriginalFile().getProject());
      String namespace = ((DependentNSReference)reference).getNamespaceReference().getCanonicalText();
      Collection<String> strings = map.get(namespace);
      for (String string : strings) {
        if (!namespace.equals(string)) { // exclude namespaces from location urls
          result.consume(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(string), 100));
        }
      }
      if (!strings.isEmpty()) result.stopHere();
    }
  }
@Override
  public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result)