Create VirtualFile or PsiFile from content
Answered
Hi.
How can I create PsiFile or VirtualFile from it's content, without having actual file on disk? In case when file is actually deleted, but it's content in stored in commit data.
I found very old thread and seems that PsiManager API was changed since this post: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206790245/comments/206196325
Please sign in to leave a comment.
Actually, I figured solution right after creating this thread :D
Right. And if you need virtual file by any chance, there is a `com.intellij.testFramework.LightVirtualFile`
Thanks!
I am writing a plugin. I need to save data to a file, and the file can be read.
my plugin saved data should be share on every project, so I think I should save a file located plugin path or idea path, not be active project path.
What I should do? I can't find any solution in the official doc.
When I write code like following
It reports permission denied
Hi Qhe.
If you want to serialize the objects, you can use PersistentStateComponent, check this.
https://www.jetbrains.org/intellij/sdk/docs/basics/persisting_state_of_components.html
If you want to save the file, you should not write absolute paths in File constructor. Try relative paths.
I used PersistentStateComponent, but when I restart ide, data get missing, according to doc, it shouldn't be like this.