CommentUtil { public static void blockCommentOrUncomment(JTextArea scriptPanel) { if (scriptPanel.getSelectedText() != null) { if (alreadyBlockCommented(scriptPanel)) { blockUncomment(scriptPanel); } else { blockComment(scriptPanel); } } }  static void commentOrUncommentSQL(JTextArea scriptPanel); static void commentOrUncommentJava(JTextArea scriptPanel); static void commentOrUncommentR(JTextArea scriptPanel); static void blockCommentOrUncomment(JTextArea scriptPanel); static final String SQL_COMMENT_CHARACTER; static final String JAVA_COMMENT_CHARACTER; static final String R_COMMENT_CHARACTER; static final String BLOCK_COMMENT_START; static final String BLOCK_COMMENT_END; }
@Test public void testBlockCommentEmptySelection() { org.junit.Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); RSyntaxTextArea scriptPanel = new RSyntaxTextArea(); scriptPanel.setText(TEXT); scriptPanel.select(13, 13); final String originalText = scriptPanel.getText(); CommentUtil.blockCommentOrUncomment(scriptPanel); assertEquals(originalText, scriptPanel.getText()); }
@Test public void testBlockCommentUncomment() throws BadLocationException { org.junit.Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); RSyntaxTextArea scriptPanel = new RSyntaxTextArea(); scriptPanel.setText(TEXT); scriptPanel.select(13, 226); final String originalText = scriptPanel.getText(); CommentUtil.blockCommentOrUncomment(scriptPanel); assertEquals(13, scriptPanel.getSelectionStart()); assertEquals(226 + CommentUtil.BLOCK_COMMENT_START.length() + CommentUtil.BLOCK_COMMENT_END.length(), scriptPanel.getSelectionEnd()); CommentUtil.blockCommentOrUncomment(scriptPanel); assertEquals(13, scriptPanel.getSelectionStart()); assertEquals(226, scriptPanel.getSelectionEnd()); assertEquals(originalText, scriptPanel.getText()); }