Search in sources :

Example 1 with RunConfigurationBase

use of com.intellij.execution.configurations.RunConfigurationBase in project intellij-community by JetBrains.

the class CompileStepBeforeRun method doMake.

static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors, final boolean forceMakeProject) {
    if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) {
        return true;
    }
    if (configuration instanceof RunConfigurationBase && ((RunConfigurationBase) configuration).excludeCompileBeforeLaunchOption()) {
        return true;
    }
    final RunProfileWithCompileBeforeLaunchOption runConfiguration = (RunProfileWithCompileBeforeLaunchOption) configuration;
    final Ref<Boolean> result = new Ref<>(Boolean.FALSE);
    try {
        final Semaphore done = new Semaphore();
        done.down();
        final ProjectTaskNotification callback = new ProjectTaskNotification() {

            public void finished(@NotNull ProjectTaskResult executionResult) {
                if ((executionResult.getErrors() == 0 || ignoreErrors) && !executionResult.isAborted()) {
                    result.set(Boolean.TRUE);
                }
                done.up();
            }
        };
        TransactionGuard.submitTransaction(myProject, () -> {
            ProjectTask projectTask;
            Object sessionId = ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.get(env);
            final ProjectTaskManager projectTaskManager = ProjectTaskManager.getInstance(myProject);
            if (forceMakeProject) {
                // user explicitly requested whole-project make
                projectTask = projectTaskManager.createAllModulesBuildTask(true, myProject);
            } else {
                final Module[] modules = runConfiguration.getModules();
                if (modules.length > 0) {
                    for (Module module : modules) {
                        if (module == null) {
                            LOG.error("RunConfiguration should not return null modules. Configuration=" + runConfiguration.getName() + "; class=" + runConfiguration.getClass().getName());
                        }
                    }
                    projectTask = projectTaskManager.createModulesBuildTask(modules, true, true, true);
                } else {
                    projectTask = projectTaskManager.createAllModulesBuildTask(true, myProject);
                }
            }
            if (!myProject.isDisposed()) {
                projectTaskManager.run(new ProjectTaskContext(sessionId, configuration), projectTask, callback);
            } else {
                done.up();
            }
        });
        done.waitFor();
    } catch (Exception e) {
        return false;
    }
    return result.get();
}
Also used : Semaphore(com.intellij.util.concurrency.Semaphore) NotNull(org.jetbrains.annotations.NotNull) RunConfigurationBase(com.intellij.execution.configurations.RunConfigurationBase) Ref(com.intellij.openapi.util.Ref) RunProfileWithCompileBeforeLaunchOption(com.intellij.execution.configurations.RunProfileWithCompileBeforeLaunchOption) Module(com.intellij.openapi.module.Module)

Example 2 with RunConfigurationBase

use of com.intellij.execution.configurations.RunConfigurationBase in project android by JetBrains.

the class AndroidProgramRunner method doExecute.

@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    boolean showRunContent = env.getRunProfile() instanceof AndroidTestRunConfiguration;
    RunnerAndConfigurationSettings runnerAndConfigurationSettings = env.getRunnerAndConfigurationSettings();
    if (runnerAndConfigurationSettings != null) {
        runnerAndConfigurationSettings.setActivateToolWindowBeforeRun(showRunContent);
    }
    RunContentDescriptor descriptor = super.doExecute(state, env);
    if (descriptor != null) {
        ProcessHandler processHandler = descriptor.getProcessHandler();
        assert processHandler != null;
        RunProfile runProfile = env.getRunProfile();
        int uniqueId = runProfile instanceof RunConfigurationBase ? ((RunConfigurationBase) runProfile).getUniqueID() : -1;
        AndroidSessionInfo sessionInfo = new AndroidSessionInfo(processHandler, descriptor, uniqueId, env.getExecutor().getId(), InstantRunUtils.isInstantRunEnabled(env));
        processHandler.putUserData(AndroidSessionInfo.KEY, sessionInfo);
    }
    return descriptor;
}
Also used : RunConfigurationBase(com.intellij.execution.configurations.RunConfigurationBase) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) AndroidTestRunConfiguration(com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ProcessHandler(com.intellij.execution.process.ProcessHandler) RunProfile(com.intellij.execution.configurations.RunProfile)

Example 3 with RunConfigurationBase

use of com.intellij.execution.configurations.RunConfigurationBase in project intellij-community by JetBrains.

the class RunContentBuilder method createDescriptor.

@NotNull
private RunContentDescriptor createDescriptor() {
    final RunProfile profile = myEnvironment.getRunProfile();
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return new RunContentDescriptor(profile, myExecutionResult, myUi);
    }
    final ExecutionConsole console = myExecutionResult.getExecutionConsole();
    RunContentDescriptor contentDescriptor = new RunContentDescriptor(profile, myExecutionResult, myUi);
    if (console != null) {
        if (console instanceof ExecutionConsoleEx) {
            ((ExecutionConsoleEx) console).buildUi(myUi);
        } else {
            buildConsoleUiDefault(myUi, console);
        }
        initLogConsoles(profile, contentDescriptor, console);
    }
    myUi.getOptions().setLeftToolbar(createActionToolbar(contentDescriptor), ActionPlaces.RUNNER_TOOLBAR);
    if (profile instanceof RunConfigurationBase) {
        if (console instanceof ObservableConsoleView && !ApplicationManager.getApplication().isUnitTestMode()) {
            ((ObservableConsoleView) console).addChangeListener(new ConsoleToFrontListener((RunConfigurationBase) profile, myProject, myEnvironment.getExecutor(), contentDescriptor, myUi), this);
        }
    }
    return contentDescriptor;
}
Also used : RunConfigurationBase(com.intellij.execution.configurations.RunConfigurationBase) RunProfile(com.intellij.execution.configurations.RunProfile) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with RunConfigurationBase

use of com.intellij.execution.configurations.RunConfigurationBase in project intellij-plugins by JetBrains.

the class DartTestRerunnerAction method getRunProfile.

@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
    final RunConfigurationBase configuration = (RunConfigurationBase) myConsoleProperties.getConfiguration();
    final DartTestRerunner runner = new DartTestRerunner(environment, getFailedTests(configuration.getProject()));
    return new RerunProfile(configuration, runner);
}
Also used : RunConfigurationBase(com.intellij.execution.configurations.RunConfigurationBase)

Example 5 with RunConfigurationBase

use of com.intellij.execution.configurations.RunConfigurationBase 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)

Aggregations

RunConfigurationBase (com.intellij.execution.configurations.RunConfigurationBase)12 RunProfile (com.intellij.execution.configurations.RunProfile)6 ProcessHandler (com.intellij.execution.process.ProcessHandler)5 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)4 AndroidSessionInfo (com.android.tools.idea.run.AndroidSessionInfo)2 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 NotNull (org.jetbrains.annotations.NotNull)2 AndroidProject (com.android.builder.model.AndroidProject)1 Client (com.android.ddmlib.Client)1 IDevice (com.android.ddmlib.IDevice)1 NullOutputReceiver (com.android.ddmlib.NullOutputReceiver)1 ApkProjects.isApkProject (com.android.tools.idea.apk.ApkProjects.isApkProject)1 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)1 GradleSyncListener (com.android.tools.idea.gradle.project.sync.GradleSyncListener)1 GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)1 AndroidTestRunConfiguration (com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration)1 CompileStepBeforeRun (com.intellij.compiler.options.CompileStepBeforeRun)1 BaseCoverageSuite (com.intellij.coverage.BaseCoverageSuite)1 LogFilesManager (com.intellij.diagnostic.logging.LogFilesManager)1