void (Element element) { if (myWritable) { myRemovedLibraries.addAll(myLibraries); } myLibraries.clear(); final List<Element> libraryElements = element.getChildren(JpsLibraryTableSerializer.LIBRARY_TAG); for (Element libraryElement : libraryElements) { final LibraryImpl library = new LibraryImpl(LibraryTableBase.this, libraryElement, null); if (library.getName() != null) { myLibraries.add(library); if (myWritable) { myAddedLibraries.add(library); } } else { Disposer.dispose(library); } } if (!myLibraries.isEmpty()) { /* this is a temporary workaround until IDEA-296918 is implemented: we need to invoke 'fireLibraryAdded' under write action, but 'readExternal' may be called from a background thread (IDEA-272575) */ ThrowableRunnable<RuntimeException> fireEvents = () -> { for (Library library : myLibraries) { fireLibraryAdded(library); } }; if (ApplicationManager.getApplication().isWriteAccessAllowed()) { fireEvents.run(); } else { ApplicationManager.getApplication().invokeLater(() -> { WriteAction.run(fireEvents); }); } } myLibraryByNameCache = null; }