void (@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext) { MavenActionsUsagesCollector.trigger(project, MavenActionsUsagesCollector.EXTRACT_MANAGED_DEPENDENCIES); Pair<MavenDomDependency, Set<MavenDomProjectModel>> depAndParents = findDependencyAndParent(file, editor); if (depAndParents == null) return; final MavenDomDependency dependency = depAndParents.first; Set<MavenDomProjectModel> parent = depAndParents.second; Function<MavenDomProjectModel, Set<MavenDomDependency>> funOccurrences = getOccurencesFunction(dependency); final ProcessData processData = getProcessData(project, parent, funOccurrences, dependency.getExclusions().getXmlElement() != null); if (processData == null) return; final MavenDomProjectModel model = processData.getModel(); final Set<MavenDomDependency> usages = processData.getUsages(); final boolean extractExclusions = processData.isExtractExclusions(); assert model != null; assert usages != null; WriteCommandAction.writeCommandAction(project, getFiles(file, model, usages)).run(() -> { MavenDomDependency addedDependency = model.getDependencyManagement().getDependencies().addDependency(); addedDependency.getGroupId().setStringValue(dependency.getGroupId().getStringValue()); addedDependency.getArtifactId().setStringValue(dependency.getArtifactId().getStringValue()); addedDependency.getVersion().setStringValue(dependency.getVersion().getStringValue()); String typeValue = dependency.getType().getStringValue(); dependency.getVersion().undefine(); if (typeValue != null) { addedDependency.getType().setStringValue(typeValue); } String classifier = dependency.getClassifier().getStringValue(); if (classifier != null) { addedDependency.getClassifier().setStringValue(classifier); } String systemPath = dependency.getSystemPath().getStringValue(); if (systemPath != null) { addedDependency.getSystemPath().setStringValue(systemPath); dependency.getSystemPath().undefine(); } if (extractExclusions) { MavenDomExclusions addedExclusions = addedDependency.getExclusions(); for (MavenDomExclusion exclusion : dependency.getExclusions().getExclusions()) { MavenDomExclusion domExclusion = addedExclusions.addExclusion(); domExclusion.getGroupId().setStringValue(exclusion.getGroupId().getStringValue()); domExclusion.getArtifactId().setStringValue(exclusion.getArtifactId().getStringValue()); } dependency.getExclusions().undefine(); } for (MavenDomDependency usage : usages) { usage.getVersion().undefine(); } }); }