1 19 20 package org.netbeans.lib.lexer.test.simple; 21 22 import java.util.Collection ; 23 import java.util.EnumSet ; 24 import java.util.Map ; 25 import org.netbeans.api.lexer.InputAttributes; 26 import org.netbeans.api.lexer.Language; 27 import org.netbeans.api.lexer.LanguagePath; 28 import org.netbeans.api.lexer.Token; 29 import org.netbeans.api.lexer.TokenId; 30 import org.netbeans.spi.lexer.LanguageEmbedding; 31 import org.netbeans.spi.lexer.LanguageHierarchy; 32 import org.netbeans.spi.lexer.Lexer; 33 import org.netbeans.spi.lexer.LexerRestartInfo; 34 35 42 public enum SimpleStringTokenId implements TokenId { 43 44 TEXT("string"), 45 BACKSPACE("string-escape"), 46 FORM_FEED("string-escape"), 47 NEWLINE("string-escape"), 48 CR("string-escape"), 49 TAB("string-escape"), 50 SINGLE_QUOTE("string-escape"), 51 DOUBLE_QUOTE("string-escape"), 52 BACKSLASH("string-escape"), 53 OCTAL_ESCAPE("string-escape"), 54 OCTAL_ESCAPE_INVALID("string-escape-invalid"), 55 ESCAPE_SEQUENCE_INVALID("string-escape-invalid"); 56 57 private final String primaryCategory; 58 59 SimpleStringTokenId() { 60 this(null); 61 } 62 63 SimpleStringTokenId(String primaryCategory) { 64 this.primaryCategory = primaryCategory; 65 } 66 67 public String primaryCategory() { 68 return primaryCategory; 69 } 70 71 private static final Language<SimpleStringTokenId> language 72 = new LanguageHierarchy<SimpleStringTokenId>() { 73 @Override 74 protected Collection <SimpleStringTokenId> createTokenIds() { 75 return EnumSet.allOf(SimpleStringTokenId.class); 76 } 77 78 @Override 79 protected Map <String , Collection <SimpleStringTokenId>> createTokenCategories() { 80 return null; } 82 83 @Override 84 public Lexer<SimpleStringTokenId> createLexer(LexerRestartInfo<SimpleStringTokenId> info) { 85 return new SimpleStringLexer(info); 86 } 87 88 @Override 89 public LanguageEmbedding<? extends TokenId> embedding( 90 Token<SimpleStringTokenId> token, LanguagePath languagePath, InputAttributes inputAttributes) { 91 return null; } 93 94 @Override 95 protected String mimeType() { 96 return "text/x-simple-string"; 97 } 98 }.language(); 99 100 public static Language<SimpleStringTokenId> language() { 101 return language; 102 } 103 104 public void release() { 105 } 106 107 } 108 | Popular Tags |