void () { ProjectStructureConfigurable projectStructureConfigurable = myContext.getModulesConfigurator().getProjectStructureConfigurable(); BaseLibrariesConfigurable configurable = BaseLibrariesConfigurable.getInstance(projectStructureConfigurable, LibraryTablesRegistrar.PROJECT_LEVEL); Library[] libraries = configurable.getModelProvider().getModifiableModel().getLibraries(); List<LibraryProjectStructureElement> toRemove = new ArrayList<>(); for (Library library : libraries) { LibraryProjectStructureElement libraryElement = new LibraryProjectStructureElement(myContext, library); if (myContext.getDaemonAnalyzer().getUsages(libraryElement).isEmpty()) { toRemove.add(libraryElement); } } configurable.removeLibraries(toRemove); }