public static @NotNull PsiElementVisitor createVisitor(@NotNull LocalInspectionTool tool,
                                                         @NotNull ProblemsHolder holder,
                                                         boolean isOnTheFly,
                                                         @NotNull LocalInspectionToolSession session) {
    if (!tool.isAvailableForFile(holder.getFile())) {
      return PsiElementVisitor.EMPTY_VISITOR;
    }
    PsiElementVisitor visitor = tool.buildVisitor(holder, isOnTheFly, session);
    //noinspection ConstantConditions
    if (visitor == null) {
      LOG.error("Tool " + tool + " (" + tool.getClass() + ") must not return null from the buildVisitor() method");
    }
    else if (visitor instanceof PsiRecursiveVisitor) {
      LOG.error("The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive: " + tool);
    }
    return visitor;
  }
public static @NotNull PsiElementVisitor createVisitor(@NotNull LocalInspectionTool tool,
                                                         @NotNull ProblemsHolder holder,
                                                         boolean isOnTheFly,
                                                         @NotNull LocalInspectionToolSession session)