void (Project project, InspectionsReportConverter reportConverter) { Path rootLogDir = Paths.get(PathManager.getLogPath()).resolve("projectStructureChanges"); //noinspection ResultOfMethodCallIgnored rootLogDir.toFile().mkdirs(); AtomicInteger counter = new AtomicInteger(0); reportConverter.projectData(project, rootLogDir.resolve("state0")); MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(ModuleRootListener.TOPIC, new ModuleRootListener() { @Override public void rootsChanged(@NotNull ModuleRootEvent event) { updateProjectStructure(counter, reportConverter, project, rootLogDir); } }); connection.subscribe(AdditionalLibraryRootsListener.TOPIC, (__, __1, __2, __3) -> updateProjectStructure(counter, reportConverter, project, rootLogDir)); }