public static void checkUnusedVariable(XsltVariable variable, ProblemsHolder holder) {
        if (variable instanceof XsltParameter) {
            if (((XsltParameter)variable).isAbstract()) {
                return;
            }
        } else {
            if (variable.isVoid()) {
                return;
            }
        }

        final XmlTag tag = variable.getTag();
        final XmlTag templateTag = XsltCodeInsightUtil.getTemplateTag(tag, false);
        if (templateTag == null) {
            return;
        }
        final XmlAttribute attribute = tag.getAttribute("name");
        if (attribute == null) {
          return;
        }
        final PsiElement token = XsltSupport.getAttValueToken(attribute);
        if (token == null) {
          return;
        }

        final SearchScope scope = new LocalSearchScope(templateTag);
        final Query<PsiReference> refs = ReferencesSearch.search(variable, scope, false);

        if (isUnused(variable, refs)) {
            final String name = variable.getName();
            assert name != null;

            final LocalQuickFix[] fixes;
            if (variable instanceof XsltParameter) {
                fixes = new LocalQuickFix[]{ new DeleteUnusedParameterFix(name, (XsltParameter)variable) };
            } else {
                fixes = new LocalQuickFix[]{ new DeleteUnusedVariableFix(name, variable) };
            }

          final String message = XPathBundle.message("inspection.message.never.used",
                                                     ((DeleteUnusedElementBase<?>)fixes[0]).getType(), name);
          holder.registerProblem(token, message, ProblemHighlightType.LIKE_UNUSED_SYMBOL, fixes);
        }
    }
public static void checkUnusedVariable(XsltVariable variable, ProblemsHolder holder)