String (final Project project, final PsiFile file, final Editor editor, String text, final RawText rawText) { if (!isSupportedFile(file)) { return text; } final Document document = editor.getDocument(); PsiDocumentManager.getInstance(project).commitDocument(document); final SelectionModel selectionModel = editor.getSelectionModel(); // pastes in block selection mode (column mode) are not handled by a CopyPasteProcessor final int selectionStart = selectionModel.getSelectionStart(); final int selectionEnd = selectionModel.getSelectionEnd(); PsiElement token = findLiteralTokenType(file, selectionStart, selectionEnd); if (token == null) { return text; } if (rawText != null && wasUnescaped(text, rawText.rawText) && isSuitableForContext(rawText.rawText, token)) return rawText.rawText; if (isStringLiteral(token)) { text = escapeAndSplit(text, token); } else if (isCharLiteral(token)) { return escapeCharCharacters(text, token); } else if (isTextBlock(token)) { final String before = document.getText(new TextRange(selectionStart - 1, selectionStart)); final String after = document.getText(new TextRange(selectionEnd, selectionEnd + 1)); int caretOffset = editor.getCaretModel().getOffset(); int offset = caretOffset - document.getLineStartOffset(document.getLineNumber(caretOffset)); return escapeTextBlock(text, offset, "\"".equals(before), "\"".equals(after)); } return text; }