PsiElement (final String prefix, XmlElement context) { final String name = "xmlns:" + prefix; XmlTag parent = PsiTreeUtil.getParentOfType(context, XmlTag.class); while (parent != null) { final XmlAttribute attribute = parent.getAttribute(name, null); if (attribute != null) { final TextRange textRange = TextRange.from("xmlns:".length(), prefix.length()); return new SchemaPrefix(attribute, textRange, prefix) { @Override public boolean equals(Object obj) { if (obj instanceof SchemaPrefix p) { return prefix.equals(p.getName()) && p.getParent() == attribute; } return super.equals(obj); } }; } parent = PsiTreeUtil.getParentOfType(parent, XmlTag.class); } return null; }