Search in sources :

Example 1 with ModuleBasedConfiguration

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;
}
Also used : RunConfigurationBase(com.intellij.execution.configurations.RunConfigurationBase) Project(com.intellij.openapi.project.Project) BaseCoverageSuite(com.intellij.coverage.BaseCoverageSuite) Module(com.intellij.openapi.module.Module) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration)

Example 2 with ModuleBasedConfiguration

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);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) LanguageLevel(com.intellij.pom.java.LanguageLevel) Sdk(com.intellij.openapi.projectRoots.Sdk) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration) Module(com.intellij.openapi.module.Module)

Example 3 with ModuleBasedConfiguration

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());
}
Also used : CommonJavaRunConfigurationParameters(com.intellij.execution.CommonJavaRunConfigurationParameters) CoverageRunner(com.intellij.coverage.CoverageRunner) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration)

Example 4 with ModuleBasedConfiguration

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) RunProfile(com.intellij.execution.configurations.RunProfile) Module(com.intellij.openapi.module.Module) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with ModuleBasedConfiguration

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;
}
Also used : PsiPackage(com.intellij.psi.PsiPackage) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) MessageType(com.intellij.openapi.ui.MessageType) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ExecutionException(com.intellij.execution.ExecutionException) ModuleManager(com.intellij.openapi.module.ModuleManager) JavaPsiFacade(com.intellij.psi.JavaPsiFacade) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration) Balloon(com.intellij.openapi.ui.popup.Balloon) HashSet(java.util.HashSet) ToolWindowId(com.intellij.openapi.wm.ToolWindowId) Project(com.intellij.openapi.project.Project) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter) ModuleUtilCore(com.intellij.openapi.module.ModuleUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) Set(java.util.Set) Executor(com.intellij.execution.Executor) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) JavaRunConfigurationModule(com.intellij.execution.configurations.JavaRunConfigurationModule) CommonJavaRunConfigurationParameters(com.intellij.execution.CommonJavaRunConfigurationParameters) Function(com.intellij.util.Function) PsiDirectory(com.intellij.psi.PsiDirectory) Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) PsiPackage(com.intellij.psi.PsiPackage) Module(com.intellij.openapi.module.Module) JavaRunConfigurationModule(com.intellij.execution.configurations.JavaRunConfigurationModule) HashSet(java.util.HashSet)

Aggregations

ModuleBasedConfiguration (com.intellij.execution.configurations.ModuleBasedConfiguration)8 Module (com.intellij.openapi.module.Module)5 Project (com.intellij.openapi.project.Project)4 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 CommonJavaRunConfigurationParameters (com.intellij.execution.CommonJavaRunConfigurationParameters)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 AndroidVersion (com.android.sdklib.AndroidVersion)1 InstantRunGradleSupport (com.android.tools.idea.fd.gradle.InstantRunGradleSupport)1 AndroidRunConfigurationBase (com.android.tools.idea.run.AndroidRunConfigurationBase)1 AndroidSessionInfo (com.android.tools.idea.run.AndroidSessionInfo)1 BaseCoverageSuite (com.intellij.coverage.BaseCoverageSuite)1 CoverageRunner (com.intellij.coverage.CoverageRunner)1 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 JavaRunConfigurationModule (com.intellij.execution.configurations.JavaRunConfigurationModule)1 RunConfigurationBase (com.intellij.execution.configurations.RunConfigurationBase)1 RunProfile (com.intellij.execution.configurations.RunProfile)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1