VirtualFile (File dir) { VirtualFile result; try { result = WriteAction.computeAndWait(() -> { // create externally, since files created via VFS are marked for editing automatically File file = new File(dir, FileUtil.createSequentFileName(dir, "extfile", "txt")); assertTrue(file.createNewFile()); return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file); }); } catch (IOException e) { throw new RuntimeException(e); } myCreatedFiles.add(result); return result; }