void (final VirtualFile mavenProjectFile, final boolean forceRead) { // if the file has already been updated, skip subsequent updates if (!startUpdate(mavenProjectFile, forceRead)) return; var mavenProject = tree.findOrCreateProject(mavenProjectFile); // we will compare modules and children before and after reading the pom.xml file var prevModules = tree.getModules(mavenProject); var prevChildren = tree.findInheritors(mavenProject); // read pom.xml if something has changed since the last reading or reading is forced boolean readPom = readPomIfNeeded(mavenProject, forceRead); var existingModuleFiles = mavenProject.getExistingModuleFiles(); // some modules might have been removed handleRemovedModules(mavenProject, prevModules, existingModuleFiles); // collect new and existing modules to reconnect to the tree var modulesFilesToReconnect = collectModuleFilesToReconnect(mavenProject, existingModuleFiles); boolean updateExistingModules = readPom || updateModules; // collect modules to update recursively var modulesFilesToUpdate = collectModuleFilesToUpdate(modulesFilesToReconnect, updateExistingModules); // do not force update modules if only this project was requested to be updated var forceReadModules = updateModules && forceRead; var moduleUpdates = ContainerUtil.map(modulesFilesToUpdate, moduleFile -> new UpdateSpec( moduleFile, forceReadModules )); updateProjects(moduleUpdates); reconnectModuleFiles(mavenProject, modulesFilesToReconnect); // collect children (inheritors) to update recursively var childFilesToUpdate = collectChildFilesToUpdate(mavenProject, prevChildren); var childUpdates = ContainerUtil.map(childFilesToUpdate, childFile -> new UpdateSpec( childFile, readPom // if parent was read, force read children )); updateProjects(childUpdates); }