private static @Nullable Editor getEditor(@NotNull PsiFile psiFile, boolean canCreate) {
    VirtualFile vFile = psiFile.getViewProvider().getVirtualFile();
    Document document = FileDocumentManager.getInstance().getDocument(vFile);
    if (document == null) {
      return null;
    }

    Project project = psiFile.getProject();
    return EditorFactory.getInstance().editors(document, project)
      .findFirst()
      .orElseGet(() -> canCreate ? EditorFactory.getInstance().createEditor(document, project) : null);
  }
private static @Nullable Editor getEditor(@NotNull PsiFile psiFile, boolean canCreate)