@Override
 public Document getDocument() {
   Document document = myDocument != null ? myDocument.get() : null;
   if (document == null /* TODO[ik] make this change && isEventSystemEnabled()*/) {
     document = FileDocumentManager.getInstance().getDocument(getVirtualFile());
     myDocument = new SoftReference<Document>(document);
   }
   if (document != null && getContent() instanceof VirtualFileContent) {
     setContent(new DocumentContent());
   }
   return document;
 }
 protected SingleRootFileViewProvider(
     @NotNull PsiManager manager,
     @NotNull VirtualFile virtualFile,
     final boolean physical,
     @NotNull Language language) {
   myManager = manager;
   myVirtualFile = virtualFile;
   myEventSystemEnabled = physical;
   myBaseLanguage = language;
   setContent(new VirtualFileContent());
   myPhysical =
       isEventSystemEnabled()
           && !(virtualFile instanceof LightVirtualFile)
           && !(virtualFile.getFileSystem() instanceof NonPhysicalFileSystem);
   myExclusionManager = ProjectFileExclusionManager.SERVICE.getInstance(manager.getProject());
 }
 public void beforeDocumentChanged() {
   final PsiFileImpl psiFile = (PsiFileImpl) getCachedPsi(getBaseLanguage());
   if (psiFile != null && psiFile.isContentsLoaded() && getContent() instanceof DocumentContent) {
     setContent(new PsiFileContent(psiFile, getModificationStamp()));
   }
 }
 @Override
 public void rootChanged(PsiFile psiFile) {
   if (((PsiFileEx) psiFile).isContentsLoaded()) {
     setContent(new PsiFileContent((PsiFileImpl) psiFile, LocalTimeCounter.currentTime()));
   }
 }
 private void unsetPsiContent() {
   if (!(myContent instanceof PsiFileContent)) return;
   final Document cachedDocument = getCachedDocument();
   setContent(cachedDocument == null ? new VirtualFileContent() : new DocumentContent());
 }