With recent builds of IDEA (12.1 EAP Series), some of my plugin tests started failing due to PsiFileImpl.isValid() returning false. I've worked around the failures, but I was left wondering if my workaround simply hides a real problem. Here's the background:
The problematic tests all extended this test, and I tracked the problems down to the call to TemplateDataLanguageMappings. That call is creating a new instance of the file it is given, which results in PsiFile.isPsiUpToDate() evaluating to false (which then results in PsiFileImpl.isValid() being false).
I've worked around the issue by fetching the file out of the project after the call to TemplateDataLanguageMappings (see diff here), but it feels like that shouldn't be necessary... so I was wondering:
- Could there be a flaw in my test that lead to this?
- Or is this indicative of a bug introduced in IDEA?
- Or is this totally OK and grabbing a fresh copy of a file from the project before manipulating it is a best practice?
Hope that all makes sense!