1 19 20 package org.netbeans.modules.lexer.nbbridge; 21 22 import org.netbeans.api.editor.mimelookup.MimeLookup; 23 import org.netbeans.api.editor.mimelookup.MimePath; 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.LanguageProvider; 31 import org.openide.util.Lookup; 32 33 37 public final class MimeLookupLanguageProvider extends LanguageProvider { 38 39 public MimeLookupLanguageProvider() { 40 super(); 41 } 42 43 public Language<? extends TokenId> findLanguage(String mimePath) { 44 Lookup lookup = MimeLookup.getLookup(MimePath.parse(mimePath)); 45 return (Language<? extends TokenId>)lookup.lookup(Language.class); 46 } 47 48 public LanguageEmbedding<? extends TokenId> findLanguageEmbedding( 49 Token<? extends TokenId> token, LanguagePath languagePath, InputAttributes inputAttributes) { 50 Lookup lookup = MimeLookup.getLookup(MimePath.parse(languagePath.mimePath())); 51 LanguagesEmbeddingMap map = lookup.lookup(LanguagesEmbeddingMap.class); 52 return map == null ? null : map.getLanguageEmbeddingForTokenName(token.id().name()); 53 } 54 55 } 56 | Popular Tags |