private static Result checkInsertBackslash(PsiFile file,
                                             Ref<Integer> caretOffset,
                                             DataContext dataContext,
                                             int offset,
                                             Document doc) {
    boolean autoWrapInProgress = DataManager.getInstance().loadFromDataContext(dataContext,
                                                                               AutoHardWrapHandler.AUTO_WRAP_LINE_IN_PROGRESS_KEY) != null;
    if (PyWhiteSpaceFormattingStrategy.needInsertBackslash(file, offset, autoWrapInProgress)) {
      PsiElement atCaret = file.findElementAt(offset);
      if (atCaret != null) {
        // Set of statements which can be parenthesised is a subset of statements which can be split by backslash
        if (PyCodeInsightSettings.getInstance().PARENTHESISE_ON_ENTER) {
          PsiElement elementToWrap = findElementToParenthesise(atCaret);
          if (elementToWrap != null) {
            parenthesise(elementToWrap, doc);
            caretOffset.set(caretOffset.get() + 1);
            return Result.Continue;
          }
        }
        doc.insertString(offset, "\\");
        caretOffset.set(caretOffset.get() + 1);
      }
    }
    return Result.Continue;
  }
private static Result checkInsertBackslash(PsiFile file,
                                             Ref<Integer> caretOffset,
                                             DataContext dataContext,
                                             int offset,
                                             Document doc)