Result (@NotNull final Request req, @NotNull final PyStringElement leftElem, @NotNull final PyStringElement rightElem, @NotNull final String replacement) { if (!leftElem.isTripleQuoted() && !rightElem.isTripleQuoted()) { if (!rightElem.getContent().contains(leftElem.getQuote())) { final int quotePos = rightElem.getTextOffset() + rightElem.getContentRange().getEndOffset(); final String quote = leftElem.getQuote(); req.document.replaceString(quotePos, quotePos + 1, quote); return getResultAndSplitStringIfTooLong(req, leftElem, rightElem, replacement, quote); } else if (!leftElem.getContent().contains(rightElem.getQuote())) { final int quotePos = leftElem.getTextOffset() + leftElem.getContentRange().getStartOffset() - 1; final String quote = rightElem.getQuote(); req.document.replaceString(quotePos, quotePos + 1, quote); return getResultAndSplitStringIfTooLong(req, leftElem, rightElem, replacement, quote); } } return null; }