use of com.intellij.openapi.module.ModuleTypeManager in project intellij-community by JetBrains.
the class PlatformProjectConfigurator method configureProject.
@Override
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, final Ref<Module> moduleRef) {
final ModuleManager moduleManager = ModuleManager.getInstance(project);
final Module[] modules = moduleManager.getModules();
if (modules.length == 0) {
ApplicationManager.getApplication().runWriteAction(() -> {
// correct module name when opening root of drive as project (RUBY-5181)
String moduleName = baseDir.getName().replace(":", "");
String imlName = baseDir.getPath() + "/.idea/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION;
ModuleTypeManager instance = ModuleTypeManager.getInstance();
String id = instance == null ? "unknown" : instance.getDefaultModuleType().getId();
final Module module = moduleManager.newModule(imlName, id);
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
ModifiableRootModel rootModel = rootManager.getModifiableModel();
if (rootModel.getContentRoots().length == 0) {
rootModel.addContentEntry(baseDir);
}
rootModel.inheritSdk();
rootModel.commit();
moduleRef.set(module);
});
}
}
Aggregations