1 19 20 package org.netbeans.lib.lexer; 21 22 import java.util.Collection ; 23 import java.util.Map ; 24 import org.netbeans.api.lexer.LanguagePath; 25 import org.netbeans.api.lexer.InputAttributes; 26 import org.netbeans.api.lexer.Language; 27 import org.netbeans.api.lexer.Token; 28 import org.netbeans.api.lexer.TokenId; 29 import org.netbeans.spi.lexer.CharPreprocessor; 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.LexerInput; 34 import org.netbeans.spi.lexer.LexerRestartInfo; 35 import org.netbeans.spi.lexer.MutableTextInput; 36 import org.netbeans.spi.lexer.TokenFactory; 37 import org.netbeans.spi.lexer.TokenValidator; 38 39 45 46 public abstract class LexerSpiPackageAccessor { 47 48 private static LexerSpiPackageAccessor INSTANCE; 49 50 public static LexerSpiPackageAccessor get() { 51 return INSTANCE; 52 } 53 54 60 public static void register(LexerSpiPackageAccessor accessor) { 61 if (INSTANCE != null) { 62 throw new IllegalStateException ("Already registered"); } 64 INSTANCE = accessor; 65 } 66 67 public abstract <T extends TokenId> Collection <T> createTokenIds(LanguageHierarchy<T> languageHierarchy); 68 69 public abstract <T extends TokenId> Map <String ,Collection <T>> createTokenCategories(LanguageHierarchy<T> languageHierarchy); 70 71 public abstract <T extends TokenId> Lexer<T> createLexer(LanguageHierarchy<T> languageHierarchy, LexerRestartInfo<T> info); 72 73 public abstract <T extends TokenId> LexerRestartInfo<T> createLexerRestartInfo( 74 LexerInput input, TokenFactory<T> tokenFactory, Object state, 75 LanguagePath languagePath, InputAttributes inputAttributes); 76 77 public abstract String mimeType(LanguageHierarchy<? extends TokenId> languageHierarchy); 78 79 public abstract <T extends TokenId> LanguageEmbedding<? extends TokenId> embedding( 80 LanguageHierarchy<T> languageHierarchy, Token<T> token, 81 LanguagePath languagePath, InputAttributes inputAttributes); 82 83 public abstract <T extends TokenId> TokenValidator<T> createTokenValidator(LanguageHierarchy<T> languageHierarchy, T id); 84 85 public abstract CharPreprocessor createCharPreprocessor(LanguageHierarchy<? extends TokenId> languageHierarchy); 86 87 public abstract <T extends TokenId> boolean isRetainTokenText(LanguageHierarchy<T> languageHierarchy, T id); 88 89 public abstract <T extends TokenId> LanguageOperation<T> operation(LanguageHierarchy<T> languageHierarchy); 90 91 public abstract LexerInput createLexerInput(CharProvider charProvider); 92 93 public abstract void init(CharPreprocessor preprocessor, CharPreprocessorOperation operation); 94 95 public abstract void preprocessChar(CharPreprocessor preprocessor); 96 97 public abstract Language<? extends TokenId> language(MutableTextInput<?> mti); 98 99 public abstract <T extends TokenId> LanguageEmbedding<T> createLanguageEmbedding( 100 Language<T> language, int startSkipLength, int endSkipLength, boolean joinSections); 101 102 public abstract CharSequence text(MutableTextInput<?> mti); 103 104 public abstract InputAttributes inputAttributes(MutableTextInput<?> mti); 105 106 public abstract <I> I inputSource(MutableTextInput<I> mti); 107 108 public abstract <T extends TokenId> TokenFactory<T> createTokenFactory(LexerInputOperation<T> lexerInputOperation); 109 110 } 111 | Popular Tags |