String (Editor editor, PsiFile psiFile) { final StringBuilder builder = new StringBuilder(); SelectionModel selectionModel = editor.getSelectionModel(); String selectedText = selectionModel.getSelectedText(true); assertNotNull(selectedText); final String text = StringUtil.convertLineSeparators(selectedText); TextWithMarkupProcessor processor = new TextWithMarkupProcessor() { @Override void createResult(SyntaxInfo syntaxInfo, Editor editor) { final ColorRegistry colorRegistry = syntaxInfo.getColorRegistry(); assertEquals(JBColor.BLACK, colorRegistry.dataById(syntaxInfo.getDefaultForeground())); assertEquals(JBColor.WHITE, colorRegistry.dataById(syntaxInfo.getDefaultBackground())); assertEquals((float)editor.getColorsScheme().getEditorFontSize(), syntaxInfo.getFontSize(), 0.01f); syntaxInfo.processOutputInfo(new MarkupHandler() { @Override public void handleText(int startOffset, int endOffset) { builder.append("text=").append(text, startOffset, endOffset).append('\n'); } @Override public void handleForeground(int foregroundId) { builder.append("foreground=").append(colorRegistry.dataById(foregroundId)).append(','); } @Override public void handleBackground(int backgroundId) { builder.append("background=").append(colorRegistry.dataById(backgroundId)).append(','); } @Override public void handleFont(int fontNameId) { assertEquals(1, fontNameId); } @Override public void handleStyle(int style) { builder.append("fontStyle=").append(style).append(','); } @Override public boolean canHandleMore() { return true; } }); } }; processor.collectTransferableData(psiFile, editor, selectionModel.getBlockSelectionStarts(), selectionModel.getBlockSelectionEnds()); return builder.toString(); }