Search in sources :

Example 51 with RunConfiguration

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

the class FlashRunConfigurationProducer method findSuitableRunConfig.

@Nullable
private static RunConfiguration findSuitableRunConfig(final Module module, final String fqn, final List<RunConfiguration> existing) {
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
    RunConfiguration basedOnBC = null;
    RunConfiguration basedOnMainClass = null;
    RunConfiguration basedOnMainClassAndActiveBC = null;
    for (final RunConfiguration runConfig : existing) {
        final FlashRunnerParameters params = ((FlashRunConfiguration) runConfig).getRunnerParameters();
        if (module.getName().equals(params.getModuleName())) {
            final FlexBuildConfiguration bc = manager.findConfigurationByName(params.getBCName());
            if (bc == null)
                continue;
            if (params.isOverrideMainClass()) {
                if (fqn.equals(params.getOverriddenMainClass())) {
                    if (manager.getActiveConfiguration() == bc) {
                        basedOnMainClassAndActiveBC = runConfig;
                    }
                    basedOnMainClass = runConfig;
                }
            } else {
                if (bc.getOutputType() == OutputType.Application && fqn.equals(bc.getMainClass())) {
                    if (manager.getActiveConfiguration() == bc) {
                        // the best choice
                        return runConfig;
                    }
                    basedOnBC = runConfig;
                }
            }
        }
    }
    // forth - based on overridden main class and any bc
    return basedOnBC != null ? basedOnBC : basedOnMainClassAndActiveBC != null ? basedOnMainClassAndActiveBC : basedOnMainClass;
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Example 52 with RunConfiguration

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

the class FlashRunConfigurationProducer method isConfigurationFromContext.

public boolean isConfigurationFromContext(final FlashRunConfiguration configuration, final ConfigurationContext context) {
    final Module module = context.getModule();
    if (module == null || ModuleType.get(module) != FlexModuleType.getInstance())
        return false;
    if (!module.getName().equals(configuration.getRunnerParameters().getModuleName()))
        return false;
    final JSClass jsClass = getJSClass(context.getPsiLocation());
    if (jsClass == null || !isAcceptedMainClass(jsClass, module))
        return false;
    final List<RunConfiguration> existing = RunManager.getInstance(module.getProject()).getConfigurationsList(getConfigurationType());
    final RunConfiguration suitable = findSuitableRunConfig(module, jsClass.getQualifiedName(), existing);
    return suitable == configuration;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) Module(com.intellij.openapi.module.Module) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 53 with RunConfiguration

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

the class FlexModuleBuilder method createRunConfiguration.

public static void createRunConfiguration(final Module module, final FlexBuildConfiguration bc) {
    final RunManager runManager = RunManagerEx.getInstance(module.getProject());
    final List<RunConfiguration> existingConfigurations = runManager.getConfigurationsList(FlashRunConfigurationType.getInstance());
    for (RunConfiguration configuration : existingConfigurations) {
        final FlashRunnerParameters parameters = ((FlashRunConfiguration) configuration).getRunnerParameters();
        if (module.getName().equals(parameters.getModuleName()) && bc.getName().equals(parameters.getBCName())) {
            //already exists
            return;
        }
    }
    final RunnerAndConfigurationSettings settings = runManager.createConfiguration("", FlashRunConfigurationType.getFactory());
    final FlashRunConfiguration runConfiguration = (FlashRunConfiguration) settings.getConfiguration();
    final FlashRunnerParameters params = runConfiguration.getRunnerParameters();
    params.setModuleName(module.getName());
    params.setBCName(bc.getName());
    if (bc.getNature().isMobilePlatform()) {
        if (bc.getAndroidPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.Android);
        } else if (bc.getIosPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.IOS);
        }
    }
    settings.setName(params.suggestUniqueName(existingConfigurations));
    settings.setTemporary(false);
    runManager.addConfiguration(settings, false);
    runManager.setSelectedConfiguration(settings);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManager(com.intellij.execution.RunManager) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 54 with RunConfiguration

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

the class PostSyncProjectSetupTest method testJUnitRunConfigurationSetup.

public void testJUnitRunConfigurationSetup() {
    when(myIdeInfo.isAndroidStudio()).thenReturn(true);
    PostSyncProjectSetup.Request request = new PostSyncProjectSetup.Request();
    mySetup.setUpProject(request, myProgressIndicator);
    ConfigurationFactory configurationFactory = AndroidJUnitConfigurationType.getInstance().getConfigurationFactories()[0];
    AndroidJUnitConfiguration jUnitConfiguration = new AndroidJUnitConfiguration("", getProject(), configurationFactory);
    myRunManager.addConfiguration(myRunManager.createConfiguration(jUnitConfiguration, configurationFactory), true);
    List<RunConfiguration> junitRunConfigurations = myRunManager.getConfigurationsList(AndroidJUnitConfigurationType.getInstance());
    for (RunConfiguration runConfiguration : junitRunConfigurations) {
        assertSize(1, myRunManager.getBeforeRunTasks(runConfiguration));
        assertEquals(MakeBeforeRunTaskProvider.ID, myRunManager.getBeforeRunTasks(runConfiguration).get(0).getProviderId());
    }
    RunConfiguration runConfiguration = junitRunConfigurations.get(0);
    List<BeforeRunTask> tasks = new LinkedList<>(myRunManager.getBeforeRunTasks(runConfiguration));
    BeforeRunTask newTask = new MakeBeforeRunTaskProvider(getProject()).createTask(runConfiguration);
    newTask.setEnabled(true);
    tasks.add(newTask);
    myRunManager.setBeforeRunTasks(runConfiguration, tasks, false);
    mySetup.setUpProject(request, myProgressIndicator);
    assertSize(2, myRunManager.getBeforeRunTasks(runConfiguration));
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) MakeBeforeRunTaskProvider(com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) AndroidJUnitConfiguration(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration) LinkedList(java.util.LinkedList)

Example 55 with RunConfiguration

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

the class JstdRunConfigurationProducer method setupConfigurationFromContext.

@Override
protected boolean setupConfigurationFromContext(JstdRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
    Project project = configuration.getProject();
    if (!JstdSettingsUtil.areJstdConfigFilesInProjectCached(project)) {
        return false;
    }
    RunConfiguration original = context.getOriginalConfiguration(null);
    if (original != null && !ConfigurationTypeUtil.equals(original.getType(), JstdConfigurationType.getInstance())) {
        return false;
    }
    long startTimeNano = System.nanoTime();
    @SuppressWarnings({ "unchecked" }) JstdRunSettings settings = buildRunSettingsContext(context.getLocation());
    if (settings == null) {
        logDoneCreateConfigurationByElement(startTimeNano, "1");
        return false;
    }
    if (settings.getConfigFile().isEmpty()) {
        JstdRunSettings clonedSettings = configuration.getRunSettings();
        JstdRunSettings.Builder builder = new JstdRunSettings.Builder(settings);
        builder.setConfigFile(clonedSettings.getConfigFile());
        settings = builder.build();
    }
    configuration.setRunSettings(settings);
    String configurationName = configuration.resetGeneratedName();
    configuration.setName(configurationName);
    logDoneCreateConfigurationByElement(startTimeNano, "3");
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) JstdRunSettings(com.google.jstestdriver.idea.execution.settings.JstdRunSettings)

Aggregations

RunConfiguration (com.intellij.execution.configurations.RunConfiguration)59 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)16 Module (com.intellij.openapi.module.Module)13 Nullable (org.jetbrains.annotations.Nullable)12 Project (com.intellij.openapi.project.Project)10 PsiElement (com.intellij.psi.PsiElement)7 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)6 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)6 Pair (com.intellij.openapi.util.Pair)6 NotNull (org.jetbrains.annotations.NotNull)6 AndroidTestRunConfiguration (com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration)5 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 BeforeRunTask (com.intellij.execution.BeforeRunTask)4 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrayList (java.util.ArrayList)4 AndroidJUnitConfiguration (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration)3 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)3 Location (com.intellij.execution.Location)3 RunManager (com.intellij.execution.RunManager)3