本文整理匯總了Java中com.intellij.lang.Language.findInstancesByMimeType方法的典型用法代碼示例。如果您正苦於以下問題:Java Language.findInstancesByMimeType方法的具體用法?Java Language.findInstancesByMimeType怎麽用?Java Language.findInstancesByMimeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.lang.Language
的用法示例。
在下文中一共展示了Language.findInstancesByMimeType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findScriptContentProvider
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Nullable
protected static HtmlScriptContentProvider findScriptContentProvider(@Nullable String mimeType) {
if (StringUtil.isEmpty(mimeType)) {
return ourDefaultLanguage != null ? LanguageHtmlScriptContentProvider.getScriptContentProvider(ourDefaultLanguage) : null;
}
Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(mimeType.trim());
if (instancesByMimeType.isEmpty() && mimeType.contains("template")) {
instancesByMimeType = Collections.<Language>singletonList(HTMLLanguage.INSTANCE);
}
for (Language language : instancesByMimeType) {
HtmlScriptContentProvider scriptContentProvider = LanguageHtmlScriptContentProvider.getScriptContentProvider(language);
if (scriptContentProvider != null) {
return scriptContentProvider;
}
}
return null;
}
示例2: getLanguagesToInject
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
if (context instanceof AppleScriptStringLiteralExpression) {
AppleScriptCommandHandlerCall asCommand = PsiTreeUtil.getContextOfType(context, AppleScriptCommandHandlerCall.class);
if (asCommand != null && asCommand.getCommandName().equalsIgnoreCase("do javascript")) {
Collection<Language> javascript = Language.findInstancesByMimeType("javascript");
if (javascript.isEmpty()) return;
registrar.startInjecting(javascript.iterator().next()).addPlace(null, null, (PsiLanguageInjectionHost) context, new TextRange(1, context.getTextLength() - 1)).doneInjecting();
}
}
}
示例3: getLanguage
import com.intellij.lang.Language; //導入方法依賴的package包/類
private static Language getLanguage(String mimeType) {
Language language = null;
Collection<Language> langs = Language.findInstancesByMimeType(mimeType);
if (langs.isEmpty()) {
language = PlainTextLanguage.INSTANCE;
} else {
language = langs.iterator().next();//Pick first one
}
return language;
}
示例4: getScriptLanguageToInject
import com.intellij.lang.Language; //導入方法依賴的package包/類
/**
* Finds language to be injected into <script> tag
*
* @param xmlTag <script> tag
* @return language to inject or null if no language found or not a script tag at all
*/
@Nullable
public static Language getScriptLanguageToInject(@NotNull XmlTag xmlTag) {
if (!HtmlUtil.isScriptTag(xmlTag)) {
return null;
}
String mimeType = xmlTag.getAttributeValue("type");
Collection<Language> languages = Language.findInstancesByMimeType(mimeType);
return !languages.isEmpty() ? languages.iterator().next() : Language.ANY;
}
示例5: getScriptLanguage
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Nullable
protected Language getScriptLanguage() {
Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(scriptType != null ? scriptType.trim() : null);
return instancesByMimeType.isEmpty() ? null : instancesByMimeType.iterator().next();
}