"VirtualFile.getUrl()" vs. "VirtualFileUrl" vs "VirtualFileId"

A general question and one more specific question

  1. In monolith mode, what’s the recommendation to reference a VirtualFile?
  • May VirtualFileUrl be used only for Workspace-related files or is a more generic use okay?
  • Should VirtualFileId only be used for RPC-aware APIs or is more generic use okay?
  • What’s the downside of the plain VirtualFile.getUrl()? Lookup performance or something else?
  1. Question related to split mode:
    In a plugin, which is capable of split mode, I need to store a reference to a VirtualFile.
    The file is on the backend, but to pass state between frontend and backend, it must be serializable. The file will be read only a few times and not regularly.

    It must:
  • be serializable via RPC, for split-mode
  • not keep a strong reference to the VirtualFile (to avoid leaks and to reference potentially invalid files)

    If I understand correctly, a VirtualFileId keeps a strong reference in monolith mode.
    And VirtualFileUrl is (probably) not serializable.
    That would leave “VirtualFile.getUrl()”, even though I’d prefer the newer alternatives.

Any recommendations on the best way to handle VirtualFiles?