当前位置: 首页>>代码示例>>Java>>正文


Java LanguageUtil.isInjectableLanguage方法代码示例

本文整理汇总了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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:HtmlScriptLanguageInjector.java

示例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();
  }
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:20,代码来源:HtmlScriptLanguageInjector.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:HtmlLexer.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:InjectedLanguage.java

示例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();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:HtmlScriptLanguageInjector.java

示例6: isInjectableLanguage

import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
public static boolean isInjectableLanguage(Language language) {
  return LanguageUtil.isInjectableLanguage(language);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:InjectedLanguageUtil.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:47,代码来源:HtmlLexer.java


注:本文中的com.intellij.lang.LanguageUtil.isInjectableLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。