private static int calcBlockEndOffset(@NotNull Editor editor, @NotNull PsiFile file) {
    int offsetFromBraceMatcher = calcBlockEndOffsetFromBraceMatcher(editor, file);
    TextRange rangeFromStructuralSupport = CodeBlockSupportHandler.findCodeBlockRange(editor, file);
    if (rangeFromStructuralSupport.isEmpty()) {
      return offsetFromBraceMatcher;
    }
    else if (offsetFromBraceMatcher == -1) {
      return rangeFromStructuralSupport.getEndOffset();
    }
    else {
      return Math.min(rangeFromStructuralSupport.getEndOffset(), offsetFromBraceMatcher);
    }
  }
private static int calcBlockEndOffset(@NotNull Editor editor, @NotNull PsiFile file)