@Override
  public @NotNull PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new YamlPsiElementVisitor() {
      @Override
      public void visitAnchor(@NotNull YAMLAnchor anchor) {
        Collection<PsiReference> references =
          ReferencesSearch.search(anchor, GlobalSearchScope.fileScope(anchor.getContainingFile())).findAll();
        if (references.isEmpty()) {
          holder.registerProblem(
            anchor,
            YAMLBundle.message("inspections.unused.anchor.message", anchor.getName()),
            ProblemHighlightType.LIKE_UNUSED_SYMBOL,
            new RemoveAnchorQuickFix()
          );
        }
      }
    };
  }
@Override
  public @NotNull PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly)