[missing from docs] Getting PSI file with full file path
已回答
Hi,
I'm trying to get PSI file using the full path of the file, and it seems impossible right now.
In the docs, https://www.jetbrains.org/intellij/sdk/docs/basics/psi_cookbook.html, it specifies a way to do it with only the filename but this way results with many files that I need to filter again by myself each file's fullpath.
for example trying to get "a/b/index.js" will result getting ALL files that are named "index.js" at EVERY directory in the project...
Do you guys know of a way to get PSI file with a specific path?
Thank you!
请先登录再写评论。
Gilad,
If you have a VirtualFile (I assume you have its full path), try with:
Hi Jakub Chrzanowski,
I actually don't have a virtual file, I have it just as a variable (queried from DB or other service that saves full-paths).
Is there a way to get the psi file with just the full path?
You can get VirtualFile using
VirtualFileManager.getInstance().findFileByUrl("file://" + localPath);