String (Project project, PsiFile file, Editor editor, String text, 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(); final StringKind stringKind = findStringKind(file, selectionStart, selectionEnd); if (stringKind == null) { return text; } if (rawText != null && canPasteRaw(text, rawText.rawText, stringKind)) { return rawText.rawText; } StringBuilder buffer = new StringBuilder(text.length()); @NonNls String breaker = stringKind.getLineBreaker(); final String[] lines = LineTokenizer.tokenize(text.toCharArray(), false, true); for (int i = 0; i < lines.length; i++) { String line = lines[i]; buffer.append(escape(stringKind, line)); if (i != lines.length - 1) { buffer.append(breaker); } else if (text.endsWith("\n")) { buffer.append(stringKind.escape("\n")); } } return buffer.toString(); }