Result (@NotNull Request req) { final PyStringElement leftStringElem = PsiTreeUtil.getParentOfType(req.leftElem, PyStringElement.class, false); final PyStringElement rightStringElem = PsiTreeUtil.getParentOfType(req.rightElem, PyStringElement.class, false); if (leftStringElem != null && rightStringElem != null && leftStringElem != rightStringElem) { final PsiElement parent = rightStringElem.getParent(); if ((leftStringElem.getParent() == parent && parent instanceof PyStringLiteralExpression) || (req.leftExpr instanceof PyStringLiteralExpression && req.rightExpr instanceof PyStringLiteralExpression)) { if (leftStringElem.isTerminated() && rightStringElem.isTerminated() && haveSamePrefixes(leftStringElem, rightStringElem)) { final String leftElemQuotes = leftStringElem.getQuote(); final String rightElemQuotes = rightStringElem.getQuote(); int quotesMaxLength = Math.max(leftElemQuotes.length(), rightElemQuotes.length()); int stringToJoinMaxLength = getStringToJoinMaxLength(req, quotesMaxLength); final String replacement = findReplacement(rightStringElem.getContent(), stringToJoinMaxLength); if (leftElemQuotes.equals(rightElemQuotes)) { return getResultAndSplitStringIfTooLong(req, leftStringElem, rightStringElem, replacement, leftElemQuotes); } return processStringsWithDifferentQuotes(req, leftStringElem, rightStringElem, replacement); } } } return null; }