Result (@NotNull final Request req, @NotNull final PyStringElement leftElem, @NotNull final PyStringElement rightElem, @NotNull final String replacement, @NotNull final String quote) { int cutIntoRight = rightElem.getContentRange().getStartOffset(); String lineEnd = ""; if (!replacement.isEmpty()) { cutIntoRight = replacement.length() + rightElem.getQuote().length(); int contentWithQuoteStartColumn = leftElem.getTextOffset() + leftElem.getPrefixLength() - getLeftLineStartOffset(req); int quotePos = rightElem.getTextOffset() + rightElem.getContentRange().getStartOffset() + replacement.length(); req.document.insertString(quotePos, rightElem.getQuote()); req.document.insertString(quotePos, StringUtil.repeat(" ", contentWithQuoteStartColumn)); lineEnd = quote + "\\\n"; } return new Result(replacement + lineEnd, 0, leftElem.getQuote().length(), cutIntoRight); }