ActionCallback (@NotNull List<? extends LibraryOrderEntry> orderEntriesContainingFile) { final List<Library.ModifiableModel> modelsToCommit = new ArrayList<>(); for (LibraryOrderEntry orderEntry : orderEntriesContainingFile) { final Library library = orderEntry.getLibrary(); if (library == null) continue; final VirtualFile root = findRoot(library); if (root == null) continue; final Library.ModifiableModel model = library.getModifiableModel(); model.addRoot(root, OrderRootType.SOURCES); modelsToCommit.add(model); } if (modelsToCommit.isEmpty()) return ActionCallback.REJECTED; WriteAction.runAndWait(() -> { for (Library.ModifiableModel model : modelsToCommit) { model.commit(); } }); return ActionCallback.DONE; }