private void prepareDuplicateKeysByFile(final Map<String, Set<PsiFile>> keyToFiles,
                                          final InspectionManager manager,
                                          final Map<String, Set<String>> keyToValues,
                                          final List<? super ProblemDescriptor> problemDescriptors,
                                          final PsiFile psiFile,
                                          final ProgressIndicator progress) {
    for (String key : keyToFiles.keySet()) {
      if (progress!= null){
        progress.setText2(PropertiesBundle.message("duplicate.property.key.progress.indicator.text", key));
        ProgressIndicatorUtils.checkCancelledEvenWithPCEDisabled(progress);
      }
      @Nls StringBuilder message = new StringBuilder();
      int duplicatesCount = 0;
      PsiElement propertyInCurrentFile = null;
      Set<PsiFile> psiFilesWithDuplicates = keyToFiles.get(key);
      for (PsiFile file : psiFilesWithDuplicates) {
        if (!(file instanceof PropertiesFile propertiesFile)) continue;
        final List<IProperty> propertiesByKey = propertiesFile.findPropertiesByKey(key);
        for (IProperty property : propertiesByKey) {
          if (duplicatesCount == 0){
            message.append(PropertiesBundle.message("duplicate.property.key.problem.descriptor", key));
          }
          surroundWithHref(message, property.getPsiElement().getFirstChild(), false);
          duplicatesCount ++;
          //prepare for filter same keys different values
          Set<String> values = keyToValues.get(key);
          if (values == null){
            values = new HashSet<>();
            keyToValues.put(key, values);
          }
          values.add(property.getValue());
          if (propertyInCurrentFile == null && file == psiFile) {
            propertyInCurrentFile = property.getPsiElement();
          }
        }
      }
      if (duplicatesCount > 1 && CHECK_DUPLICATE_KEYS) {
        problemDescriptors.add(manager.createProblemDescriptor(ObjectUtils.notNull(propertyInCurrentFile, psiFile), message.toString(), false, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
      }
    }

  }
private void prepareDuplicateKeysByFile(final Map<String, Set<PsiFile>> keyToFiles,
                                          final InspectionManager manager,
                                          final Map<String, Set<String>> keyToValues,
                                          final List<? super ProblemDescriptor> problemDescriptors,
                                          final PsiFile psiFile,
                                          final ProgressIndicator progress)