本文整理汇总了Java中com.intellij.lang.LanguageUtil.isInjectableLanguage方法的典型用法代码示例。如果您正苦于以下问题:Java LanguageUtil.isInjectableLanguage方法的具体用法?Java LanguageUtil.isInjectableLanguage怎么用?Java LanguageUtil.isInjectableLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.lang.LanguageUtil
的用法示例。
在下文中一共展示了LanguageUtil.isInjectableLanguage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLanguagesToInject
import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement host) {
if (!host.isValid() || !(host instanceof XmlText) || !HtmlUtil.isHtmlTagContainingFile(host)) {
return;
}
XmlTag scriptTag = ((XmlText)host).getParentTag();
if (scriptTag == null) {
return;
}
final Language language = getScriptLanguageToInject(scriptTag);
if (language == null || HtmlScriptInjectionBlockerExtension.isInjectionBlocked(scriptTag, language)) {
return;
}
if (LanguageUtil.isInjectableLanguage(language)) {
registrar
.startInjecting(language)
.addPlace(null, null, (PsiLanguageInjectionHost)host, TextRange.create(0, host.getTextLength()))
.doneInjecting();
}
}
示例2: injectLanguages
import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
@Override
public void injectLanguages(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement host) {
if (!(host instanceof XmlText)) {
return;
}
XmlTag scriptTag = ((XmlText)host).getParentTag();
if (!"script".equalsIgnoreCase(scriptTag.getLocalName())) {
return;
}
String mimeType = scriptTag.getAttributeValue("type");
Collection<Language> languages = Language.findInstancesByMimeType(mimeType);
Language language = languages.isEmpty() ? null : languages.iterator().next();
if (language != null && LanguageUtil.isInjectableLanguage(language)) {
registrar
.startInjecting(language)
.addPlace(null, null, (PsiLanguageInjectionHost)host, TextRange.create(0, host.getTextLength()))
.doneInjecting();
}
}
示例3: getTokenType
import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
public IElementType getTokenType() {
if (myTokenType!=null) return myTokenType;
IElementType tokenType = super.getTokenType();
myTokenStart = super.getTokenStart();
myTokenEnd = super.getTokenEnd();
if (hasSeenStyle()) {
if (hasSeenTag() && ourStyleElementType!=null && isStartOfEmbeddmentTagContent(tokenType)) {
myTokenEnd = skipToTheEndOfTheEmbeddment();
tokenType = ourStyleElementType;
} else if (ourInlineStyleElementType!=null && isStartOfEmbeddmentAttributeValue(tokenType) && hasSeenAttribute()) {
tokenType = ourInlineStyleElementType;
}
} else if (hasSeenScript()) {
Language scriptLanguage = getScriptLanguage();
boolean canInject = scriptLanguage == null || LanguageUtil.isInjectableLanguage(scriptLanguage);
if (hasSeenTag() && isStartOfEmbeddmentTagContent(tokenType) && canInject) {
myTokenEnd = skipToTheEndOfTheEmbeddment();
IElementType currentScriptElementType = getCurrentScriptElementType();
tokenType = currentScriptElementType == null ? XmlTokenType.XML_DATA_CHARACTERS : currentScriptElementType;
} else if (hasSeenAttribute() && isStartOfEmbeddmentAttributeValue(tokenType) && ourInlineScriptElementType!=null) {
myTokenEnd = skipToTheEndOfTheEmbeddment();
tokenType = ourInlineScriptElementType;
}
}
return myTokenType = tokenType;
}
示例4: initLanguageCache
import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
private static void initLanguageCache() {
ourLanguageCache = new HashMap<String, Language>();
Collection<Language> registeredLanguages;
do {
registeredLanguages = new ArrayList<Language>(Language.getRegisteredLanguages());
for (Language language : registeredLanguages) {
if (LanguageUtil.isInjectableLanguage(language)) {
ourLanguageCache.put(language.getID(), language);
}
}
} while (Language.getRegisteredLanguages().size() != registeredLanguages.size());
ourLanguageCount = registeredLanguages.size();
}
示例5: getLanguagesToInject
import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement host) {
if (!host.isValid() || !(host instanceof XmlText) || !HtmlUtil.isHtmlTagContainingFile(host)) {
return;
}
XmlTag scriptTag = ((XmlText)host).getParentTag();
if (scriptTag == null || !"script".equalsIgnoreCase(scriptTag.getLocalName())) {
return;
}
String mimeType = scriptTag.getAttributeValue("type");
Collection<Language> languages = Language.findInstancesByMimeType(mimeType);
Language language;
if (!languages.isEmpty()) {
language = languages.iterator().next();
}
else if (mimeType != null && mimeType.contains("template")) {
language = StdLanguages.HTML;
}
else {
language = StdLanguages.TEXT;
}
if (LanguageUtil.isInjectableLanguage(language)) {
registrar
.startInjecting(language)
.addPlace(null, null, (PsiLanguageInjectionHost)host, TextRange.create(0, host.getTextLength()))
.doneInjecting();
}
}
示例6: isInjectableLanguage
import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
public static boolean isInjectableLanguage(Language language) {
return LanguageUtil.isInjectableLanguage(language);
}
示例7: getTokenType
import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
@Override
public IElementType getTokenType()
{
if(myTokenType != null)
{
return myTokenType;
}
IElementType tokenType = super.getTokenType();
myTokenStart = super.getTokenStart();
myTokenEnd = super.getTokenEnd();
if(hasSeenStyle())
{
if(hasSeenTag() && isStartOfEmbeddmentTagContent(tokenType))
{
myTokenEnd = skipToTheEndOfTheEmbeddment();
IElementType currentStylesheetElementType = getCurrentStylesheetElementType();
tokenType = currentStylesheetElementType == null ? XmlTokenType.XML_DATA_CHARACTERS : currentStylesheetElementType;
}
else if(ourInlineStyleElementType != null && isStartOfEmbeddmentAttributeValue(tokenType) && hasSeenAttribute())
{
tokenType = ourInlineStyleElementType;
}
}
else if(hasSeenScript())
{
if(hasSeenTag() && isStartOfEmbeddmentTagContent(tokenType))
{
Language scriptLanguage = getScriptLanguage();
if(scriptLanguage == null || LanguageUtil.isInjectableLanguage(scriptLanguage))
{
myTokenEnd = skipToTheEndOfTheEmbeddment();
IElementType currentScriptElementType = getCurrentScriptElementType();
tokenType = currentScriptElementType == null ? XmlTokenType.XML_DATA_CHARACTERS : currentScriptElementType;
}
}
else if(hasSeenAttribute() && isStartOfEmbeddmentAttributeValue(tokenType) && ourInlineScriptElementType != null)
{
myTokenEnd = skipToTheEndOfTheEmbeddment();
tokenType = ourInlineScriptElementType;
}
}
return myTokenType = tokenType;
}