當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。