Search in sources :

Example 1 with ModuleEx

use of com.intellij.openapi.module.impl.ModuleEx in project intellij-community by JetBrains.

the class CoreModuleManager method createAndLoadModule.

@NotNull
@Override
protected ModuleEx createAndLoadModule(@NotNull String filePath, @NotNull VirtualFile file) throws IOException {
    final ModuleEx module = createModule(filePath);
    try {
        ModuleRootManagerImpl.ModuleRootManagerState state = new ModuleRootManagerImpl.ModuleRootManagerState();
        state.readExternal(CoreProjectLoader.loadStorageFile(module, file).get("NewModuleRootManager"));
        ((ModuleRootManagerImpl) ModuleRootManager.getInstance(module)).loadState(state);
    } catch (JDOMException e) {
        throw new IOException(e);
    }
    return module;
}
Also used : ModuleRootManagerImpl(com.intellij.openapi.roots.impl.ModuleRootManagerImpl) ModuleEx(com.intellij.openapi.module.impl.ModuleEx) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ModuleEx

use of com.intellij.openapi.module.impl.ModuleEx 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 3 with ModuleEx

use of com.intellij.openapi.module.impl.ModuleEx in project intellij-community by JetBrains.

the class ProjectRootManagerComponent method clearScopesCachesForModules.

@Override
public void clearScopesCachesForModules() {
    super.clearScopesCachesForModules();
    Module[] modules = ModuleManager.getInstance(myProject).getModules();
    for (Module module : modules) {
        ((ModuleEx) module).clearScopesCache();
    }
}
Also used : ModuleEx(com.intellij.openapi.module.impl.ModuleEx) Module(com.intellij.openapi.module.Module)

Example 4 with ModuleEx

use of com.intellij.openapi.module.impl.ModuleEx in project intellij-community by JetBrains.

the class ModuleScopesTest method testScopeEquality.

public void testScopeEquality() {
    Module module = createModule("a.iml", StdModuleTypes.JAVA);
    addDependentModule(module, DependencyScope.COMPILE);
    addLibrary(module, DependencyScope.COMPILE);
    GlobalSearchScope deps = module.getModuleWithDependentsScope();
    GlobalSearchScope depsTests = module.getModuleTestsWithDependentsScope();
    assertFalse(deps.equals(depsTests));
    assertFalse(depsTests.equals(deps));
    ((ModuleEx) module).clearScopesCache();
    GlobalSearchScope deps2 = module.getModuleWithDependentsScope();
    GlobalSearchScope depsTests2 = module.getModuleTestsWithDependentsScope();
    assertFalse(deps2.equals(depsTests2));
    assertFalse(depsTests2.equals(deps2));
    assertNotSame(deps, deps2);
    assertNotSame(depsTests, depsTests2);
    assertEquals(deps, deps2);
    assertEquals(depsTests, depsTests2);
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ModuleEx(com.intellij.openapi.module.impl.ModuleEx) Module(com.intellij.openapi.module.Module)

Aggregations

ModuleEx (com.intellij.openapi.module.impl.ModuleEx)4 Module (com.intellij.openapi.module.Module)3 ModuleRootManagerImpl (com.intellij.openapi.roots.impl.ModuleRootManagerImpl)1 LibraryTableBase (com.intellij.openapi.roots.impl.libraries.LibraryTableBase)1 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 SmartList (com.intellij.util.SmartList)1 IOException (java.io.IOException)1 JDOMException (org.jdom.JDOMException)1 NotNull (org.jetbrains.annotations.NotNull)1