Why would PsiFile be null for a VirtualFile?
Under what circumstances does this happen? My users are reporting
strange exceptions which are semi-reproducible, but only on their
machines. A null PsiFile is returned from PsiManager.findFile
consistently for the same VirtualFile in some cases, even though the
file exists.
Please sign in to leave a comment.
There may be several reasons, eq. file is ignored, no filetype
associated, (in a alibrary path?), (directory?), ...
Or maybe your custom language returns null from parsing?
Keith Lea schrieb:
I don't believe any of these are true. It's in sourcepath.
Sven Steiniger wrote:
>> Under what circumstances does this happen? My users are reporting
>> strange exceptions which are semi-reproducible, but only on their
>> machines. A null PsiFile is returned from PsiManager.findFile
>> consistently for the same VirtualFile in some cases, even though the
>> file exists.
Please check vFile.isValid() is true (this is not the same as physical file being present on the disk). Another reason is ignored file as Sven already mentioned.
Eugene Vigdorchik wrote:
I'll add a log message. In the mean time, I'd like to know how can I
convert from an invalid VirtualFile to its existing valid counterpart?
This file which had null psifile certainly exists, so there must be a
VirtualFile for it. Is the solution to call
VfsUtil.findFileByUrl(VfsUtil.pathToUrl(file.getPath())) every time I
use a VirtualFile?