1 19 20 package org.netbeans.lib.lexer.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 protected Lexer<SimpleCharTokenId> createLexer(LexerRestartInfo<SimpleCharTokenId> info) { 63 return new SimpleCharLexer(info); 64 } 65 66 @Override 67 protected LanguageEmbedding<? extends TokenId> embedding( 68 Token<SimpleCharTokenId> token, LanguagePath languagePath, InputAttributes inputAttributes) { 69 return null; } 71 72 @Override 73 protected String mimeType() { 74 return MIME_TYPE; 75 } 76 77 }.language(); 78 79 public static Language<SimpleCharTokenId> language() { 80 return language; 81 } 82 83 } 84 | Popular Tags |