本文整理匯總了Java中com.intellij.psi.FileViewProvider.getContents方法的典型用法代碼示例。如果您正苦於以下問題:Java FileViewProvider.getContents方法的具體用法?Java FileViewProvider.getContents怎麽用?Java FileViewProvider.getContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.FileViewProvider
的用法示例。
在下文中一共展示了FileViewProvider.getContents方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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()]);
}