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


Java FileViewProvider.getBaseLanguage方法代码示例

本文整理汇总了Java中com.intellij.psi.FileViewProvider.getBaseLanguage方法的典型用法代码示例。如果您正苦于以下问题:Java FileViewProvider.getBaseLanguage方法的具体用法?Java FileViewProvider.getBaseLanguage怎么用?Java FileViewProvider.getBaseLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.FileViewProvider的用法示例。


在下文中一共展示了FileViewProvider.getBaseLanguage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkFile

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@Override
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
  if (InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file)) return null;
  if (!file.isPhysical()) return null;
  FileViewProvider viewProvider = file.getViewProvider();
  if (viewProvider.getBaseLanguage() != file.getLanguage()) return null;
  VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return null;
  if (!virtualFile.isInLocalFileSystem()) return null;
  CharSequence text = viewProvider.getContents();
  Charset charset = LoadTextUtil.extractCharsetFromFileContent(file.getProject(), virtualFile, text);

  // no sense in checking transparently decoded file: all characters there are already safely encoded
  if (charset instanceof Native2AsciiCharset) return null;

  List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>();
  boolean ok = checkFileLoadedInWrongEncoding(file, manager, isOnTheFly, virtualFile, charset, descriptors);
  if (ok) {
    checkIfCharactersWillBeLostAfterSave(file, manager, isOnTheFly, text, charset, descriptors);
  }

  return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LossyEncodingInspection.java

示例2: getRootLanguage

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@NotNull
public static Language getRootLanguage(@NotNull PsiElement element) {
  final FileViewProvider provider = element.getContainingFile().getViewProvider();
  final Set<Language> languages = provider.getLanguages();
  if (languages.size() > 1) {
    PsiElement current = element;
    while (current != null) {
      final Language language = current.getLanguage();
      if (languages.contains(language)) return language;
      current = current.getParent();
    }
  }
  return provider.getBaseLanguage();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:LanguageUtil.java

示例3: isHtmlTagContainingFile

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
public static boolean isHtmlTagContainingFile(PsiElement element) {
  if (element == null) {
    return false;
  }
  final PsiFile containingFile = element.getContainingFile();
  if (containingFile != null) {
    final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
    if (tag instanceof HtmlTag) {
      return true;
    }
    final XmlDocument document = PsiTreeUtil.getParentOfType(element, XmlDocument.class, false);
    if (document instanceof HtmlDocumentImpl) {
      return true;
    }
    final FileViewProvider provider = containingFile.getViewProvider();
    Language language;
    if (provider instanceof TemplateLanguageFileViewProvider) {
      language = ((TemplateLanguageFileViewProvider)provider).getTemplateDataLanguage();
    }
    else {
      language = provider.getBaseLanguage();
    }

    return language == XHTMLLanguage.INSTANCE;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:HtmlUtil.java


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