use of com.intellij.execution.configurations.ModuleBasedConfiguration in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoCoverageRunner method loadCoverageData.
@Override
public ProjectData loadCoverageData(@NotNull File sessionDataFile, @Nullable CoverageSuite baseCoverageSuite) {
if (!(baseCoverageSuite instanceof BaseCoverageSuite)) {
return null;
}
Project project = baseCoverageSuite.getProject();
if (project == null) {
return null;
}
RunConfigurationBase configuration = ((BaseCoverageSuite) baseCoverageSuite).getConfiguration();
Module module = configuration instanceof ModuleBasedConfiguration ? ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule() : null;
try {
BufferedReader reader = new BufferedReader(new FileReader(sessionDataFile.getAbsolutePath()));
try {
return parseCoverage(reader, project, module);
} catch (IOException e) {
LOG.warn(e);
} finally {
try {
reader.close();
} catch (IOException e) {
LOG.warn(e);
}
}
} catch (FileNotFoundException e) {
LOG.warn(e);
}
return null;
}
use of com.intellij.execution.configurations.ModuleBasedConfiguration in project intellij-community by JetBrains.
the class GroovyHotSwapper method patchJavaParameters.
@Override
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
ApplicationManager.getApplication().assertReadAccessAllowed();
if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
return;
}
if (!GroovyDebuggerSettings.getInstance().ENABLE_GROOVY_HOTSWAP) {
return;
}
if (hasSpringLoadedReloader(javaParameters)) {
return;
}
if (!(configuration instanceof RunConfiguration)) {
return;
}
final Project project = ((RunConfiguration) configuration).getProject();
if (project == null) {
return;
}
if (!LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) {
return;
}
if (configuration instanceof ModuleBasedConfiguration) {
final Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
if (module != null) {
final LanguageLevel level = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
if (level != null && !level.isAtLeast(LanguageLevel.JDK_1_5)) {
return;
}
}
}
Sdk jdk = javaParameters.getJdk();
if (jdk != null) {
String vendor = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VENDOR);
if (vendor != null && vendor.contains("IBM")) {
LOG.info("Due to IBM JDK peculiarities (IDEA-59070) we don't add Groovy agent when running applications under it");
return;
}
}
if (!project.isDefault() && containsGroovyClasses(project)) {
final String agentPath = handleSpacesInPath(getAgentJarPath());
if (agentPath != null) {
javaParameters.getVMParametersList().add("-javaagent:" + agentPath);
}
}
}
use of com.intellij.execution.configurations.ModuleBasedConfiguration in project intellij-community by JetBrains.
the class CoverageConfigurable method resetEditorFrom.
protected void resetEditorFrom(@NotNull final RunConfigurationBase runConfiguration) {
final boolean isJre50;
if (runConfiguration instanceof CommonJavaRunConfigurationParameters && myVersionDetector.isJre50Configured((CommonJavaRunConfigurationParameters) runConfiguration)) {
isJre50 = true;
} else if (runConfiguration instanceof ModuleBasedConfiguration) {
isJre50 = myVersionDetector.isModuleJre50Configured((ModuleBasedConfiguration) runConfiguration);
} else {
isJre50 = true;
}
myCoverageNotSupportedLabel.setVisible(!isJre50);
final JavaCoverageEnabledConfiguration configuration = (JavaCoverageEnabledConfiguration) CoverageEnabledConfiguration.getOrCreate(runConfiguration);
CoverageRunner runner = configuration.getCoverageRunner();
if (runner != null) {
myCoverageRunnerCb.setSelectedItem(new CoverageRunnerItem(runner));
} else {
final String runnerId = configuration.getRunnerId();
if (runnerId != null) {
final CoverageRunnerItem runnerItem = new CoverageRunnerItem(runnerId);
final DefaultComboBoxModel model = (DefaultComboBoxModel) myCoverageRunnerCb.getModel();
if (model.getIndexOf(runnerItem) == -1) {
model.addElement(runnerItem);
}
myCoverageRunnerCb.setSelectedItem(runnerItem);
} else {
myCoverageRunnerCb.setSelectedIndex(0);
}
runner = ((CoverageRunnerItem) myCoverageRunnerCb.getSelectedItem()).getRunner();
}
UIUtil.setEnabled(myRunnerPanel, isJre50, true);
myClassFilterEditor.setFilters(configuration.getCoveragePatterns());
final boolean isCoverageByTestApplicable = runner != null && runner.isCoverageByTestApplicable();
myTracingRb.setEnabled(myTracingRb.isEnabled() && isCoverageByTestApplicable);
mySamplingRb.setSelected(configuration.isSampling() || !isCoverageByTestApplicable);
myTracingRb.setSelected(!mySamplingRb.isSelected());
myTrackPerTestCoverageCb.setSelected(configuration.isTrackPerTestCoverage());
myTrackPerTestCoverageCb.setEnabled(myTracingRb.isEnabled() && myTracingRb.isSelected() && canHavePerTestCoverage());
myTrackTestSourcesCb.setSelected(configuration.isTrackTestFolders());
}
use of com.intellij.execution.configurations.ModuleBasedConfiguration in project go-lang-idea-plugin by go-lang-plugin-org.
the class DlvStackFrame method findFile.
@Nullable
private VirtualFile findFile() {
String url = myLocation.file;
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(url);
if (file == null && SystemInfo.isWindows) {
Project project = myProcess.getSession().getProject();
RunProfile profile = myProcess.getSession().getRunProfile();
Module module = profile instanceof ModuleBasedConfiguration ? ((ModuleBasedConfiguration) profile).getConfigurationModule().getModule() : null;
String sdkHomePath = GoSdkService.getInstance(project).getSdkHomePath(module);
if (sdkHomePath == null)
return null;
String newUrl = StringUtil.replaceIgnoreCase(url, "c:/go", sdkHomePath);
return LocalFileSystem.getInstance().findFileByPath(newUrl);
}
return file;
}
use of com.intellij.execution.configurations.ModuleBasedConfiguration 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;
}
Aggregations