本文整理汇总了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()]);
}
示例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();
}
示例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;
}