Document (@Nullable PsiFile file) { Document document = file != null ? PsiDocumentManager.getInstance(file.getProject()).getDocument(file) : null; return document != null ? document : EditorFactory.getInstance().createDocument(myTemplate == null ? "" : myTemplate.getText()); }