VirtualFile (@NotNull String fileName, @NotNull String text) { assertInitialized(); try { return WriteCommandAction.writeCommandAction(getProject()).compute(() -> { VirtualFile file; if (myTempDirFixture instanceof LightTempDirTestFixtureImpl) { VirtualFile root = LightPlatformTestCase.getSourceRoot(); root.refresh(false, false); file = root.findOrCreateChildData(this, fileName); assertNotNull(fileName + " not found in " + root.getPath(), file); } else if (myTempDirFixture instanceof TempDirTestFixtureImpl) { Path tempFile = ((TempDirTestFixtureImpl)myTempDirFixture).createTempFile(fileName); file = LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(tempFile.toString())); assertNotNull(tempFile + " not found", file); } else { file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(getTempDirPath(), fileName)); assertNotNull(fileName + " not found in " + getTempDirPath(), file); } prepareVirtualFile(file); Document document = FileDocumentManager.getInstance().getCachedDocument(file); if (document != null) { PsiDocumentManager.getInstance(getProject()).doPostponedOperationsAndUnblockDocument(document); FileDocumentManager.getInstance().saveDocument(document); } VfsUtil.saveText(file, text); return file; }); } catch (IOException e) { throw new RuntimeException(e); } }