public void visitXmlTag(XmlTag tag) {
      final PsiFile file = tag.getContainingFile();
      if (file.getFileType() != XmlFileType.INSTANCE) {
        return;
      }
      if (!tag.getLocalName().equals("define")) {
        return;
      }
      if (!tag.getNamespace().equals(RelaxNgMetaDataContributor.RNG_NAMESPACE)) {
        return;
      }
      if (tag.getAttribute("combine") != null) {
        return; // ?
      }

      final XmlAttribute attr = tag.getAttribute("name");
      if (attr == null) return;

      final XmlAttributeValue value = attr.getValueElement();
      if (value == null) return;

      final String s = value.getValue();
      if (s.length() == 0) {
        return;
      }
      final PsiElement parent = value.getParent();
      if (!(parent instanceof XmlAttribute)) {
        return;
      }
      if (!"name".equals(((XmlAttribute)parent).getName())) {
        return;
      }
      final PsiElement grandParent = parent.getParent();
      if (!(grandParent instanceof XmlTag)) {
        return;
      }

      final DomElement element = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
      if (element == null) {
        return;
      }

      final RngGrammar rngGrammar = element.getParentOfType(RngGrammar.class, true);
      if (rngGrammar != null) {
        if (processUsages(tag, value, new LocalSearchScope(rngGrammar.getXmlTag()))) return;
      } else {
        if (processUsages(tag, value, new LocalSearchScope(file))) return;
      }

      final PsiElementProcessor.CollectElements<XmlFile> collector = new PsiElementProcessor.CollectElements<>();
      RelaxIncludeIndex.processBackwardDependencies((XmlFile)file, collector);

      if (processUsages(tag, value, new LocalSearchScope(collector.toArray()))) return;

      myHolder.registerProblem(value, RelaxngBundle.message("relaxng.inspection.unused-define.message"), ProblemHighlightType.LIKE_UNUSED_SYMBOL, new MyFix<>());
    }
public void visitXmlTag(XmlTag tag)