1 19 20 package org.netbeans.api.java.lexer; 21 22 import java.util.Collection ; 23 import java.util.EnumSet ; 24 import java.util.Map ; 25 import org.netbeans.api.lexer.Language; 26 import org.netbeans.api.lexer.TokenId; 27 import org.netbeans.lib.java.lexer.JavaStringLexer; 28 import org.netbeans.spi.lexer.LanguageHierarchy; 29 import org.netbeans.spi.lexer.Lexer; 30 import org.netbeans.spi.lexer.LexerRestartInfo; 31 32 39 public enum JavaStringTokenId implements TokenId { 40 41 TEXT("string"), 42 BACKSPACE("string-escape"), 43 FORM_FEED("string-escape"), 44 NEWLINE("string-escape"), 45 CR("string-escape"), 46 TAB("string-escape"), 47 SINGLE_QUOTE("string-escape"), 48 DOUBLE_QUOTE("string-escape"), 49 BACKSLASH("string-escape"), 50 OCTAL_ESCAPE("string-escape"), 51 OCTAL_ESCAPE_INVALID("string-escape-invalid"), 52 ESCAPE_SEQUENCE_INVALID("string-escape-invalid"); 53 54 private final String primaryCategory; 55 56 JavaStringTokenId() { 57 this(null); 58 } 59 60 JavaStringTokenId(String primaryCategory) { 61 this.primaryCategory = primaryCategory; 62 } 63 64 public String primaryCategory() { 65 return primaryCategory; 66 } 67 68 private static final Language<JavaStringTokenId> language = new LanguageHierarchy<JavaStringTokenId>() { 69 @Override 70 protected Collection <JavaStringTokenId> createTokenIds() { 71 return EnumSet.allOf(JavaStringTokenId.class); 72 } 73 74 @Override 75 protected Map <String , Collection <JavaStringTokenId>> createTokenCategories() { 76 return null; } 78 79 @Override 80 protected Lexer<JavaStringTokenId> createLexer(LexerRestartInfo<JavaStringTokenId> info) { 81 return new JavaStringLexer(info); 82 } 83 84 @Override 85 protected String mimeType() { 86 return "text/x-java-string"; 87 } 88 }.language(); 89 90 public static Language<JavaStringTokenId> language() { 91 return language; 92 } 93 94 } 95 | Popular Tags |