use of com.intellij.openapi.module.ModuleManager in project intellij-community by JetBrains.
the class ModuleTestCase method loadModule.
protected Module loadModule(@NotNull String modulePath) {
final ModuleManager moduleManager = ModuleManager.getInstance(myProject);
Module module;
try {
module = ApplicationManager.getApplication().runWriteAction((ThrowableComputable<Module, Exception>) () -> moduleManager.loadModule(FileUtil.toSystemIndependentName(modulePath)));
} catch (Exception e) {
LOG.error(e);
return null;
}
myModulesToDispose.add(module);
return module;
}
use of com.intellij.openapi.module.ModuleManager in project intellij-plugins by JetBrains.
the class AngularJSProjectConfigurator method configureProject.
@Override
public void configureProject(Project project, @NotNull VirtualFile baseDir, Ref<Module> moduleRef) {
final ModuleManager moduleManager = ModuleManager.getInstance(project);
final Module[] modules = moduleManager.getModules();
if (modules.length == 1) {
final VirtualFile cliJson = baseDir.findChild(ANGULAR_CLI_JSON);
final ModifiableRootModel model = ModuleRootManager.getInstance(modules[0]).getModifiableModel();
final ContentEntry entry = MarkRootActionBase.findContentEntry(model, baseDir);
if (entry != null && cliJson != null) {
excludeDefault(baseDir, entry);
ApplicationManager.getApplication().runWriteAction(() -> {
model.commit();
project.save();
});
} else {
model.dispose();
}
}
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class DataNodeCaches method isCacheMissingModels.
public boolean isCacheMissingModels(@NotNull DataNode<ProjectData> cache) {
Collection<DataNode<ModuleData>> moduleDataNodes = findAll(cache, MODULE);
if (!moduleDataNodes.isEmpty()) {
Map<String, DataNode<ModuleData>> moduleDataNodesByName = indexByModuleName(moduleDataNodes);
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
for (Module module : moduleManager.getModules()) {
DataNode<ModuleData> moduleDataNode = moduleDataNodesByName.get(module.getName());
if (moduleDataNode == null) {
// When a Gradle facet is present, there should be a cache node for the module.
GradleFacet gradleFacet = GradleFacet.getInstance(module);
if (gradleFacet != null) {
return true;
}
} else if (isCacheMissingModels(moduleDataNode, module)) {
return true;
}
}
return false;
}
return true;
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class AndroidGradleTestCase method loadProject.
protected void loadProject(@NotNull String relativePath, @Nullable GradleSyncListener listener, @Nullable String chosenModuleName) throws Exception {
prepareProjectForImport(relativePath);
Project project = getProject();
File projectRoot = virtualToIoFile(project.getBaseDir());
importProject(project.getName(), projectRoot, listener);
assertTrue(AndroidProjectInfo.getInstance(project).requiresAndroidModel());
assertFalse(isLegacyIdeaAndroidProject(project));
ModuleManager moduleManager = ModuleManager.getInstance(project);
Module[] modules = moduleManager.getModules();
// if module name is specified, find it
if (chosenModuleName != null) {
for (Module module : modules) {
if (chosenModuleName.equals(module.getName())) {
myAndroidFacet = AndroidFacet.getInstance(module);
break;
}
}
}
if (myAndroidFacet == null) {
// then try and find a non-lib facet
for (Module module : modules) {
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet != null && androidFacet.isAppProject()) {
myAndroidFacet = androidFacet;
break;
}
}
}
// then try and find ANY android facet
if (myAndroidFacet == null) {
for (Module module : modules) {
myAndroidFacet = AndroidFacet.getInstance(module);
if (myAndroidFacet != null) {
break;
}
}
}
refreshProjectFiles();
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class MakeGradleProjectAction method doPerform.
@Override
protected void doPerform(@NotNull AnActionEvent e, @NotNull Project project) {
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
if (statusBar != null) {
// Reset info from the previous runs (if any).
statusBar.setInfo(" ");
}
ModuleManager moduleManager = ModuleManager.getInstance(project);
GradleBuildInvoker.getInstance(project).compileJava(moduleManager.getModules(), GradleBuildInvoker.TestCompileType.NONE);
}
Aggregations