1 13 package org.netbeans.api.xml.lexer; 14 15 import java.util.Collection ; 16 import java.util.EnumSet ; 17 import java.util.HashMap ; 18 import java.util.Map ; 19 import org.netbeans.api.lexer.InputAttributes; 20 import org.netbeans.api.lexer.Language; 21 import org.netbeans.api.lexer.LanguagePath; 22 import org.netbeans.api.lexer.Token; 23 import org.netbeans.api.lexer.TokenId; 24 import org.netbeans.lib.xml.lexer.XMLLexer; 25 import org.netbeans.spi.lexer.LanguageEmbedding; 26 import org.netbeans.spi.lexer.LanguageHierarchy; 27 import org.netbeans.spi.lexer.Lexer; 28 import org.netbeans.spi.lexer.LexerRestartInfo; 29 30 33 public enum XMLTokenId implements TokenId { 34 35 36 TEXT("xml-text"), 37 38 WS("xml-ws"), 39 40 ERROR("xml-error"), 41 42 TAG("xml-tag"), 43 44 ARGUMENT("xml-attribute"), 45 46 OPERATOR("xml-operator"), 47 48 VALUE("xml-value"), 49 50 BLOCK_COMMENT("xml-comment"), 51 52 DECLARATION("xml-doctype"), 53 54 CHARACTER("xml-ref"), 55 56 EOL("xml-EOL"), 57 58 PI_START("xml-pi-start"), 59 60 PI_TARGET("xml-pi-target"), 61 62 PI_CONTENT("pi-content"), 63 64 PI_END("pi-end"), 65 66 CDATA_SECTION("xml-cdata-section"); 67 68 private final String primaryCategory; 69 70 XMLTokenId() { 71 this(null); 72 } 73 74 XMLTokenId(String primaryCategory) { 75 this.primaryCategory = primaryCategory; 76 } 77 78 public String primaryCategory() { 79 return primaryCategory; 80 } 81 82 private static final Language<XMLTokenId> language = new LanguageHierarchy<XMLTokenId>() { 83 @Override 84 protected Collection <XMLTokenId> createTokenIds() { 85 return EnumSet.allOf(XMLTokenId.class); 86 } 87 88 @Override 89 protected Map <String ,Collection <XMLTokenId>> createTokenCategories() { 90 Map <String ,Collection <XMLTokenId>> cats = new HashMap <String ,Collection <XMLTokenId>>(); 91 92 97 return cats; 98 } 99 100 @Override 101 public Lexer<XMLTokenId> createLexer(LexerRestartInfo<XMLTokenId> info) { 102 return new XMLLexer(info); 103 } 104 105 @Override 106 public LanguageEmbedding<? extends TokenId> embedding( 107 Token<XMLTokenId> token, LanguagePath languagePath, InputAttributes inputAttributes) { 108 return null; } 110 111 @Override 112 public String mimeType() { 113 return "text/xml"; 114 } 115 }.language(); 116 117 public static Language<XMLTokenId> language() { 118 return language; 119 } 120 121 } 122 | Popular Tags |