Search in sources :

Example 1 with LibraryTableBase

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();
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) ModuleEx(com.intellij.openapi.module.impl.ModuleEx) LibraryTableBase(com.intellij.openapi.roots.impl.libraries.LibraryTableBase) Module(com.intellij.openapi.module.Module) SmartList(com.intellij.util.SmartList)

Example 2 with LibraryTableBase

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());
}
Also used : Element(org.jdom.Element) LibraryTableBase(com.intellij.openapi.roots.impl.libraries.LibraryTableBase)

Example 3 with LibraryTableBase

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectRootManagerImpl(com.intellij.openapi.roots.impl.ProjectRootManagerImpl) Element(org.jdom.Element) FileNotFoundException(java.io.FileNotFoundException) LibraryTableBase(com.intellij.openapi.roots.impl.libraries.LibraryTableBase) JDOMException(org.jdom.JDOMException)

Aggregations

LibraryTableBase (com.intellij.openapi.roots.impl.libraries.LibraryTableBase)3 Element (org.jdom.Element)2 Module (com.intellij.openapi.module.Module)1 ModuleEx (com.intellij.openapi.module.impl.ModuleEx)1 ProjectRootManagerImpl (com.intellij.openapi.roots.impl.ProjectRootManagerImpl)1 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 SmartList (com.intellij.util.SmartList)1 FileNotFoundException (java.io.FileNotFoundException)1 JDOMException (org.jdom.JDOMException)1