Opening a PsiFile

Hi there, and thanks for all your help so far. I'm pulling data from an API and making a new document out of it. I'm using PsiFileFactory.createFileFromText() and it returns a PsiFile. I then want to open it in an editor. From what I understand I'm supposed to use psiFile.navigate() for this, but it fails because the file isn't saved in a directory yet. I would prefer not to save the file locally if I can avoid it (ala scratch pad). But I can't seem to find anyway to accomplish this. Any feedback would be appreciated, thanks in advance.

0
2 comments
Official comment

To open a file in editor, a VirtualFile should be available. Have you considered creating a scratch (via ScratchFileService#findFile) and opening it?

Avatar
Permanently deleted user

Thanks for getting me on the right path. I ended up using 

ScratchRootType.createScratchFile()

Made life very easy. Thanks again!

0

Please sign in to leave a comment.