@NotNull
  private static String findPrefixStatic(CompletionParameters parameters) {
    String prefix = CompletionUtil.findReferencePrefix(parameters);
    if (prefix == null) {
      prefix = CompletionUtil.findJavaIdentifierPrefix(parameters);
    }

    PsiElement element = parameters.getPosition();
    if (element.getParent() instanceof XPathVariableReference) {
      prefix = "$" + prefix;
    }

    if (element.getParent() instanceof XPathNodeTest nodeTest) {
      if (nodeTest.isNameTest()) {
        final PrefixedName prefixedName = nodeTest.getQName();
        assert prefixedName != null;
        final String p = prefixedName.getPrefix();

        int endIndex = prefixedName.getLocalName().indexOf(CompletionLists.INTELLIJ_IDEA_RULEZ);
        if (endIndex != -1) {
          prefix = prefixedName.getLocalName().substring(0, endIndex);
        } else if (p != null) {
          endIndex = p.indexOf(CompletionLists.INTELLIJ_IDEA_RULEZ);
          if (endIndex != -1) {
            prefix = p.substring(0, endIndex);
          }
        }
      }
    }

    return prefix;
  }
@NotNull
  private static String findPrefixStatic(CompletionParameters parameters)