public void testIgnoringProjectsForDeletedModules() throws Exception { createProjectPom( "<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + " <module>m</module>" + "</modules>"); VirtualFile m = createModulePom( "m", "<groupId>test</groupId>" + "<artifactId>m</artifactId>" + "<version>1</version>"); importProject(); Module module = getModule("m"); assertNotNull(module); assertFalse(myProjectsManager.isIgnored(myProjectsManager.findProject(m))); ModuleManager.getInstance(myProject).disposeModule(module); myProjectsManager.performScheduledImportInTests(); assertNull(ModuleManager.getInstance(myProject).findModuleByName("m")); assertTrue(myProjectsManager.isIgnored(myProjectsManager.findProject(m))); }
@Override public WorkspaceConfig get() { SimpleWorkspaceConfig _xblockexpression = null; { ProjectManager _instance = ProjectManager.getInstance(); Project[] _openProjects = _instance.getOpenProjects(); final Project project = IterableExtensions.<Project>head( ((Iterable<Project>) Conversions.doWrapArray(_openProjects))); String _basePath = project.getBasePath(); final SimpleWorkspaceConfig result = new SimpleWorkspaceConfig(_basePath); ModuleManager _instance_1 = ModuleManager.getInstance(project); Module[] _modules = _instance_1.getModules(); final Procedure1<Module> _function = new Procedure1<Module>() { @Override public void apply(final Module m) { IdeaModuleConfig _ideaModuleConfig = new IdeaModuleConfig(m, IdeaWorkspaceConfigProvider.this.outputConfigurations); result.addProjectConfig(_ideaModuleConfig); } }; IterableExtensions.<Module>forEach( ((Iterable<Module>) Conversions.doWrapArray(_modules)), _function); _xblockexpression = result; } return _xblockexpression; }
private static void removeGenModule(@NotNull final Module libModule) { final String genModuleName = getGenModuleName(libModule); final ModuleManager moduleManager = ModuleManager.getInstance(libModule.getProject()); final ModifiableRootModel model = ModuleRootManager.getInstance(libModule).getModifiableModel(); for (OrderEntry entry : model.getOrderEntries()) { if (entry instanceof ModuleOrderEntry && genModuleName.equals(((ModuleOrderEntry) entry).getModuleName())) { model.removeOrderEntry(entry); } } ApplicationManager.getApplication() .runWriteAction( new Runnable() { @Override public void run() { model.commit(); } }); final Module genModule = moduleManager.findModuleByName(genModuleName); if (genModule == null) { return; } moduleManager.disposeModule(genModule); final VirtualFile moduleFile = genModule.getModuleFile(); if (moduleFile != null) { ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { ApplicationManager.getApplication() .runWriteAction( new Runnable() { @Override public void run() { try { moduleFile.delete(libModule.getProject()); } catch (IOException e) { LOG.error(e); } } }); } }); } }
public Collection<Module> getValidModules() { if (TEST_PACKAGE.equals(myData.TEST_OBJECT) || TEST_PATTERN.equals(myData.TEST_OBJECT)) { return Arrays.asList(ModuleManager.getInstance(getProject()).getModules()); } try { myData.getTestObject(getProject(), this).checkConfiguration(); } catch (RuntimeConfigurationError e) { return Arrays.asList(ModuleManager.getInstance(getProject()).getModules()); } catch (RuntimeConfigurationException e) { // ignore } return JavaRunConfigurationModule.getModulesForClass(getProject(), myData.getMainClassName()); }
@Override public Module commitModule(@NotNull final Project project, ModifiableModuleModel model) { if (myProjectMode) { final Module[] modules = ModuleManager.getInstance(project).getModules(); if (modules.length > 0) { ApplicationManager.getApplication() .runWriteAction( new Runnable() { @Override public void run() { try { Module module = modules[0]; setupModule(module); ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel(); modifiableModuleModel.renameModule(module, module.getProject().getName()); modifiableModuleModel.commit(); } catch (ConfigurationException e) { LOG.error(e); } catch (ModuleWithNameAlreadyExists exists) { // do nothing } } }); } return null; } else { return super.commitModule(project, model); } }
@Override protected void hyperlinkActivated(HyperlinkEvent e) { final Module moduleByName = ModuleManager.getInstance(myProject).findModuleByName(e.getDescription()); if (moduleByName != null) { myConfiguration.getConfigurationModule().setModule(moduleByName); try { final Executor executor = myConsoleProperties.isDebug() ? DefaultDebugExecutor.getDebugExecutorInstance() : DefaultRunExecutor.getRunExecutorInstance(); final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), myConfiguration); assert runner != null; runner.execute( executor, new ExecutionEnvironment( myConfiguration, myProject, getRunnerSettings(), getConfigurationSettings(), null)); final Balloon balloon = myToolWindowManager.getToolWindowBalloon(myTestRunDebugId); if (balloon != null) { balloon.hide(); } } catch (ExecutionException e1) { LOG.error(e1); } } }
@NotNull @Override public Set<UsageDescriptor> getProjectUsages(@Nullable Project project) { if (project == null) return Collections.emptySet(); final Set<LibraryKind> usedKinds = new HashSet<LibraryKind>(); final Processor<Library> processor = new Processor<Library>() { @Override public boolean process(Library library) { usedKinds.addAll(LibraryPresentationManagerImpl.getLibraryKinds(library, null)); return true; } }; for (Module module : ModuleManager.getInstance(project).getModules()) { ModuleRootManager.getInstance(module) .orderEntries() .librariesOnly() .forEachLibrary(processor); } final HashSet<UsageDescriptor> usageDescriptors = new HashSet<UsageDescriptor>(); for (LibraryKind kind : usedKinds) { usageDescriptors.add(new UsageDescriptor(kind.getKindId(), 1)); } return usageDescriptors; }
private void calculateRoots() { final ModuleManager moduleManager = ModuleManager.getInstance(myProject); // assertion for read access inside final Module[] modules = ApplicationManager.getApplication() .runReadAction( new Computable<Module[]>() { public Module[] compute() { return moduleManager.getModules(); } }); final TreeSet<VirtualFile> checkSet = new TreeSet<VirtualFile>(FilePathComparator.getInstance()); myRoots = new HashSet<VirtualFile>(); myRoots.addAll(myInitialRoots); checkSet.addAll(myInitialRoots); for (Module module : modules) { final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots(); for (VirtualFile file : files) { final VirtualFile floor = checkSet.floor(file); if (floor != null) { myModulesSet.put(file, module.getName()); myRoots.add(file); } } } }
@Nullable private PsiDirectory[] getSelectedDirectories() { if (myBuilder == null) return null; final Object[] selectedNodeElements = getSelectedNodeElements(); if (selectedNodeElements.length != 1) return null; for (FavoriteNodeProvider nodeProvider : Extensions.getExtensions(FavoriteNodeProvider.EP_NAME, myProject)) { final PsiElement psiElement = nodeProvider.getPsiElement(selectedNodeElements[0]); if (psiElement instanceof PsiDirectory) { return new PsiDirectory[] {(PsiDirectory) psiElement}; } else if (psiElement instanceof PsiDirectoryContainer) { final String moduleName = nodeProvider.getElementModuleName(selectedNodeElements[0]); GlobalSearchScope searchScope = GlobalSearchScope.projectScope(myProject); if (moduleName != null) { final Module module = ModuleManager.getInstance(myProject).findModuleByName(moduleName); if (module != null) { searchScope = GlobalSearchScope.moduleScope(module); } } return ((PsiDirectoryContainer) psiElement).getDirectories(searchScope); } } return selectedNodeElements[0] instanceof PsiDirectory ? new PsiDirectory[] {(PsiDirectory) selectedNodeElements[0]} : null; }
private JComponent createToolbar() { DefaultActionGroup group = new DefaultActionGroup(); group.add(new CloseAction()); group.add(new RerunAction(this)); group.add(new FlattenPackagesAction()); group.add(new ShowFilesAction()); if (ModuleManager.getInstance(myProject).getModules().length > 1) { group.add(new ShowModulesAction()); group.add(new ShowModuleGroupsAction()); } group.add(new GroupByScopeTypeAction()); // group.add(new GroupByFilesAction()); group.add(new FilterLegalsAction()); group.add(new MarkAsIllegalAction()); group.add(new ChooseScopeTypeAction()); group.add(new EditDependencyRulesAction()); group.add( CommonActionsManager.getInstance() .createExportToTextFileAction(new DependenciesExporterToTextFile())); group.add(new ContextHelpAction("dependency.viewer.tool.window")); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); return toolbar.getComponent(); }
@Override protected void setUp() throws Exception { if (ourOutputRoot == null) { ourOutputRoot = FileUtil.createTempDirectory("ExecutionTestCase", null, true); } myModuleOutputDir = new File(ourOutputRoot, PathUtil.getFileName(getTestAppPath())); myChecker = initOutputChecker(); EdtTestUtil.runInEdtAndWait( new ThrowableRunnable<Throwable>() { @Override public void run() throws Throwable { ExecutionTestCase.super.setUp(); } }); if (!myModuleOutputDir.exists()) { VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ourOutputRoot); assertNotNull(ourOutputRoot.getAbsolutePath(), vDir); vDir .getChildren(); // we need this to load children to VFS to fire VFileCreatedEvent for the // output directory myCompilerTester = new CompilerTester( myProject, Arrays.asList(ModuleManager.getInstance(myProject).getModules())); List<CompilerMessage> messages = myCompilerTester.rebuild(); for (CompilerMessage message : messages) { if (message.getCategory() == CompilerMessageCategory.ERROR) { FileUtil.delete(myModuleOutputDir); fail("Compilation failed: " + message); } } } }
public static Set<Artifact> getArtifactsToBuild( final Project project, final CompileScope compileScope, final boolean addIncludedArtifactsWithOutputPathsOnly) { final Artifact[] artifactsFromScope = getArtifacts(compileScope); final ArtifactManager artifactManager = ArtifactManager.getInstance(project); PackagingElementResolvingContext context = artifactManager.getResolvingContext(); if (artifactsFromScope != null) { return addIncludedArtifacts( Arrays.asList(artifactsFromScope), context, addIncludedArtifactsWithOutputPathsOnly); } final Set<Artifact> cached = compileScope.getUserData(CACHED_ARTIFACTS_KEY); if (cached != null) { return cached; } Set<Artifact> artifacts = new HashSet<Artifact>(); final Set<Module> modules = new HashSet<Module>(Arrays.asList(compileScope.getAffectedModules())); final List<Module> allModules = Arrays.asList(ModuleManager.getInstance(project).getModules()); for (Artifact artifact : artifactManager.getArtifacts()) { if (artifact.isBuildOnMake()) { if (modules.containsAll(allModules) || containsModuleOutput(artifact, modules, context)) { artifacts.add(artifact); } } } Set<Artifact> result = addIncludedArtifacts(artifacts, context, addIncludedArtifactsWithOutputPathsOnly); compileScope.putUserData(CACHED_ARTIFACTS_KEY, result); return result; }
@Nullable private static Module getModule(Project project, PythonRunParams config) { String name = config.getModuleName(); return StringUtil.isEmpty(name) ? null : ModuleManager.getInstance(project).findModuleByName(name); }
public void testModulesSelector() throws ConfigurationException { if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return; Module module1 = getModule1(); Module module2 = getModule2(); JUnitConfigurable editor = new JUnitConfigurable(myProject); try { JUnitConfiguration configuration = createConfiguration(findTestA(module2)); editor.getComponent(); // To get all the watchers installed. Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration); JComboBox comboBox = editor.getModulesComponent(); configurable.reset(); assertFalse(configurable.isModified()); assertEquals(module2.getName(), ((Module) comboBox.getSelectedItem()).getName()); assertEquals( ModuleManager.getInstance(myProject).getModules().length + 1, comboBox.getModel().getSize()); // no module comboBox.setSelectedItem(module1); assertTrue(configurable.isModified()); configurable.apply(); assertFalse(configurable.isModified()); assertEquals( Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules())); } finally { Disposer.dispose(editor); } }
@NotNull private static Map<Module, String> collectJpsPluginModules(@NotNull Module module) { XmlFile pluginXml = PluginModuleType.getPluginXml(module); if (pluginXml == null) return Collections.emptyMap(); DomFileElement<IdeaPlugin> fileElement = DomManager.getDomManager(module.getProject()).getFileElement(pluginXml, IdeaPlugin.class); if (fileElement == null) return Collections.emptyMap(); Map<Module, String> jpsPluginToOutputPath = new HashMap<Module, String>(); IdeaPlugin plugin = fileElement.getRootElement(); List<Extensions> extensions = plugin.getExtensions(); for (Extensions extensionGroup : extensions) { XmlTag extensionsTag = extensionGroup.getXmlTag(); String defaultExtensionNs = extensionsTag.getAttributeValue("defaultExtensionNs"); for (XmlTag tag : extensionsTag.getSubTags()) { String name = tag.getLocalName(); String qualifiedName = defaultExtensionNs != null ? defaultExtensionNs + "." + name : name; if (CompileServerPlugin.EP_NAME.getName().equals(qualifiedName)) { String classpath = tag.getAttributeValue("classpath"); if (classpath != null) { for (String path : StringUtil.split(classpath, ";")) { String moduleName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(path)); Module jpsModule = ModuleManager.getInstance(module.getProject()).findModuleByName(moduleName); if (jpsModule != null) { jpsPluginToOutputPath.put(jpsModule, path); } } } } } } return jpsPluginToOutputPath; }
private JComponent createTreeToolbar() { final DefaultActionGroup group = new DefaultActionGroup(); final Runnable update = new Runnable() { public void run() { rebuild(true); } }; if (ProjectViewDirectoryHelper.getInstance(myProject).supportsFlattenPackages()) { group.add(new FlattenPackagesAction(update)); } final PatternDialectProvider[] dialectProviders = Extensions.getExtensions(PatternDialectProvider.EP_NAME); for (PatternDialectProvider provider : dialectProviders) { for (AnAction action : provider.createActions(myProject, update)) { group.add(action); } } group.add(new ShowFilesAction(update)); final Module[] modules = ModuleManager.getInstance(myProject).getModules(); if (modules.length > 1) { group.add(new ShowModulesAction(update)); group.add(new ShowModuleGroupsAction(update)); } group.add(new FilterLegalsAction(update)); if (dialectProviders.length > 1) { group.add(new ChooseScopeTypeAction(update)); } ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); return toolbar.getComponent(); }
@Override public void recalculateOutputDirs() { final Module[] allModules = ModuleManager.getInstance(myProject).getModules(); final Set<VirtualFile> allDirs = new OrderedSet<VirtualFile>(); final Set<VirtualFile> testOutputDirs = new java.util.HashSet<VirtualFile>(); final Set<VirtualFile> productionOutputDirs = new java.util.HashSet<VirtualFile>(); CompilerPathsManager pathsManager = CompilerPathsManager.getInstance(getProject()); for (Module module : allModules) { final VirtualFile output = pathsManager.getCompilerOutput(module, ProductionContentFolderTypeProvider.getInstance()); if (output != null && output.isValid()) { allDirs.add(output); productionOutputDirs.add(output); } final VirtualFile testsOutput = pathsManager.getCompilerOutput(module, TestContentFolderTypeProvider.getInstance()); if (testsOutput != null && testsOutput.isValid()) { allDirs.add(testsOutput); testOutputDirs.add(testsOutput); } } myOutputDirectories = VfsUtil.toVirtualFileArray(allDirs); // need this to ensure that the sent contains only _dedicated_ test output dirs // Directories that are configured for both test and production classes must not be added in the // resulting set testOutputDirs.removeAll(productionOutputDirs); myTestOutputDirectories = Collections.unmodifiableSet(testOutputDirs); }
public boolean validate() throws ConfigurationException { final String moduleName = getModuleName(); if (myCreateModuleCb.isSelected() || !myWizardContext.isCreatingNewProject()) { final String moduleFileDirectory = myModuleFileLocation.getText(); if (moduleFileDirectory.length() == 0) { throw new ConfigurationException("Enter module file location"); } if (moduleName.length() == 0) { throw new ConfigurationException("Enter a module name"); } if (!ProjectWizardUtil.createDirectoryIfNotExists( IdeBundle.message("directory.module.file"), moduleFileDirectory, myImlLocationChangedByUser)) { return false; } if (!ProjectWizardUtil.createDirectoryIfNotExists( IdeBundle.message("directory.module.content.root"), myModuleContentRoot.getText(), myContentRootChangedByUser)) { return false; } File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION); if (moduleFile.exists()) { int answer = Messages.showYesNoDialog( IdeBundle.message( "prompt.overwrite.project.file", moduleFile.getAbsolutePath(), IdeBundle.message("project.new.wizard.module.identification")), IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon()); if (answer != 0) { return false; } } } if (!myWizardContext.isCreatingNewProject()) { final Module module; final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(myWizardContext.getProject()); if (fromConfigurable != null) { module = fromConfigurable.getModulesConfig().getModule(moduleName); } else { module = ModuleManager.getInstance(myWizardContext.getProject()).findModuleByName(moduleName); } if (module != null) { throw new ConfigurationException( "Module \'" + moduleName + "\' already exist in project. Please, specify another name."); } } return !myWizardContext.isCreatingNewProject() || super.validate(); }
public void testParseTransformInRebarConfig() throws Exception { Project project = doTest(null); Module[] modules = ModuleManager.getInstance(project).getModules(); assertEquals(1, modules.length); ErlangFacet facet = ErlangFacet.getFacet(modules[0]); assertNotNull(facet); assertSameElements(facet.getConfiguration().getParseTransforms(), "lager_transform"); }
@Override public void clearScopesCachesForModules() { super.clearScopesCachesForModules(); Module[] modules = ModuleManager.getInstance(myProject).getModules(); for (Module module : modules) { ((ModuleEx) module).clearScopesCache(); } }
@Nullable private VirtualFile setupGradleSettingsFile( @NotNull VirtualFile modelContentRootDir, @NotNull ModifiableRootModel model) throws ConfigurationException { VirtualFile file = null; if (myWizardContext.isCreatingNewProject()) { final String moduleDirName = VfsUtilCore.getRelativePath(modelContentRootDir, model.getProject().getBaseDir(), '/'); file = getExternalProjectConfigFile( model.getProject().getBasePath(), GradleConstants.SETTINGS_FILE_NAME); if (file == null) return null; Map<String, String> attributes = ContainerUtil.newHashMap(); final String projectName = model.getProject().getName(); attributes.put(TEMPLATE_ATTRIBUTE_PROJECT_NAME, projectName); attributes.put(TEMPLATE_ATTRIBUTE_MODULE_DIR_NAME, moduleDirName); attributes.put(TEMPLATE_ATTRIBUTE_MODULE_NAME, model.getModule().getName()); saveFile(file, TEMPLATE_GRADLE_SETTINGS, attributes); } else { Map<String, Module> moduleMap = ContainerUtil.newHashMap(); for (Module module : ModuleManager.getInstance(model.getProject()).getModules()) { for (ContentEntry contentEntry : model.getContentEntries()) { if (contentEntry.getFile() != null) { moduleMap.put(contentEntry.getFile().getPath(), module); } } } VirtualFile virtualFile = modelContentRootDir; Module module = null; while (virtualFile != null && module == null) { module = moduleMap.get(virtualFile.getPath()); virtualFile = virtualFile.getParent(); } if (module != null) { String rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); if (!StringUtil.isEmpty(rootProjectPath)) { VirtualFile rootProjectFile = VfsUtil.findFileByIoFile(new File(rootProjectPath), true); if (rootProjectFile == null) return null; final String moduleDirName = VfsUtilCore.getRelativePath(modelContentRootDir, rootProjectFile, '/'); file = getExternalProjectConfigFile(rootProjectPath, GradleConstants.SETTINGS_FILE_NAME); if (file == null) return null; Map<String, String> attributes = ContainerUtil.newHashMap(); attributes.put(TEMPLATE_ATTRIBUTE_MODULE_DIR_NAME, moduleDirName); attributes.put(TEMPLATE_ATTRIBUTE_MODULE_NAME, model.getModule().getName()); appendToFile(file, TEMPLATE_GRADLE_SETTINGS_MERGE, attributes); } } } return file; }
private void createOutputDirectories() { for (Module module : ModuleManager.getInstance(myProject).getModules()) { CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module); if (extension != null) { createDirectoryIfDoesntExist(extension.getCompilerOutputUrl()); createDirectoryIfDoesntExist(extension.getCompilerOutputUrlForTests()); } } }
private void markContentRootsForRefresh() { for (Module module : ModuleManager.getInstance(myProject).getModules()) { for (VirtualFile contentRoot : ModuleRootManager.getInstance(module).getContentRoots()) { if (contentRoot instanceof NewVirtualFile) { ((NewVirtualFile) contentRoot).markDirtyRecursively(); } } } }
protected void setUpJdk() { // final ProjectJdkEx jdk = ProjectJdkUtil.getDefaultJdk("java 1.4"); final Sdk jdk = getTestProjectJdk(); // ProjectJdkImpl jdk = ProjectJdkTable.getInstance().addJdk(defaultJdk); Module[] modules = ModuleManager.getInstance(myProject).getModules(); for (Module module : modules) { ModuleRootModificationUtil.setModuleSdk(module, jdk); } }
public void testPantsIdeaPluginGoal() throws Throwable { assertEmpty(ModuleManager.getInstance(myProject).getModules()); /** Check whether Pants supports `idea-plugin` goal. */ PantsUtil.findPantsExecutable(getProjectFolder().getPath()); final GeneralCommandLine commandLinePantsGoals = PantsUtil.defaultCommandLine(getProjectFolder().getPath()); commandLinePantsGoals.addParameter("goals"); final ProcessOutput cmdOutputGoals = PantsUtil.getCmdOutput(commandLinePantsGoals.withWorkDirectory(getProjectFolder()), null); assertEquals(commandLinePantsGoals.toString() + " failed", 0, cmdOutputGoals.getExitCode()); if (!cmdOutputGoals.getStdout().contains("idea-plugin")) { return; } /** Generate idea project via `idea-plugin` goal. */ final GeneralCommandLine commandLine = PantsUtil.defaultCommandLine(getProjectFolder().getPath()); final File outputFile = FileUtil.createTempFile("project_dir_location", ".out"); commandLine.addParameters( "idea-plugin", "--no-open", "--output-file=" + outputFile.getPath(), "testprojects/tests/java/org/pantsbuild/testproject/::"); final ProcessOutput cmdOutput = PantsUtil.getCmdOutput(commandLine.withWorkDirectory(getProjectFolder()), null); assertEquals(commandLine.toString() + " failed", 0, cmdOutput.getExitCode()); String projectDir = FileUtil.loadFile(outputFile); myProject = ProjectUtil.openProject(projectDir + "/project.ipr", myProject, false); // Invoke post startup activities. UIUtil.dispatchAllInvocationEvents(); /** * Under unit test mode, {@link com.intellij.ide.impl.ProjectUtil#openProject} will force open a * project in a new window, so Project SDK has to be reset. In practice, this is not needed. */ ApplicationManager.getApplication() .runWriteAction( new Runnable() { @Override public void run() { final JavaSdk javaSdk = JavaSdk.getInstance(); ProjectRootManager.getInstance(myProject) .setProjectSdk( ProjectJdkTable.getInstance().getSdksOfType(javaSdk).iterator().next()); } }); JUnitConfiguration runConfiguration = generateJUnitConfiguration( "testprojects_tests_java_org_pantsbuild_testproject_matcher_matcher", "org.pantsbuild.testproject.matcher.MatcherTest", null); assertAndRunPantsMake(runConfiguration); assertSuccessfulJUnitTest(runConfiguration); }
@NotNull private Map<VirtualFile, OrderEntry[]> getOrderEntries() { Map<VirtualFile, OrderEntry[]> result = myOrderEntries; if (result != null) return result; MultiMap<VirtualFile, OrderEntry> libClassRootEntries = MultiMap.createSmart(); MultiMap<VirtualFile, OrderEntry> libSourceRootEntries = MultiMap.createSmart(); MultiMap<VirtualFile, OrderEntry> depEntries = MultiMap.createSmart(); for (final Module module : ModuleManager.getInstance(myProject).getModules()) { final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); for (OrderEntry orderEntry : moduleRootManager.getOrderEntries()) { if (orderEntry instanceof ModuleOrderEntry) { final Module depModule = ((ModuleOrderEntry) orderEntry).getModule(); if (depModule != null) { VirtualFile[] importedClassRoots = OrderEnumerator.orderEntries(depModule) .exportedOnly() .recursively() .classes() .usingCache() .getRoots(); for (VirtualFile importedClassRoot : importedClassRoots) { depEntries.putValue(importedClassRoot, orderEntry); } } for (VirtualFile sourceRoot : orderEntry.getFiles(OrderRootType.SOURCES)) { depEntries.putValue(sourceRoot, orderEntry); } } else if (orderEntry instanceof LibraryOrSdkOrderEntry) { final LibraryOrSdkOrderEntry entry = (LibraryOrSdkOrderEntry) orderEntry; for (final VirtualFile sourceRoot : entry.getRootFiles(OrderRootType.SOURCES)) { libSourceRootEntries.putValue(sourceRoot, orderEntry); } for (final VirtualFile classRoot : entry.getRootFiles(OrderRootType.CLASSES)) { libClassRootEntries.putValue(classRoot, orderEntry); } } } } RootInfo rootInfo = buildRootInfo(myProject); result = ContainerUtil.newHashMap(); Set<VirtualFile> allRoots = rootInfo.getAllRoots(); for (VirtualFile file : allRoots) { List<VirtualFile> hierarchy = getHierarchy(file, allRoots, rootInfo); result.put( file, hierarchy == null ? OrderEntry.EMPTY_ARRAY : calcOrderEntries( rootInfo, depEntries, libClassRootEntries, libSourceRootEntries, hierarchy)); } myOrderEntries = result; return result; }
protected void assertModules(String... expectedNames) { Module[] actual = ModuleManager.getInstance(myProject).getModules(); List<String> actualNames = new ArrayList<String>(); for (Module m : actual) { actualNames.add(m.getName()); } assertUnorderedElementsAreEqual(actualNames, expectedNames); }
protected Module getModule(final String name) { AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock(); try { Module m = ModuleManager.getInstance(myProject).findModuleByName(name); assertNotNull("Module " + name + " not found", m); return m; } finally { accessToken.finish(); } }
protected void assertModuleGroupPath(String moduleName, String... expected) { String[] path = ModuleManager.getInstance(myProject).getModuleGroupPath(getModule(moduleName)); if (expected.length == 0) { assertNull(path); } else { assertNotNull(path); assertOrderedElementsAreEqual(Arrays.asList(path), expected); } }
@Nullable private static Module getJSModule(@NotNull Project project) { Module[] modules = ModuleManager.getInstance(project).getModules(); for (Module module : modules) { if (isJsModule(module)) { return module; } } return null; }