private static void mergeSegments(Editor editor, @NotNull List<? extends Segment> zones) {
    if (!(editor instanceof EditorImpl)) return;
    FocusModeModel focusModeModel = ((EditorImpl)editor).getFocusModeModel();

    Set<RangeMarker> focusRegions = ((EditorImpl)editor).putUserDataIfAbsent(FOCUS_REGIONS_FROM_PASS, new HashSet<>());
    Set<RangeMarker> invalidFocusRegions = new HashSet<>(focusRegions);
    for (Segment zone : zones) {
      RangeMarker foundRegion = focusModeModel.findFocusRegion(zone.getStartOffset(), zone.getEndOffset());
      if (foundRegion == null) {
        RangeMarker newRegion = focusModeModel.createFocusRegion(zone.getStartOffset(), zone.getEndOffset());
        focusRegions.add(newRegion);
      }
      else {
        if (focusRegions.contains(foundRegion)) {
          // The region exists and belongs to this provider. Leave in focusRegions.
          invalidFocusRegions.remove(foundRegion);
        }
        else {
          LOG.warn("Trying to add existing focus region. startOffset: " + zone.getStartOffset() + ", endOffset: " + zone.getEndOffset());
        }
      }
    }
    for (RangeMarker invalidFocusRegion : invalidFocusRegions) {
      // Dispose and delete invalid and removed focus markers
      focusModeModel.removeFocusRegion(invalidFocusRegion);
      focusRegions.remove(invalidFocusRegion);
    }
  }
private static void mergeSegments(Editor editor, @NotNull List<? extends Segment> zones)