use of com.intellij.execution.configurations.JavaRunConfigurationModule in project intellij-community by JetBrains.
the class ConfigurationModuleSelector method getConfigurationModule.
public JavaRunConfigurationModule getConfigurationModule() {
final JavaRunConfigurationModule configurationModule = new JavaRunConfigurationModule(getProject(), false);
configurationModule.setModule(getModule());
return configurationModule;
}
use of com.intellij.execution.configurations.JavaRunConfigurationModule in project intellij-community by JetBrains.
the class ResetConfigurationModuleAdapter method tryWithAnotherModule.
public static <T extends ModuleBasedConfiguration<JavaRunConfigurationModule> & CommonJavaRunConfigurationParameters> boolean tryWithAnotherModule(T configuration, boolean isDebug) {
final String packageName = configuration.getPackage();
if (packageName == null)
return false;
final Project project = configuration.getProject();
final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
if (aPackage == null)
return false;
final Module module = configuration.getConfigurationModule().getModule();
if (module == null)
return false;
final Set<Module> modulesWithPackage = new HashSet<>();
final PsiDirectory[] directories = aPackage.getDirectories();
for (PsiDirectory directory : directories) {
final Module currentModule = ModuleUtilCore.findModuleForFile(directory.getVirtualFile(), project);
if (module != currentModule && currentModule != null) {
modulesWithPackage.add(currentModule);
}
}
if (!modulesWithPackage.isEmpty()) {
final String testRunDebugId = isDebug ? ToolWindowId.DEBUG : ToolWindowId.RUN;
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
final Function<Module, String> moduleNameRef = module1 -> {
final String moduleName = module1.getName();
return "<a href=\"" + moduleName + "\">" + moduleName + "</a>";
};
String message = "Tests were not found in module \"" + module.getName() + "\".\n" + "Use ";
if (modulesWithPackage.size() == 1) {
message += "module \"" + moduleNameRef.fun(modulesWithPackage.iterator().next()) + "\" ";
} else {
message += "one of\n" + StringUtil.join(modulesWithPackage, moduleNameRef, "\n") + "\n";
}
message += "instead";
toolWindowManager.notifyByBalloon(testRunDebugId, MessageType.WARNING, message, null, new ResetConfigurationModuleAdapter(configuration, project, isDebug, toolWindowManager, testRunDebugId));
return true;
}
return false;
}
use of com.intellij.execution.configurations.JavaRunConfigurationModule in project intellij-community by JetBrains.
the class TestCategory method checkConfiguration.
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
JavaParametersUtil.checkAlternativeJRE(getConfiguration());
ProgramParametersUtil.checkWorkingDirectoryExist(getConfiguration(), getConfiguration().getProject(), getConfiguration().getConfigurationModule().getModule());
final String category = getConfiguration().getPersistentData().getCategory();
if (category == null || category.isEmpty()) {
throw new RuntimeConfigurationError("Category is not specified");
}
final JavaRunConfigurationModule configurationModule = getConfiguration().getConfigurationModule();
if (getSourceScope() == null) {
configurationModule.checkForWarning();
}
final Module module = configurationModule.getModule();
if (module != null) {
final PsiClass psiClass = JavaExecutionUtil.findMainClass(getConfiguration().getProject(), category, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module));
if (psiClass == null) {
throw new RuntimeConfigurationWarning(ExecutionBundle.message("class.not.found.in.module.error.message", category, configurationModule.getModuleName()));
}
}
}
Aggregations