@Nullable
    private static PatternDefinition createPatternDefinition(@NotNull ForEachWithRecordPatternCanBeUsedInspection.ComponentContext context,
                                                             @NotNull Map<String, List<String>> usedVariable) {
      PsiClass recordClass = context.recordClass;
      PsiStatement body = context.base.getBody();
      if (body == null) {
        return null;
      }
      Map<String, String> namesToComponents = new HashMap<>();
      List<String> variables = new ArrayList<>();
      for (PsiRecordComponent component : context.recordClass.getRecordComponents()) {
        String type = "var";
        if (!context.options.useVar) {
          PsiType substituted = context.classSubstitutor.substitute(component.getType());
          if (substituted == null) {
            return null;
          }
          type = substituted.getCanonicalText();
        }
        ArrayList<String> proposedNames = new ArrayList<>();
        proposedNames.add(component.getName());
        List<String> previouslyUsedNames = usedVariable.get(component.getName());
        if (previouslyUsedNames != null) {
          proposedNames.addAll(previouslyUsedNames);
        }
        VariableNameGenerator generator = new VariableNameGenerator(body, VariableKind.PARAMETER)
          .byName(ArrayUtil.toStringArray(proposedNames));
        String generatedName = generator.generate(true);
        variables.add(type + " " + generatedName);
        namesToComponents.put(component.getName(), generatedName);
      }
      StringJoiner joiner = new StringJoiner(", ", "(", ")");
      variables.forEach(pattern -> joiner.add(pattern));

      return new PatternDefinition(recordClass.getQualifiedName() + joiner, namesToComponents);
    }
@Nullable
    private static PatternDefinition createPatternDefinition(@NotNull ForEachWithRecordPatternCanBeUsedInspection.ComponentContext context,
                                                             @NotNull Map<String, List<String>> usedVariable)