@Override public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { if (!textArea.isEditable() || !textArea.isEnabled()) { UIManager.getLookAndFeel().provideErrorFeedback(textArea); return; } RSyntaxTextArea rsta = (RSyntaxTextArea)getTextComponent(e); RSyntaxDocument doc = (RSyntaxDocument)rsta.getDocument(); int line = textArea.getCaretLineNumber(); int type = doc.getLastTokenTypeOnLine(line); if (type<0) { type = doc.getClosestStandardTokenTypeForInternalType(type); } // Only in MLC's should we try this if (type==Token.COMMENT_DOCUMENTATION || type==Token.COMMENT_MULTILINE) { insertBreakInMLC(e, rsta, line); } else { handleInsertBreak(rsta, true); } }
@Test public void testGetClosestStandardTokenTypeForInternalType() throws Exception { String syntaxStyle = SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT; doc = new RSyntaxDocument(syntaxStyle); JavaScriptTokenMaker tokenMaker = new JavaScriptTokenMaker(); for (int i=0; i<TokenTypes.DEFAULT_NUM_TOKEN_TYPES; i++) { int expected = tokenMaker.getClosestStandardTokenTypeForInternalType(i); int actual = doc.getClosestStandardTokenTypeForInternalType(i); Assert.assertEquals(expected, actual); } }
@Override public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { if (!textArea.isEditable() || !textArea.isEnabled()) { UIManager.getLookAndFeel().provideErrorFeedback(textArea); return; } RSyntaxTextArea rsta = (RSyntaxTextArea)getTextComponent(e); RSyntaxDocument doc = (RSyntaxDocument)rsta.getDocument(); int line = textArea.getCaretLineNumber(); int type = doc.getLastTokenTypeOnLine(line); if (type<0) { type = doc.getClosestStandardTokenTypeForInternalType(type); } // Only in MLC's should we try this if (type==Token.COMMENT_DOCUMENTATION || type==Token.COMMENT_MULTILINE) { insertBreakInMLC(e, rsta, line); } else { handleInsertBreak(rsta, true); } }