private static void addNameCompletions(ContextProvider contextProvider, final XPathNodeTest element, final Set<? super LookupElement> list) {
    final PrefixedName prefixedName = element.getQName();
    final XPathNodeTest.PrincipalType principalType = element.getPrincipalType();

    final Set<PsiFile> files = new HashSet<>();
    final XPathFile file = (XPathFile)element.getContainingFile();
    files.add(file);
    ContainerUtil.addAll(files, contextProvider.getRelatedFiles(file));

    for (PsiFile xpathFile : files) {
      xpathFile.accept(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(@NotNull PsiElement e) {
          if (e instanceof XPathNodeTest nodeTest) {

            final XPathNodeTest.PrincipalType _principalType = nodeTest.getPrincipalType();
            if (_principalType == principalType) {
              final PrefixedName _prefixedName = nodeTest.getQName();
              if (_prefixedName != null && prefixedName != null) {
                final String localName = _prefixedName.getLocalName();
                if (!"*".equals(localName) && !localName.contains(INTELLIJ_IDEA_RULEZ)) {
                  if (Objects.equals(_prefixedName.getPrefix(), prefixedName.getPrefix())) {
                    list.add(new NodeLookup(localName, _principalType));
                  } else if (prefixedName.getPrefix() == null) {
                    list.add(new NodeLookup(_prefixedName.toString(), _principalType));
                  }
                }
              }
            }
          }
          super.visitElement(e);
        }
      });
    }
  }
private static void addNameCompletions(ContextProvider contextProvider, final XPathNodeTest element, final Set<? super LookupElement> list)