PsiFile (@NotNull String rootPath, @NotNull String relativePath, @NotNull String fileText) { try { VirtualFile file = WriteCommandAction.runWriteCommandAction(getProject(), (ThrowableComputable<VirtualFile, IOException>)() -> { try { VirtualFile f; if (myTempDirFixture instanceof LightTempDirTestFixtureImpl) { f = myTempDirFixture.createFile(relativePath, fileText); } else if (myProjectFixture instanceof HeavyIdeaTestFixture){ f = ((HeavyIdeaTestFixture)myProjectFixture).addFileToProject(rootPath, relativePath, fileText).getViewProvider() .getVirtualFile(); } else { f = myTempDirFixture.createFile(relativePath, fileText); } prepareVirtualFile(f); return f; } catch (IOException e) { throw new RuntimeException(e); } finally { PsiManager.getInstance(getProject()).dropPsiCaches(); } }); return ReadAction.compute(() -> PsiManager.getInstance(getProject()).findFile(file)); } catch (IOException e) { throw new RuntimeException(e); } }