use of com.intellij.openapi.roots.impl.libraries.LibraryTableBase in project intellij-community by JetBrains.
the class ModuleRootManagerComponent method getStateModificationCount.
@Override
public long getStateModificationCount() {
Module module = getModule();
if (!module.isLoaded() || !(module instanceof ModuleEx)) {
return myModificationCount;
}
final long[] result = { myModificationCount };
result[0] += ((ModuleEx) module).getOptionsModificationCount();
final List<String> handledLibraryTables = new SmartList<>();
getRootModel().orderEntries().forEachLibrary(library -> {
LibraryTable table = library.getTable();
if (table instanceof LibraryTableBase && !handledLibraryTables.contains(table.getTableLevel())) {
handledLibraryTables.add(table.getTableLevel());
long count = ((LibraryTableBase) table).getStateModificationCount();
if (count > 0) {
if (Registry.is("store.track.module.root.manager.changes", false)) {
LOG.error("modification count changed due to library " + library.getName() + " change (" + count + "), module " + getModule().getName());
}
}
result[0] += count;
}
return true;
});
return result[0] + myRootModel.getStateModificationCount();
}
use of com.intellij.openapi.roots.impl.libraries.LibraryTableBase in project intellij-community by JetBrains.
the class LibraryTest method testReloadLibraryTable.
public void testReloadLibraryTable() {
((LibraryTableBase) getLibraryTable()).loadState(new Element("component"));
createLibrary("a", null, null);
((LibraryTableBase) getLibraryTable()).loadState(new Element("component").addContent(new Element("library").setAttribute("name", "b")));
assertEquals("b", assertOneElement(getLibraryTable().getLibraries()).getName());
}
use of com.intellij.openapi.roots.impl.libraries.LibraryTableBase in project intellij-community by JetBrains.
the class CoreProjectLoader method loadDirectoryProject.
private static void loadDirectoryProject(MockProject project, @NotNull VirtualFile dotIdea) throws IOException, JDOMException {
VirtualFile modulesXml = dotIdea.findChild("modules.xml");
if (modulesXml == null)
throw new FileNotFoundException("Missing 'modules.xml' in " + dotIdea.getPath());
TreeMap<String, Element> storageData = loadStorageFile(project, modulesXml);
final Element moduleManagerState = storageData.get("ProjectModuleManager");
if (moduleManagerState == null) {
throw new JDOMException("cannot find ProjectModuleManager state in modules.xml");
}
final CoreModuleManager moduleManager = (CoreModuleManager) ModuleManager.getInstance(project);
moduleManager.loadState(moduleManagerState);
VirtualFile miscXml = dotIdea.findChild("misc.xml");
if (miscXml != null) {
storageData = loadStorageFile(project, miscXml);
final Element projectRootManagerState = storageData.get("ProjectRootManager");
if (projectRootManagerState == null) {
throw new JDOMException("cannot find ProjectRootManager state in misc.xml");
}
((ProjectRootManagerImpl) ProjectRootManager.getInstance(project)).loadState(projectRootManagerState);
}
VirtualFile libraries = dotIdea.findChild("libraries");
if (libraries != null) {
Map<String, Element> data = DirectoryStorageUtil.loadFrom(libraries, PathMacroManager.getInstance(project));
Element libraryTable = DefaultStateSerializer.deserializeState(DirectoryStorageUtil.getCompositeState(data, new ProjectLibraryTable.LibraryStateSplitter()), Element.class, null);
((LibraryTableBase) ProjectLibraryTable.getInstance(project)).loadState(libraryTable);
}
moduleManager.loadModules();
project.projectOpened();
}
Aggregations