1 19 20 package org.netbeans.modules.lexer.nbbridge.test.simple; 21 22 import java.util.Collection ; 23 import java.util.EnumSet ; 24 import org.netbeans.api.lexer.InputAttributes; 25 import org.netbeans.api.lexer.Language; 26 import org.netbeans.api.lexer.LanguagePath; 27 import org.netbeans.api.lexer.Token; 28 import org.netbeans.api.lexer.TokenId; 29 import org.netbeans.spi.lexer.LanguageEmbedding; 30 import org.netbeans.spi.lexer.LanguageHierarchy; 31 import org.netbeans.spi.lexer.Lexer; 32 import org.netbeans.spi.lexer.LexerRestartInfo; 33 34 39 public enum SimpleCharTokenId implements TokenId { 40 41 CHARACTER, 42 DIGIT; 43 44 SimpleCharTokenId() { 45 } 46 47 public String primaryCategory() { 48 return "chars"; 49 } 50 51 public static final String MIME_TYPE = "text/x-simple-char"; 52 53 private static final Language<SimpleCharTokenId> language 54 = new LanguageHierarchy<SimpleCharTokenId>() { 55 56 @Override 57 protected Collection <SimpleCharTokenId> createTokenIds() { 58 return EnumSet.allOf(SimpleCharTokenId.class); 59 } 60 61 @Override 62 public Lexer<SimpleCharTokenId> createLexer(LexerRestartInfo<SimpleCharTokenId> info) { 63 return new SimpleCharLexer(info); 64 } 65 66 @Override 67 public LanguageEmbedding embedding( 68 Token<SimpleCharTokenId> token, LanguagePath languagePath, InputAttributes inputAttributes) { 69 return null; } 71 72 public String mimeType() { 73 return MIME_TYPE; 74 } 75 76 }.language(); 77 78 public static Language<SimpleCharTokenId> language() { 79 return language; 80 } 81 82 } 83 | Popular Tags |