@NotNull
    public LinkedHashMap<JavaReplaceChoice, List<PsiExpression>> buildOccurrencesMap(PsiExpression expr) {
      final LinkedHashMap<JavaReplaceChoice, List<PsiExpression>> occurrencesMap = new LinkedHashMap<>();
      if (myChainMethodName != null) {
        if (myOccurrences.size() > 1 && !myCantReplaceAll) {
          occurrencesMap.put(JavaReplaceChoice.NO, Collections.singletonList(expr));
          occurrencesMap.put(JavaReplaceChoice.ALL, myOccurrences);
          occurrencesMap.put(new JavaReplaceChoice(ReplaceChoice.ALL, null, true) {
              @Override
              public String formatDescription(int occurrencesCount) {
                return JavaRefactoringBundle.message("replace.all.and.extract", occurrencesCount, myChainMethodName);
              }
            }, myOccurrences);
        } else {
          JavaReplaceChoice noChain =
            new JavaReplaceChoice(ReplaceChoice.NO, JavaRefactoringBundle.message("replace.inside.current.lambda"), false);
          JavaReplaceChoice chain =
            new JavaReplaceChoice(ReplaceChoice.NO, JavaRefactoringBundle.message("replace.as.separate.operation", myChainMethodName), true);
          occurrencesMap.put(noChain, Collections.singletonList(expr));
          occurrencesMap.put(chain, Collections.singletonList(expr));
        }
      } else {
        occurrencesMap.put(JavaReplaceChoice.NO, Collections.singletonList(expr));
        boolean hasWrite = myHasWriteAccess && !myCantReplaceAllButWrite;
        if (hasWrite && myNonWrite.contains(expr)) {
          occurrencesMap.put(JavaReplaceChoice.NO_WRITE, myNonWrite);
        }

        if (myOccurrences.size() > 1 && !myCantReplaceAll) {
          if (hasWrite) {
            JavaReplaceChoice choice = new JavaReplaceChoice(
              ReplaceChoice.ALL,
              myNonWrite.isEmpty() ? JavaRefactoringBundle.message("replace.all.occurrences.changes.semantics", myOccurrences.size())
              : JavaRefactoringBundle.message("replace.all.read.and.write"), false);
            occurrencesMap.put(choice, myOccurrences);
          }
          else {
            generateScopeBasedChoices(expr, occurrencesMap);
            occurrencesMap.put(JavaReplaceChoice.ALL, myOccurrences);
          }
        }
      }
      return occurrencesMap;
    }
@NotNull
    public LinkedHashMap<JavaReplaceChoice, List<PsiExpression>> buildOccurrencesMap(PsiExpression expr)