Search in sources :

Example 1 with RunConfigurationProducer

use of com.intellij.execution.actions.RunConfigurationProducer in project android by JetBrains.

the class AndroidStudioInitializer method disableIdeaJUnitConfigurations.

// JUnit original Extension JUnitConfigurationType is disabled so it can be replaced by its child class AndroidJUnitConfigurationType
private static void disableIdeaJUnitConfigurations() {
    // First we unregister the ConfigurationProducers, and after the ConfigurationType
    ExtensionPoint<RunConfigurationProducer> configurationProducerExtensionPoint = Extensions.getRootArea().getExtensionPoint(RunConfigurationProducer.EP_NAME);
    for (RunConfigurationProducer runConfigurationProducer : configurationProducerExtensionPoint.getExtensions()) {
        if (runConfigurationProducer instanceof JUnitConfigurationProducer && !(runConfigurationProducer instanceof AndroidJUnitConfigurationProducer)) {
            // In AndroidStudio these ConfigurationProducer s are replaced
            configurationProducerExtensionPoint.unregisterExtension(runConfigurationProducer);
        }
    }
    ExtensionPoint<ConfigurationType> configurationTypeExtensionPoint = Extensions.getRootArea().getExtensionPoint(ConfigurationType.CONFIGURATION_TYPE_EP);
    for (ConfigurationType configurationType : configurationTypeExtensionPoint.getExtensions()) {
        if (configurationType instanceof JUnitConfigurationType && !(configurationType instanceof AndroidJUnitConfigurationType)) {
            // In Android Studio the user is forced to use AndroidJUnitConfigurationType instead of JUnitConfigurationType
            configurationTypeExtensionPoint.unregisterExtension(configurationType);
        }
    }
    // We hide actions registered by the JUnit plugin and instead we use those registered in android-junit.xml
    hideAction("excludeFromSuite");
    hideAction("AddToISuite");
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) JUnitConfigurationType(com.intellij.execution.junit.JUnitConfigurationType) RunConfigurationProducer(com.intellij.execution.actions.RunConfigurationProducer) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) AndroidJUnitConfigurationProducer(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) JUnitConfigurationType(com.intellij.execution.junit.JUnitConfigurationType) JUnitConfigurationProducer(com.intellij.execution.junit.JUnitConfigurationProducer) AndroidJUnitConfigurationProducer(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer)

Example 2 with RunConfigurationProducer

use of com.intellij.execution.actions.RunConfigurationProducer in project intellij-plugins by JetBrains.

the class CfmlRunConfigurationTest method getDefaultCfmlRunConfiguration.

public CfmlRunConfiguration getDefaultCfmlRunConfiguration() throws IOException {
    final Project project = myFixture.getProject();
    final Editor editor = openCfmFileInEditor(indexCfm);
    final Presentation presentation = getPresentationForRunAction(editor);
    assert editor != null;
    final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent());
    TestCase.assertEquals("Run 'index.cfm'", presentation.getText());
    final ConfigurationContext configurationContext = ConfigurationContext.getFromContext(dataContext);
    final List<RunConfigurationProducer<?>> producers = RunConfigurationProducer.getProducers(project);
    List<ConfigurationFromContext> configs = new ArrayList<>();
    for (RunConfigurationProducer<?> producer : producers) {
        final ConfigurationFromContext configurationFromContext = producer.createConfigurationFromContext(configurationContext);
        if (configurationFromContext != null)
            configs.add(configurationFromContext);
    }
    TestCase.assertEquals(true, configs.size() == 1);
    final ConfigurationFromContext defaultConfigurationFromContext = configs.get(0);
    final RunConfiguration configuration = defaultConfigurationFromContext.getConfiguration();
    TestCase.assertNotNull(configuration);
    UsefulTestCase.assertInstanceOf(configuration, CfmlRunConfiguration.class);
    return (CfmlRunConfiguration) configuration;
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) ArrayList(java.util.ArrayList) CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration) Project(com.intellij.openapi.project.Project) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration) RunConfigurationProducer(com.intellij.execution.actions.RunConfigurationProducer) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) Editor(com.intellij.openapi.editor.Editor)

Example 3 with RunConfigurationProducer

use of com.intellij.execution.actions.RunConfigurationProducer in project intellij-plugins by JetBrains.

the class JstdAssertionFrameworkLineMarkerProvider method execute.

private static void execute(@NotNull Executor executor, @NotNull final PsiElement element) {
    Project project = element.getProject();
    Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
    if (editor == null) {
        return;
    }
    DataContext dataContext = createDataContext(editor, element);
    RunConfigurationProducer jstdOriginalProducer = getJstdRunConfigurationProducer();
    ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
    boolean created = false;
    RunnerAndConfigurationSettings configuration = jstdOriginalProducer.findExistingConfiguration(context);
    if (configuration == null) {
        created = true;
        ConfigurationFromContext fromContext = jstdOriginalProducer.createConfigurationFromContext(context);
        if (fromContext != null) {
            configuration = fromContext.getConfigurationSettings();
        } else {
            return;
        }
    }
    execute(project, executor, configuration, created);
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) DataContext(com.intellij.openapi.actionSystem.DataContext) JstdRunConfigurationProducer(com.google.jstestdriver.idea.execution.JstdRunConfigurationProducer) RunConfigurationProducer(com.intellij.execution.actions.RunConfigurationProducer) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) Editor(com.intellij.openapi.editor.Editor)

Example 4 with RunConfigurationProducer

use of com.intellij.execution.actions.RunConfigurationProducer in project intellij-community by JetBrains.

the class BaseConfigurationTestCase method createJUnitConfiguration.

protected JUnitConfiguration createJUnitConfiguration(@NotNull PsiElement psiElement, @NotNull Class<? extends AbstractJavaTestConfigurationProducer> producerClass, @NotNull MapDataContext dataContext) {
    ConfigurationContext context = createContext(psiElement, dataContext);
    RunConfigurationProducer producer = RunConfigurationProducer.getInstance(producerClass);
    assert producer != null;
    ConfigurationFromContext fromContext = producer.createConfigurationFromContext(context);
    assertNotNull(fromContext);
    return (JUnitConfiguration) fromContext.getConfiguration();
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) RunConfigurationProducer(com.intellij.execution.actions.RunConfigurationProducer) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) JUnitConfiguration(com.intellij.execution.junit.JUnitConfiguration)

Aggregations

RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)4 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)3 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)3 Editor (com.intellij.openapi.editor.Editor)2 Project (com.intellij.openapi.project.Project)2 AndroidJUnitConfigurationProducer (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer)1 AndroidJUnitConfigurationType (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType)1 JstdRunConfigurationProducer (com.google.jstestdriver.idea.execution.JstdRunConfigurationProducer)1 CfmlRunConfiguration (com.intellij.coldFusion.UI.runner.CfmlRunConfiguration)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 JUnitConfiguration (com.intellij.execution.junit.JUnitConfiguration)1 JUnitConfigurationProducer (com.intellij.execution.junit.JUnitConfigurationProducer)1 JUnitConfigurationType (com.intellij.execution.junit.JUnitConfigurationType)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ArrayList (java.util.ArrayList)1