void () { // 10 20 // 012345678901 2 345678901234567890 String text = "<xxx aaa = \"\"/> <xxx/>"; EditorHighlighter htmlHighlighter = HtmlHighlighterFactory.createHTMLHighlighter(EditorColorsManager.getInstance().getGlobalScheme()); htmlHighlighter.setText(text); HighlighterIterator iterator = htmlHighlighter.createIterator(4); assertEquals(XmlTokenType.TAG_WHITE_SPACE, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(8); assertEquals(XmlTokenType.TAG_WHITE_SPACE, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(10); assertEquals(XmlTokenType.TAG_WHITE_SPACE, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(15); assertEquals(XmlTokenType.XML_REAL_WHITE_SPACE, iterator.getTokenType()); // 10 20 // 01234567890123456 7890 1234567890 text = "<?xml version = \"1.0\"?> <html/>"; htmlHighlighter = HtmlHighlighterFactory.createHTMLHighlighter(EditorColorsManager.getInstance().getGlobalScheme()); htmlHighlighter.setText(text); iterator = htmlHighlighter.createIterator(1); assertEquals(XmlTokenType.XML_PI_START, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(10); assertEquals(XmlTokenType.XML_PI_TARGET, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(22); assertEquals(XmlTokenType.XML_PI_END, iterator.getTokenType()); // 10 20 30 40 50 60 70 // 012345678 901234567890123456789012345678901234567890123456 789012 345 678 90 text = "<tr><td>\\${param.foo}</td><td>${param.foo}</td><td name=\"${el['el']}\"/></tr>"; htmlHighlighter.setText(text); iterator = htmlHighlighter.createIterator(10); assertSame("Escaped el", XmlTokenType.XML_DATA_CHARACTERS, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(30); assertSame("El start", XmlTokenType.XML_DATA_CHARACTERS, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(35); assertSame("El identifier", XmlTokenType.XML_DATA_CHARACTERS, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(37); assertSame("El dot", XmlTokenType.XML_DATA_CHARACTERS, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(41); assertSame("El end", XmlTokenType.XML_DATA_CHARACTERS, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(57); assertSame("El start", XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(61); assertSame("El lbracket", XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(63); assertSame("El string literal", XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(67); assertSame("El end", XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(68); assertSame("Attribute value end", XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER, iterator.getTokenType()); // 10 20 30 // 0123456789012345678901234567890123456 text = "<!--- bla --->"; htmlHighlighter.setText(text); iterator = htmlHighlighter.createIterator(6); assertSame("Comment content", XmlTokenType.XML_COMMENT_CHARACTERS, iterator.getTokenType()); iterator = htmlHighlighter.createIterator(12); assertSame("Comment end", XmlTokenType.XML_COMMENT_END, iterator.getTokenType()); // 10 20 30 // 012345678901234 5 678901234567890123456 text = "<input onclick=\"\"/> <a></a>"; htmlHighlighter.setText(text); iterator = htmlHighlighter.createIterator(19); assertEquals(XmlTokenType.XML_REAL_WHITE_SPACE, iterator.getTokenType()); // 10 20 30 // 0123456789012345678901234567890123456 text = "<#input tableRow as value></#input>"; htmlHighlighter.setText(text); iterator = htmlHighlighter.createIterator(3); assertEquals(XmlTokenType.XML_DATA_CHARACTERS, iterator.getTokenType()); // 10 // 01234567890123456789 text = "<!--&nbsp; &aaa;-->"; htmlHighlighter.setText(text); iterator = htmlHighlighter.createIterator(5); assertEquals( "char entity in comment", XmlTokenType.XML_COMMENT_CHARACTERS, iterator.getTokenType() ); iterator = htmlHighlighter.createIterator(12); assertEquals( "entity ref in comment", XmlTokenType.XML_COMMENT_CHARACTERS, iterator.getTokenType() ); // 10 // 01234567890123456789 text = "<div> < in </div>"; htmlHighlighter.setText(text); iterator = htmlHighlighter.createIterator(6); assertEquals( "< before space should be tag data", XmlTokenType.XML_DATA_CHARACTERS, iterator.getTokenType() ); iterator = htmlHighlighter.createIterator(8); assertEquals( "should be tag data", XmlTokenType.XML_DATA_CHARACTERS, iterator.getTokenType() ); }