Search in sources :

Example 51 with ModuleManager

use of com.intellij.openapi.module.ModuleManager in project intellij-elixir by KronicDeth.

the class ParsingTestCase method registerModuleManager.

private void registerModuleManager(MessageBus messageBus) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
    Class<?> moduleManagerComponentClass = Class.forName("com.intellij.openapi.module.impl.ModuleManagerComponent");
    Constructor<?> moduleManagerComponentConstructor;
    ModuleManager moduleManager = null;
    try {
        // IntelliJ > 2016.3
        moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class);
        moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject);
    } catch (NoSuchMethodException e1) {
        try {
            // IntelliJ 2016.3
            moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class, MessageBus.class);
            moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject, messageBus);
        } catch (NoSuchMethodException e2) {
            moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class, ProgressManager.class, MessageBus.class);
            moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject, new ProgressManagerImpl(), messageBus);
        }
    }
    myProject.registerService(ModuleManager.class, moduleManager);
}
Also used : Project(com.intellij.openapi.project.Project) MessageBus(com.intellij.util.messages.MessageBus) ProgressManager(com.intellij.openapi.progress.ProgressManager) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) ModuleManager(com.intellij.openapi.module.ModuleManager)

Aggregations

ModuleManager (com.intellij.openapi.module.ModuleManager)51 Module (com.intellij.openapi.module.Module)40 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 Project (com.intellij.openapi.project.Project)10 NotNull (org.jetbrains.annotations.NotNull)8 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)7 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)7 File (java.io.File)7 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)3 IOException (java.io.IOException)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 AndroidLibrary (com.android.builder.model.AndroidLibrary)2 Variant (com.android.builder.model.Variant)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 BuildMode (com.android.tools.idea.gradle.util.BuildMode)2 AccessToken (com.intellij.openapi.application.AccessToken)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 ContentEntry (com.intellij.openapi.roots.ContentEntry)2 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)2