use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class ConfigureAndroidModuleStepDynamicTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
ApplicationManager.getApplication().runWriteAction(() -> {
final ModuleManager manager = ModuleManager.getInstance(getProject());
File moduleRoot = new File(getProject().getBasePath(), "app");
manager.newModule(moduleRoot.getPath(), ModuleTypeId.JAVA_MODULE);
moduleRoot = new File(getProject().getBasePath(), "Lib");
manager.newModule(moduleRoot.getPath(), ModuleTypeId.JAVA_MODULE);
moduleRoot = new File(getProject().getBasePath(), "lib2");
manager.newModule(moduleRoot.getPath(), ModuleTypeId.JAVA_MODULE);
});
ScopedStateStore wizardState = new ScopedStateStore(ScopedStateStore.Scope.WIZARD, null, null);
ScopedStateStore pathState = new ScopedStateStore(ScopedStateStore.Scope.PATH, wizardState, null);
myStep = new ConfigureAndroidModuleStepDynamic(getTestRootDisposable(), FormFactor.MOBILE);
myStep.myState = new ScopedStateStore(ScopedStateStore.Scope.STEP, pathState, myStep);
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class ConfigureAndroidModuleStepDynamicTest method testComputeModuleName_deduplication.
public void testComputeModuleName_deduplication() throws Exception {
ModuleManager manager = ModuleManager.getInstance(getProject());
Module module = manager.getModules()[0];
assertEquals("app", module.getName());
// "Lib" and "lib2" already exist
assertEquals("lib3", WizardUtils.computeModuleName("Lib", getProject()));
// "app" already exists
assertEquals("app2", WizardUtils.computeModuleName("app", getProject()));
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class ProjectStructureUsageTrackerTest method trackGradleProject.
/**
* Builds a set of mock objects representing an Android Studio project with a set of modules
* and calls the tracking code to report metrics on this project.
*/
private void trackGradleProject(String project) throws Exception {
loadProject(project);
ProjectStructureUsageTracker psut = new ProjectStructureUsageTracker(getProject());
ModuleManager moduleManager = ModuleManager.getInstance(getProject());
psut.trackProjectStructure(moduleManager.getModules());
}
use of com.intellij.openapi.module.ModuleManager 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);
});
}
}
use of com.intellij.openapi.module.ModuleManager in project intellij-community by JetBrains.
the class GotoImplementationTest method test.
public void test() throws Exception {
ModuleManager moduleManager = ModuleManager.getInstance(getProject());
Module[] modules = moduleManager.getModules();
assertEquals(3, modules.length);
Module module1 = moduleManager.findModuleByName("test1");
Module module2 = moduleManager.findModuleByName("test2");
Module module3 = moduleManager.findModuleByName("test3");
final GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(module1);
PsiClass test1 = myJavaFacade.findClass("com.test.TestI", moduleScope);
PsiClass test2 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module2));
PsiClass test3 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module3));
HashSet<PsiElement> expectedImpls1 = new HashSet<>(Arrays.asList(myJavaFacade.findClass("com.test.TestIImpl1", moduleScope), myJavaFacade.findClass("com.test.TestIImpl2", moduleScope)));
assertEquals(expectedImpls1, new HashSet<>(getClassImplementations(test1)));
PsiMethod psiMethod = test1.findMethodsByName("test", false)[0];
Set<PsiElement> expectedMethodImpl1 = new HashSet<>(Arrays.asList(myJavaFacade.findClass("com.test.TestIImpl1", moduleScope).findMethodsByName("test", false)[0], myJavaFacade.findClass("com.test.TestIImpl2", moduleScope).findMethodsByName("test", false)[0]));
CommonProcessors.CollectProcessor<PsiElement> processor = new CommonProcessors.CollectProcessor<>();
MethodImplementationsSearch.processImplementations(psiMethod, processor, moduleScope);
assertEquals(expectedMethodImpl1, new HashSet<>(processor.getResults()));
HashSet<PsiElement> expectedImpls2 = new HashSet<>(Arrays.asList(myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module2)), myJavaFacade.findClass("com.test.TestIImpl3", GlobalSearchScope.moduleScope(module2))));
assertEquals(expectedImpls2, new HashSet<>(getClassImplementations(test2)));
HashSet<PsiElement> expectedImpls3 = new HashSet<>(Arrays.asList(myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module3))));
assertEquals(expectedImpls3, new HashSet<>(getClassImplementations(test3)));
}
Aggregations