CommentUtil { private static void blockUncomment(JTextArea scriptPanel) { final int startOffset = scriptPanel.getSelectionStart(); final int endOffset = scriptPanel.getSelectionEnd(); scriptPanel.replaceRange("", endOffset - BLOCK_COMMENT_END.length(), endOffset); scriptPanel.replaceRange("", startOffset, startOffset + BLOCK_COMMENT_START.length()); scriptPanel.setSelectionStart(startOffset); scriptPanel.setSelectionEnd(endOffset - BLOCK_COMMENT_START.length() - BLOCK_COMMENT_END.length()); }  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 testBlockUncomment() { org.junit.Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); RSyntaxTextArea scriptPanel = new RSyntaxTextArea(); scriptPanel.setText("This is a uncommenting."); scriptPanel.select(10, 28); CommentUtil.blockCommentOrUncomment(scriptPanel); assertEquals(10, scriptPanel.getSelectionStart()); assertEquals(28 - CommentUtil.BLOCK_COMMENT_START.length() - CommentUtil.BLOCK_COMMENT_END.length(), scriptPanel.getSelectionEnd()); assertEquals("This is a test for block uncommenting.", scriptPanel.getText()); }