private void validateAffectedCustomRegions() {
    if (myComplexDocumentChange) {
      // validate all custom fold regions
      myRegionTree.processAll(r -> {
        if (r instanceof CustomFoldRegionImpl) {
          myAffectedCustomRegions.add((CustomFoldRegionImpl)r);
        }
        return true;
      });
      myComplexDocumentChange = false;
    }
    for (CustomFoldRegionImpl region : myAffectedCustomRegions) {
      if (region.isValid() && !myFoldTree.checkIfValidToCreate(region.getStartOffset(), region.getEndOffset(), true, region)) {
        myRegionTree.removeInterval(region);
      }
    }
    myAffectedCustomRegions.clear();
  }
private void validateAffectedCustomRegions()