use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class ConfigFilesTreeBuilder method buildModuleNodes.
public Set<PsiFile> buildModuleNodes(final MultiMap<Module, PsiFile> files, final MultiMap<VirtualFile, PsiFile> jars, DefaultMutableTreeNode root) {
final HashSet<PsiFile> psiFiles = new HashSet<>();
final List<Module> modules = new ArrayList<>(files.keySet());
Collections.sort(modules, ModulesAlphaComparator.INSTANCE);
for (Module module : modules) {
DefaultMutableTreeNode moduleNode = createFileNode(module);
root.add(moduleNode);
if (files.containsKey(module)) {
List<PsiFile> moduleFiles = new ArrayList<>(files.get(module));
MultiMap<FileType, PsiFile> filesByType = new MultiMap<>();
for (PsiFile file : moduleFiles) {
filesByType.putValue(file.getFileType(), file);
}
if (hasNonEmptyGroups(filesByType)) {
for (Map.Entry<FileType, Collection<PsiFile>> entry : filesByType.entrySet()) {
DefaultMutableTreeNode fileTypeNode = createFileNode(entry.getKey());
moduleNode.add(fileTypeNode);
addChildrenFiles(psiFiles, fileTypeNode, new ArrayList<>(entry.getValue()));
}
} else {
addChildrenFiles(psiFiles, moduleNode, moduleFiles);
}
}
}
List<VirtualFile> sortedJars = new ArrayList<>(jars.keySet());
Collections.sort(sortedJars, (o1, o2) -> StringUtil.naturalCompare(o1.getName(), o2.getName()));
for (VirtualFile file : sortedJars) {
if (!file.isValid())
continue;
final List<PsiFile> list = new ArrayList<>(jars.get(file));
final PsiFile jar = list.get(0).getManager().findFile(file);
if (jar != null) {
final DefaultMutableTreeNode jarNode = createFileNode(jar);
root.add(jarNode);
Collections.sort(list, FILE_COMPARATOR);
for (PsiFile psiFile : list) {
jarNode.add(createFileNode(psiFile));
psiFiles.add(psiFile);
}
}
}
return psiFiles;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class DefaultGroovyScriptRunner method ensureRunnerConfigured.
@Override
public void ensureRunnerConfigured(@NotNull GroovyScriptRunConfiguration configuration) throws RuntimeConfigurationException {
Module module = configuration.getModule();
if (module == null) {
throw new RuntimeConfigurationException("Module is not specified");
}
if (LibrariesUtil.getGroovyHomePath(module) == null) {
RuntimeConfigurationException e = new RuntimeConfigurationException("Groovy is not configured for module '" + module.getName() + "'");
e.setQuickFix(() -> ModulesConfigurator.showDialog(module.getProject(), module.getName(), ClasspathEditor.NAME));
throw e;
}
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class GroovyScriptRunConfiguration method getValidModules.
@Override
public Collection<Module> getValidModules() {
Module[] modules = ModuleManager.getInstance(getProject()).getModules();
final GroovyScriptRunner scriptRunner = getScriptRunner();
if (scriptRunner == null) {
return Arrays.asList(modules);
}
ArrayList<Module> res = new ArrayList<>();
for (Module module : modules) {
if (scriptRunner.isValidModule(module)) {
res.add(module);
}
}
return res;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class TestPackage method createSearchingForTestsTask.
@Override
public SearchForTestsTask createSearchingForTestsTask() {
final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
return new SearchForTestsTask(getConfiguration().getProject(), myServerSocket) {
private final THashSet<PsiClass> myClasses = new THashSet<>();
@Override
protected void search() {
myClasses.clear();
final SourceScope sourceScope = getSourceScope();
final Module module = getConfiguration().getConfigurationModule().getModule();
if (sourceScope != null && !ReadAction.compute(() -> isJUnit5(module, sourceScope, myProject))) {
try {
final TestClassFilter classFilter = getClassFilter(data);
LOG.assertTrue(classFilter.getBase() != null);
ConfigurationUtil.findAllTestClasses(classFilter, module, myClasses);
} catch (CantRunException ignored) {
}
}
}
@Override
protected void onFound() {
try {
addClassesListToJavaParameters(myClasses, psiClass -> psiClass != null ? JavaExecutionUtil.getRuntimeQualifiedName(psiClass) : null, getPackageName(data), createTempFiles(), getJavaParameters());
} catch (ExecutionException ignored) {
}
}
};
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class JUnitConfiguration method bePatternConfiguration.
public void bePatternConfiguration(List<PsiClass> classes, PsiMethod method) {
myData.TEST_OBJECT = TEST_PATTERN;
final LinkedHashSet<String> patterns = new LinkedHashSet<>();
final String methodSufiix;
if (method != null) {
myData.METHOD_NAME = Data.getMethodPresentation(method);
methodSufiix = "," + myData.METHOD_NAME;
} else {
methodSufiix = "";
}
for (PsiClass pattern : classes) {
patterns.add(JavaExecutionUtil.getRuntimeQualifiedName(pattern) + methodSufiix);
}
myData.setPatterns(patterns);
final Module module = RunConfigurationProducer.getInstance(PatternConfigurationProducer.class).findModule(this, getConfigurationModule().getModule(), patterns);
if (module == null) {
myData.setScope(TestSearchScope.WHOLE_PROJECT);
setModule(null);
} else {
setModule(module);
}
setGeneratedName();
}
Aggregations