VirtualFile (File ioFile, CodeInsightTestFixture fixture, String rootPath) { try { String path = FileUtil.getRelativePath(FileUtil.toCanonicalPath(rootPath), FileUtil.toSystemIndependentName(ioFile.getPath()), '/'); assert path != null; Matcher rootPackageMatcher = Pattern.compile("/com/|/org/|/onair/").matcher(path); if (rootPackageMatcher.find()) { path = path.substring(rootPackageMatcher.start() + 1); } VirtualFile existing = fixture.getTempDirFixture().getFile(path); if (existing != null) { WriteAction.run(() -> existing.delete(fixture)); } return fixture.addFileToProject(path, FileUtil.loadFile(ioFile)).getVirtualFile(); } catch (IOException e) { throw new RuntimeException(e); } }