diff --git a/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/MxmlTokenMakerTest.java b/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/MxmlTokenMakerTest.java index 5ce424c5..4d2a1040 100755 --- a/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/MxmlTokenMakerTest.java +++ b/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/MxmlTokenMakerTest.java @@ -72,7 +72,8 @@ void testMxml_actionScript_chars_invalid() { assertAllTokensOfType(TokenTypes.ERROR_CHAR, MxmlTokenMaker.INTERNAL_IN_AS, "'c", - "'\\uff07" + "'\\uff07", + "'\\ufffx'" ); } @@ -124,6 +125,24 @@ void testMxml_actionScript_endScriptTag() { } + @Test + void testMxml_actionScript_endTag() { + + String code = ""; + Segment segment = createSegment(code); + TokenMaker tm = createTokenMaker(); + + Token token = tm.getTokenList(segment, 0, 0); + Assertions.assertTrue(token.is(TokenTypes.MARKUP_TAG_DELIMITER, "")); + } + + @Test void testMxml_actionScript_eolComments() { assertAllTokensOfType(TokenTypes.COMMENT_EOL, @@ -136,7 +155,7 @@ void testMxml_actionScript_eolComments() { void testMxml_actionScript_eolComments_url() { String[] eolCommentLiterals = { - "// Hello world https://www.google.com", + "// Hello world https://www.google.com trailing text", }; for (String code : eolCommentLiterals) { @@ -152,6 +171,8 @@ void testMxml_actionScript_eolComments_url() { Assertions.assertEquals(TokenTypes.COMMENT_EOL, token.getType()); Assertions.assertEquals("https://www.google.com", token.getLexeme()); + token = token.getNextToken(); + Assertions.assertTrue(token.is(TokenTypes.COMMENT_EOL, " trailing text")); } } @@ -599,6 +620,7 @@ void testMxml_doctype() { "", "", "", + "", }; for (String code : doctypes) { @@ -611,6 +633,16 @@ void testMxml_doctype() { } + @Test + void testMXML_doctype_continuedFromPriorLine() { + assertAllTokensOfType(TokenTypes.MARKUP_DTD, + TokenTypes.MARKUP_DTD, + "continued from prior line unterminated", + "continued from prior line>" + ); + } + + @Test void testMxml_entityReferences() { assertAllTokensOfType(TokenTypes.MARKUP_ENTITY_REFERENCE, @@ -619,6 +651,18 @@ void testMxml_entityReferences() { } + @Test + void testXML_getSetCompleteCloseTags() { + try { + Assertions.assertTrue(MxmlTokenMaker.getCompleteCloseMarkupTags()); + MxmlTokenMaker.setCompleteCloseTags(false); + Assertions.assertFalse(MxmlTokenMaker.getCompleteCloseMarkupTags()); + } finally { + MxmlTokenMaker.setCompleteCloseTags(true); + } + } + + @Test void testMxml_happyPath_tagWithAttributes() { @@ -652,6 +696,80 @@ void testMxml_happyPath_tagWithAttributes() { } + @Test + void testMXML_inAttrDouble() { + assertAllTokensOfType(TokenTypes.MARKUP_TAG_ATTRIBUTE_VALUE, + MxmlTokenMaker.INTERNAL_ATTR_DOUBLE, + "continued to next line", + "ends on this line\"" + ); + } + + + @Test + void testMXML_inAttrDouble_scriptTag() { + assertAllTokensOfType(TokenTypes.MARKUP_TAG_ATTRIBUTE_VALUE, + MxmlTokenMaker.INTERNAL_ATTR_DOUBLE_QUOTE_SCRIPT, + "continued to next line", + "ends on this line\"" + ); + } + + + @Test + void testMXML_inAttrSingle() { + assertAllTokensOfType(TokenTypes.MARKUP_TAG_ATTRIBUTE_VALUE, + MxmlTokenMaker.INTERNAL_ATTR_SINGLE, + "continued to next line", + "ends on this line'" + ); + } + + + @Test + void testMXML_inAttrSingle_scriptTag() { + assertAllTokensOfType(TokenTypes.MARKUP_TAG_ATTRIBUTE_VALUE, + MxmlTokenMaker.INTERNAL_ATTR_SINGLE_QUOTE_SCRIPT, + "continued to next line", + "ends on this line'" + ); + } + + + @Test + void testMXML_inProcessingInstruction() { + assertAllTokensOfType(TokenTypes.MARKUP_PROCESSING_INSTRUCTION, + TokenTypes.MARKUP_PROCESSING_INSTRUCTION, + "continued to next line", + "ends on this line ?>" + ); + } + + + @Test + void testMXML_inTag_attributeNames() { + assertAllTokensOfType(TokenTypes.MARKUP_TAG_ATTRIBUTE, + MxmlTokenMaker.INTERNAL_INTAG, + "foo", + "value123", + "cszčšž", + "xmlns:cszčšž" + ); + } + + + @Test + void testMXML_inTagScript_attributeNames() { + assertAllTokensOfType(TokenTypes.MARKUP_TAG_ATTRIBUTE, + MxmlTokenMaker.INTERNAL_INTAG_SCRIPT, + "foo", + "value123", + "cszčšž", + "xmlns:cszčšž" + ); + } + + @Test void testMxml_processingInstructions() { diff --git a/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/XMLTokenMakerTest.java b/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/XMLTokenMakerTest.java index 08a8988b..edb3a3aa 100755 --- a/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/XMLTokenMakerTest.java +++ b/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/XMLTokenMakerTest.java @@ -142,6 +142,7 @@ void testXML_doctype() { "", "", "", + "", }; for (String code : doctypes) { @@ -154,6 +155,26 @@ void testXML_doctype() { } + @Test + void testXML_doctype_continuedFromPriorLine() { + assertAllTokensOfType(TokenTypes.MARKUP_DTD, + XMLTokenMaker.INTERNAL_DTD, + "continued from prior line unterminated", + "continued from prior line>" + ); + } + + + @Test + void testXML_doctypeInternal_continuedFromPriorLine() { + assertAllTokensOfType(TokenTypes.MARKUP_DTD, + XMLTokenMaker.INTERNAL_DTD_INTERNAL, + "continued from prior line unterminated", + "continued from prior line]>" + ); + } + + @Test void testXML_entityReferences() { @@ -171,6 +192,18 @@ void testXML_entityReferences() { } + @Test + void testXML_getSetCompleteCloseTags() { + try { + Assertions.assertTrue(XMLTokenMaker.getCompleteCloseMarkupTags()); + XMLTokenMaker.setCompleteCloseTags(false); + Assertions.assertFalse(XMLTokenMaker.getCompleteCloseMarkupTags()); + } finally { + XMLTokenMaker.setCompleteCloseTags(true); + } + } + + @Test void testXML_happyPath_tagWithAttributes() { @@ -246,6 +279,18 @@ void testXML_inTag_attributeNames() { } + @Test + void testXML_inTagScript_attributeNames() { + assertAllTokensOfType(TokenTypes.MARKUP_TAG_ATTRIBUTE, + XMLTokenMaker.INTERNAL_INTAG, + "foo", + "value123", + "cszčšž", + "xmlns:cszčšž" + ); + } + + @Test void testXML_openingTag_tagNames() { String[] openingTags = { diff --git a/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java b/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java index 4fb9ecce..2274c03a 100755 --- a/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java +++ b/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java @@ -21,6 +21,7 @@ import javax.swing.event.HyperlinkListener; import org.fife.ui.rsyntaxtextarea.*; +import org.fife.ui.rsyntaxtextarea.parser.ParserNotice; import org.fife.ui.rtextarea.FoldIndicatorStyle; import org.fife.ui.rtextarea.Gutter; import org.fife.ui.rtextarea.RTextScrollPane; @@ -52,7 +53,17 @@ public class DemoRootPane extends JRootPane implements HyperlinkListener, URL url = getClass().getResource("bookmark.png"); gutter.setBookmarkIcon(new ImageIcon(url)); getContentPane().add(scrollPane); - ErrorStrip errorStrip = new ErrorStrip(textArea); + ErrorStrip errorStrip = new ErrorStrip(textArea) { + protected void paintParserNoticeMarker(Graphics2D g, ParserNotice notice, int width, int height) { + GradientPaint paint = new GradientPaint( + 0, 0, Color.RED, + width, height, Color.GREEN); + + g.setPaint(paint); + g.fillOval(0, 0, width, height); +// g.fillRect(0,0, width,height); + } + }; //errorStrip.setBackground(java.awt.Color.blue); getContentPane().add(errorStrip, BorderLayout.LINE_END); setJMenuBar(createMenuBar());