1 19 package org.netbeans.modules.ruby.lexer; 20 21 import java.util.Collection ; 22 import java.util.EnumSet ; 23 import java.util.Map ; 24 25 import org.netbeans.modules.ruby.lexer.RubyCommentLexer; 26 import org.netbeans.api.lexer.Language; 27 import org.netbeans.api.lexer.TokenId; 28 import org.netbeans.spi.lexer.LanguageHierarchy; 29 import org.netbeans.spi.lexer.Lexer; 30 import org.netbeans.spi.lexer.LexerRestartInfo; 31 32 38 public enum RubyCommentTokenId implements TokenId { 39 COMMENT_TEXT("comment"), 40 COMMENT_TODO("todo"), 41 COMMENT_RDOC("rdoc"), 42 COMMENT_LINK("comment-link"), 43 COMMENT_BOLD("comment-bold"), 44 COMMENT_ITALIC("comment-italic"), 45 COMMENT_HTMLTAG("dochtml"); 46 47 private final String primaryCategory; 48 49 RubyCommentTokenId() { 50 this(null); 51 } 52 53 RubyCommentTokenId(String primaryCategory) { 54 this.primaryCategory = primaryCategory; 55 } 56 57 public String primaryCategory() { 58 return primaryCategory; 59 } 60 61 private static final Language<RubyCommentTokenId> language = 62 new LanguageHierarchy<RubyCommentTokenId>() { 63 @Override 64 protected Collection <RubyCommentTokenId> createTokenIds() { 65 return EnumSet.allOf(RubyCommentTokenId.class); 66 } 67 68 @Override 69 protected Map <String , Collection <RubyCommentTokenId>> createTokenCategories() { 70 return null; } 72 73 @Override 74 protected Lexer<RubyCommentTokenId> createLexer( 75 LexerRestartInfo<RubyCommentTokenId> info) { 76 return new RubyCommentLexer(info); 77 } 78 79 @Override 80 public String mimeType() { 81 return "text/x-ruby-comment"; 82 } 83 }.language(); 84 85 public static Language<RubyCommentTokenId> language() { 86 return language; 87 } 88 } 89 | Popular Tags |