public abstract class ModuleManagerImpl extends ModuleManagerEx implements Disposable, PersistentStateComponent<Element>, ProjectComponent
Disposable.Parent
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTRIBUTE_FILEPATH |
static java.lang.String |
ATTRIBUTE_FILEURL |
static java.lang.String |
ATTRIBUTE_GROUP |
static java.lang.String |
COMPONENT_NAME |
static java.lang.String |
ELEMENT_MODULE |
static java.lang.String |
ELEMENT_MODULES |
static java.lang.String |
IML_EXTENSION |
static java.lang.String |
MODULE_GROUP_SEPARATOR |
protected MessageBus |
myMessageBus |
protected com.intellij.openapi.module.impl.ModuleManagerImpl.ModuleModelImpl |
myModuleModel |
protected Project |
myProject |
EVER_CHANGED, NEVER_CHANGED
Constructor and Description |
---|
ModuleManagerImpl(Project project) |
Modifier and Type | Method and Description |
---|---|
boolean |
areModulesLoaded() |
protected void |
cleanCachedStuff() |
static void |
commitModelWithRunnable(ModifiableModuleModel model,
java.lang.Runnable runnable) |
protected abstract ModuleEx |
createAndLoadModule(java.lang.String filePath) |
protected abstract ModuleEx |
createModule(java.lang.String filePath) |
protected ModuleEx |
createNonPersistentModule(java.lang.String name) |
protected void |
deliverPendingEvents() |
void |
dispose()
Usually not invoked directly, see class javadoc.
|
void |
disposeModule(Module module)
Disposes of the specified module and removes it from the project.
|
Module |
findModuleByName(java.lang.String name)
Returns the project module with the specified name.
|
protected void |
fireBeforeModuleRemoved(Module module) |
protected void |
fireModuleAdded(Module module) |
protected void |
fireModuleAddedInWriteAction(ModuleEx module) |
protected void |
fireModuleLoadErrors(java.util.List<? extends ModuleLoadingErrorDescription> errors) |
protected void |
fireModuleRemoved(Module module) |
void |
fireModuleRenamedByVfsEvent(Module module,
java.lang.String oldName) |
protected void |
fireModulesAdded() |
protected void |
fireModulesRenamed(java.util.List<Module> modules,
java.util.Map<Module,java.lang.String> oldNames) |
java.util.Collection<ModuleDescription> |
getAllModuleDescriptions() |
java.util.Collection<ModulePath> |
getFailedModulePaths() |
static ModuleManagerImpl |
getInstanceImpl(Project project) |
ModifiableModuleModel |
getModifiableModel()
Returns the model for the list of modules in the project, which can be used to add,
remove or modify modules.
|
java.util.List<Module> |
getModuleDependentModules(Module module)
Returns the list of modules which directly depend on the specified module.
|
ModuleGrouper |
getModuleGrouper(ModifiableModuleModel model) |
java.lang.String[] |
getModuleGroupPath(Module module)
Returns the path to the group to which the specified module belongs, as an array of group names starting from the project root.
|
int |
getModulePathsCount() |
Module [] |
getModules()
Returns the list of all modules in the project.
|
static java.util.Set<ModulePath> |
getPathsToModuleFiles(Element element) |
Module [] |
getSortedModules()
Returns the list of modules sorted by dependency (the modules which do not depend
on anything are in the beginning of the list, a module which depends on another module
follows it in the list).
|
Element |
getState() |
UnloadedModuleDescription |
getUnloadedModuleDescription(java.lang.String moduleName) |
java.util.Collection<UnloadedModuleDescription> |
getUnloadedModuleDescriptions() |
boolean |
hasModuleGroups() |
boolean |
isModuleDependent(Module module,
Module onModule)
Checks if one of the specified modules directly depends on the other module.
|
protected boolean |
isUnknownModuleType(Module module) |
Module |
loadModule(java.lang.String filePath)
Loads a module from an .iml file with the specified path and adds it to the project.
|
protected void |
loadModules(com.intellij.openapi.module.impl.ModuleManagerImpl.ModuleModelImpl moduleModel) |
void |
loadState(Element state)
This method is called when new component state is loaded.
|
java.util.Comparator<Module> |
moduleDependencyComparator()
Returns the module comparator which can be used for sorting modules by dependency
(the modules which do not depend on anything are in the beginning of the list,
a module which depends on another module follows it in the list).
|
Graph<Module> |
moduleGraph()
Returns the graph of dependencies between modules in the project.
|
Graph<Module> |
moduleGraph(boolean includeTests)
Returns the graph of dependencies between modules in the project.
|
Module |
newModule(java.lang.String filePath,
java.lang.String moduleTypeId)
Creates a module of the specified type at the specified path and adds it to the project
to which the module manager is related.
|
Module |
newNonPersistentModule(java.lang.String moduleName,
java.lang.String id)
Creates a non-persistent module of the specified type and adds it to the project
to which the module manager is related.
|
void |
noStateLoaded()
This method is called when the component is initialized, but no state is persisted.
|
void |
projectClosed()
Invoked when the project corresponding to this component instance is closed.
|
void |
projectOpened()
Invoked when the project corresponding to this component instance is opened.
|
void |
removeUnloadedModules(java.util.Collection<? extends UnloadedModuleDescription> unloadedModules) |
void |
setModuleGroupPath(Module module,
java.lang.String [] groupPath) |
void |
setProgressStep(double step) |
protected void |
setUnloadedModuleNames(java.util.List<java.lang.String> unloadedModuleNames) |
void |
setUnloadedModules(java.util.List<java.lang.String> unloadedModuleNames)
Specify list of modules which will be unloaded from the project.
|
protected void |
showUnknownModuleTypeNotification(java.util.List<? extends Module> types) |
protected void |
unloadNewlyAddedModulesIfPossible(java.util.Set<ModulePath> modulesToLoad,
java.util.List<UnloadedModuleDescriptionImpl> modulesToUnload) |
void |
writeExternal(Element element,
java.util.List<? extends Module> collection) |
static void |
writeExternal(Element element,
java.util.List<? extends Module> collection,
ModuleManagerEx moduleManager) |
getInstanceEx
getInstance
getModificationCount, incModificationCount
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initializeComponent
disposeComponent, initComponent
getComponentName
public static final java.lang.String COMPONENT_NAME
public static final java.lang.String ELEMENT_MODULES
public static final java.lang.String ELEMENT_MODULE
public static final java.lang.String ATTRIBUTE_FILEURL
public static final java.lang.String ATTRIBUTE_FILEPATH
public static final java.lang.String ATTRIBUTE_GROUP
public static final java.lang.String IML_EXTENSION
public static final java.lang.String MODULE_GROUP_SEPARATOR
protected final Project myProject
protected final MessageBus myMessageBus
protected volatile com.intellij.openapi.module.impl.ModuleManagerImpl.ModuleModelImpl myModuleModel
public ModuleManagerImpl(Project project)
public static ModuleManagerImpl getInstanceImpl(Project project)
public void projectOpened()
ProjectComponent
Note that components may be created for even unopened projects and this method can be never invoked for a particular component instance (for example for default project).
projectOpened
in interface ProjectComponent
public void projectClosed()
ProjectComponent
Note that components may be created for even unopened projects and this method can be never invoked for a particular component instance (for example for default project).
projectClosed
in interface ProjectComponent
protected void cleanCachedStuff()
public void dispose()
Disposable
dispose
in interface Disposable
public Element getState()
getState
in interface PersistentStateComponent<Element>
null
value indicates
that the returned state won't be stored, as a result previously stored state will be used.XmlSerializer
public void loadState(Element state)
PersistentStateComponent
State object should be used directly, defensive copying is not required.
loadState
in interface PersistentStateComponent<Element>
state
- loaded component stateXmlSerializerUtil.copyBean(Object, Object)
public void noStateLoaded()
PersistentStateComponent
noStateLoaded
in interface PersistentStateComponent<Element>
protected void unloadNewlyAddedModulesIfPossible(java.util.Set<ModulePath> modulesToLoad, java.util.List<UnloadedModuleDescriptionImpl> modulesToUnload)
public static java.util.Set<ModulePath> getPathsToModuleFiles(Element element)
protected void loadModules(com.intellij.openapi.module.impl.ModuleManagerImpl.ModuleModelImpl moduleModel)
public int getModulePathsCount()
public boolean areModulesLoaded()
public void setProgressStep(double step)
protected boolean isUnknownModuleType(Module module)
protected void showUnknownModuleTypeNotification(java.util.List<? extends Module> types)
protected void fireModuleAdded(Module module)
protected void fireModuleRemoved(Module module)
protected void fireBeforeModuleRemoved(Module module)
protected void fireModulesRenamed(java.util.List<Module> modules, java.util.Map<Module,java.lang.String> oldNames)
protected void fireModuleLoadErrors(java.util.List<? extends ModuleLoadingErrorDescription> errors)
public ModifiableModuleModel getModifiableModel()
ModuleManager
getModifiableModel
in class ModuleManager
public void writeExternal(Element element, java.util.List<? extends Module> collection)
public static void writeExternal(Element element, java.util.List<? extends Module> collection, ModuleManagerEx moduleManager)
public Module newModule(java.lang.String filePath, java.lang.String moduleTypeId)
ModuleManager
newModule
in class ModuleManager
filePath
- path to an *.iml file where module configuration will be saved; name of the module will be equal to the file name without extension.moduleTypeId
- the ID of the module type to create.public Module newNonPersistentModule(java.lang.String moduleName, java.lang.String id)
ModuleManager
#commit()
must be called to
bring the changes in effect.
In contrast with modules created by ModuleManager.newModule(String, String)
,
non-persistent modules aren't stored on a filesystem and aren't being written
in a project XML file. When IDE closes, all non-persistent modules vanishes out.newNonPersistentModule
in class ModuleManager
public Module loadModule(java.lang.String filePath) throws java.io.IOException, ModuleWithNameAlreadyExists
ModuleManager
loadModule
in class ModuleManager
filePath
- the path to load the module from.java.io.IOException
- if an I/O error occurred when loading the module file.ModuleWithNameAlreadyExists
- if a module with such a name already exists in the project.public void disposeModule(Module module)
ModuleManager
disposeModule
in class ModuleManager
module
- the module to remove.public Module [] getModules()
ModuleManager
getModules
in class ModuleManager
public Module [] getSortedModules()
ModuleManager
getSortedModules
in class ModuleManager
public Module findModuleByName(java.lang.String name)
ModuleManager
findModuleByName
in class ModuleManager
name
- the name of the module to find.public java.util.Comparator<Module> moduleDependencyComparator()
ModuleManager
moduleDependencyComparator
in class ModuleManager
protected void deliverPendingEvents()
public Graph<Module> moduleGraph()
ModuleManager
moduleGraph
in class ModuleManager
public Graph<Module> moduleGraph(boolean includeTests)
ModuleManager
moduleGraph
in class ModuleManager
includeTests
- whether test-only dependencies should be includedpublic java.util.List<Module> getModuleDependentModules(Module module)
ModuleManager
getModuleDependentModules
in class ModuleManager
module
- the module for which the list of dependent modules is requested.ModuleUtilCore.getAllDependentModules(Module)
public boolean isModuleDependent(Module module, Module onModule)
ModuleManager
isModuleDependent
in class ModuleManager
module
- the module to check the dependency for.onModule
- the module on which module
may depend.module
directly depends on onModule
, false otherwise.protected void fireModulesAdded()
protected void fireModuleAddedInWriteAction(ModuleEx module)
public static void commitModelWithRunnable(ModifiableModuleModel model, java.lang.Runnable runnable)
protected abstract ModuleEx createModule(java.lang.String filePath)
protected ModuleEx createNonPersistentModule(java.lang.String name)
protected abstract ModuleEx createAndLoadModule(java.lang.String filePath) throws java.io.IOException
java.io.IOException
public void fireModuleRenamedByVfsEvent(Module module, java.lang.String oldName)
public java.lang.String[] getModuleGroupPath(Module module)
ModuleManager
Use ModuleGrouper#getGroupPath(Module)
instead. Explicit module groups will be replaced
by automatical module grouping accordingly to qualified names of modules, see https://youtrack.jetbrains.com/issue/IDEA-166061 for details.
getModuleGroupPath
in class ModuleManager
module
- the module for which the path is requested.public boolean hasModuleGroups()
hasModuleGroups
in class ModuleManager
public java.util.Collection<ModuleDescription> getAllModuleDescriptions()
getAllModuleDescriptions
in class ModuleManager
public java.util.Collection<UnloadedModuleDescription> getUnloadedModuleDescriptions()
getUnloadedModuleDescriptions
in class ModuleManager
public java.util.Collection<ModulePath> getFailedModulePaths()
getFailedModulePaths
in class ModuleManagerEx
public UnloadedModuleDescription getUnloadedModuleDescription(java.lang.String moduleName)
getUnloadedModuleDescription
in class ModuleManager
public ModuleGrouper getModuleGrouper(ModifiableModuleModel model)
getModuleGrouper
in class ModuleManager
public void setUnloadedModules(java.util.List<java.lang.String> unloadedModuleNames)
ModuleManager
setUnloadedModules
in class ModuleManager
UnloadedModuleDescription
public void removeUnloadedModules(java.util.Collection<? extends UnloadedModuleDescription> unloadedModules)
removeUnloadedModules
in class ModuleManager
protected void setUnloadedModuleNames(java.util.List<java.lang.String> unloadedModuleNames)
public void setModuleGroupPath(Module module, java.lang.String [] groupPath)