@NotNull
  @Override
  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
                                        final boolean isOnTheFly,
                                        @NotNull final LocalInspectionToolSession session) {
    final PsiFile file = session.getFile();
    if (!fileNameMask.isEmpty()) {
      try {
        Pattern p = Pattern.compile(fileNameMask);
        if (!p.matcher(file.getName()).matches()) {
          return PsiElementVisitor.EMPTY_VISITOR;
        }
      }
      catch (PatternSyntaxException ignored) {
      }
    }
    final Module module = ModuleUtilCore.findModuleForPsiElement(file);
    if (module == null) return PsiElementVisitor.EMPTY_VISITOR;

    if (InjectedLanguageManager.getInstance(module.getProject()).isInjectedFragment(holder.getFile())
        || holder.getFile().getUserData(FileContextUtil.INJECTED_IN_ELEMENT) != null) {
      // Properties inside injected fragments cannot be normally referenced
      return PsiElementVisitor.EMPTY_VISITOR;
    }

    VirtualFile virtualFile = holder.getFile().getVirtualFile();
    if (virtualFile == null ||
        !ProjectFileIndex.getInstance(module.getProject()).isInSource(virtualFile)) {
      return PsiElementVisitor.EMPTY_VISITOR;
    }

    final UnusedPropertiesSearchHelper helper = new UnusedPropertiesSearchHelper(module);

    final Set<PsiElement> propertiesBeingCommitted = getBeingCommittedProperties(file);

    return new PsiElementVisitor() {
      @Override
      public void visitElement(@NotNull PsiElement element) {
        if (!(element instanceof Property property)) return;
        if (propertiesBeingCommitted != null && !propertiesBeingCommitted.contains(property)) return;

        if (isPropertyUsed(property, helper, isOnTheFly)) return;

        final ASTNode propertyNode = property.getNode();
        assert propertyNode != null;

        ASTNode[] nodes = propertyNode.getChildren(null);
        PsiElement key = nodes.length == 0 ? property : nodes[0].getPsi();
        LocalQuickFix fix = PropertiesQuickFixFactory.getInstance().createRemovePropertyLocalFix(property);
        holder.registerProblem(key, isOnTheFly ? PropertiesBundle.message("unused.property.problem.descriptor.name")
                                               : PropertiesBundle
                                      .message("unused.property.problem.descriptor.name.offline", property.getUnescapedKey()), fix);
      }
    };
  }
@NotNull
  @Override
  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
                                        final boolean isOnTheFly,
                                        @NotNull final LocalInspectionToolSession session)