public static Document createPythonCodeDocument(
      @NotNull final Project project, @NotNull IpnbCodeSourcePanel codeSourcePanel) {
    final String text = codeSourcePanel.getCell().getSourceAsString().trim();
    final IpnbPyFragment fragment = new IpnbPyFragment(project, text, true, codeSourcePanel);

    return PsiDocumentManager.getInstance(project).getDocument(fragment);
  }
 public IpnbPyFragment(
     Project project, CharSequence text, boolean isPhysical, IpnbCodeSourcePanel codeSourcePanel) {
   super(
       PsiManagerEx.getInstanceEx(project)
           .getFileManager()
           .createFileViewProvider(
               new LightVirtualFile("code.py", IpnbPyLanguageDialect.getInstance(), text),
               isPhysical));
   myPhysical = isPhysical;
   myCodeSourcePanel = codeSourcePanel;
   myFilePanel = codeSourcePanel.getIpnbCodePanel().getFileEditor().getIpnbFilePanel();
   ((SingleRootFileViewProvider) getViewProvider()).forceCachedPsi(this);
 }