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);
}
Aggregations