本文整理匯總了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;
}