void () { // 10 20 // 012345678901234567890 123456 789 String text = "<!ENTITY % Charsets \"CDATA\">"; EditorHighlighter dtdHighlighter = HighlighterFactory.createHighlighter(DTDFileType.INSTANCE, EditorColorsManager.getInstance().getGlobalScheme(), myProject); dtdHighlighter.setText(text); HighlighterIterator iterator = dtdHighlighter.createIterator(3); assertSame("Xml entity name", XmlTokenType.XML_ENTITY_DECL_START, iterator.getTokenType()); iterator = dtdHighlighter.createIterator(13); assertSame("Xml name in dtd", XmlTokenType.XML_NAME, iterator.getTokenType()); iterator = dtdHighlighter.createIterator(23); assertSame("Xml attribute value in dtd", XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, iterator.getTokenType()); // 10 20 30 40 // 0123456789012345678901 2345678901234567890123456789 text = "<!ELEMENT base EMPTY>\n<!ATTLIST base id ID #IMPLIED>"; dtdHighlighter.setText(text); iterator = dtdHighlighter.createIterator(3); assertSame("Xml element name", XmlTokenType.XML_ELEMENT_DECL_START, iterator.getTokenType()); iterator = dtdHighlighter.createIterator(25); assertSame("Xml attr list", XmlTokenType.XML_ATTLIST_DECL_START, iterator.getTokenType()); iterator = dtdHighlighter.createIterator(14); assertSame("Xml attr list", TokenType.WHITE_SPACE, iterator.getTokenType()); iterator = dtdHighlighter.createIterator(21); assertSame("Xml attr list", TokenType.WHITE_SPACE, iterator.getTokenType()); // 10 20 30 40 50 60 // 0123456789012345678901234567890123456789012345678901234567890123456789 text = "<![%sgml;[<![IGNORE[<![ INCLUDE [<!ENTITY % aaa SYSTEM 'zzz'>]]>]]>]]>"; dtdHighlighter.setText(text); iterator = dtdHighlighter.createIterator(2); assertEquals("Xml conditional section start",XmlTokenType.XML_CONDITIONAL_SECTION_START,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(67); assertEquals("Xml conditional section end",XmlTokenType.XML_CONDITIONAL_SECTION_END,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(5); assertEquals("entity ref in conditional section",XmlTokenType.XML_ENTITY_REF_TOKEN,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(15); assertEquals("ignore in conditional section",XmlTokenType.XML_CONDITIONAL_IGNORE,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(27); assertEquals("include in conditional section",XmlTokenType.XML_CONDITIONAL_INCLUDE,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(9); assertEquals("markup start in conditional section",XmlTokenType.XML_MARKUP_START,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(33); assertEquals("entity decl start in conditional section",XmlTokenType.XML_ENTITY_DECL_START,iterator.getTokenType()); // 10 20 30 40 50 60 70 // 012345678901234567890123 456789 0 123456789012345678901234567890123456 7890123456789 text = "<!ENTITY % ContentType \"CDATA\"\n -- media type, as per [RFC2045]\n -- --xxx-->"; dtdHighlighter.setText(text); iterator = dtdHighlighter.createIterator(35); assertEquals("Dtd comment start",XmlTokenType.XML_COMMENT_START,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(40); assertEquals("Dtd comment content",XmlTokenType.XML_COMMENT_CHARACTERS,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(71); assertEquals("Dtd comment end",XmlTokenType.XML_COMMENT_END,iterator.getTokenType()); iterator = dtdHighlighter.createIterator(78); assertEquals("Dtd comment content",XmlTokenType.XML_COMMENT_CHARACTERS,iterator.getTokenType()); }