Search in sources :

Example 1 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoRunConfigurationTestCase method doTestProducedConfigurations.

protected void doTestProducedConfigurations(@Nullable PsiElement context) {
    assertNotNull(context);
    ConfigurationContext configurationContext = new ConfigurationContext(context);
    List<ConfigurationFromContext> configurationAndSettings = configurationContext.getConfigurationsFromContext();
    Element configurationsElement = new Element("configurations");
    if (configurationAndSettings != null) {
        for (ConfigurationFromContext setting : configurationAndSettings) {
            try {
                RunConfiguration configuration = setting.getConfiguration();
                Element configurationElement = new Element("configurations");
                configurationElement.setAttribute("name", configuration.getName());
                configurationElement.setAttribute("class", configuration.getClass().getSimpleName());
                configuration.writeExternal(configurationElement);
                configurationsElement.addContent(configurationElement);
            } catch (WriteExternalException e) {
                throw new RuntimeException(e);
            }
        }
    }
    assertSameLinesWithFile(getTestDataPath() + "/" + getTestName(true) + ".xml", JDOMUtil.writeElement(configurationsElement));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiElement(com.intellij.psi.PsiElement) Element(org.jdom.Element) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Example 2 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoTestRunConfigurationProducerTest method testSameConfigurationOnDirectory.

public void testSameConfigurationOnDirectory() {
    PsiFile file = myFixture.configureByText("a.go", "package main");
    PsiDirectory directory = file.getParent();
    assertNotNull(directory);
    ConfigurationContext configurationContext = new ConfigurationContext(directory);
    GotestRunConfigurationProducer producer = new GotestRunConfigurationProducer();
    GoTestRunConfiguration runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath() + "_vl", directory.getVirtualFile().getPath());
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createDirectoryConfiguration(GobenchFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath());
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PsiDirectory(com.intellij.psi.PsiDirectory) PsiFile(com.intellij.psi.PsiFile) GotestRunConfigurationProducer(com.goide.runconfig.testing.frameworks.gotest.GotestRunConfigurationProducer)

Example 3 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoRunConfigurationProducerTest method testSameRunApplicationConfigurationOnPackage.

public void testSameRunApplicationConfigurationOnPackage() {
    PsiFile file = myFixture.configureByText("a.go", "package main; <caret>\nfunc main() {}");
    PsiElement at = file.findElementAt(myFixture.getCaretOffset());
    assertNotNull(at);
    ConfigurationContext configurationContext = new ConfigurationContext(at);
    GoApplicationRunConfigurationProducer producer = new GoApplicationRunConfigurationProducer();
    GoApplicationConfiguration runConfiguration = createRunAppFileConfiguration(file.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createRunAppFileConfiguration(file.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) GoApplicationRunConfigurationProducer(com.goide.runconfig.application.GoApplicationRunConfigurationProducer) PsiFile(com.intellij.psi.PsiFile) GoApplicationConfiguration(com.goide.runconfig.application.GoApplicationConfiguration) PsiElement(com.intellij.psi.PsiElement)

Example 4 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoRunConfigurationProducerTest method testSameRunApplicationConfigurationOnDirectory.

public void testSameRunApplicationConfigurationOnDirectory() {
    PsiFile file = myFixture.addFileToProject("import/path/a.go", "package main; func main(){}");
    PsiDirectory directory = file.getParent();
    assertNotNull(directory);
    ConfigurationContext configurationContext = new ConfigurationContext(directory);
    GoApplicationRunConfigurationProducer producer = new GoApplicationRunConfigurationProducer();
    GoApplicationConfiguration runConfiguration = createRunAppPackageConfiguration("import/path");
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createRunAppPackageConfiguration("import/path/other");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) GoApplicationRunConfigurationProducer(com.goide.runconfig.application.GoApplicationRunConfigurationProducer) PsiDirectory(com.intellij.psi.PsiDirectory) PsiFile(com.intellij.psi.PsiFile) GoApplicationConfiguration(com.goide.runconfig.application.GoApplicationConfiguration)

Example 5 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoRunConfigurationProducerTest method testSameRunApplicationConfigurationOnFile.

public void testSameRunApplicationConfigurationOnFile() {
    PsiFile file = myFixture.configureByText("a.go", "package main; <caret>\nfunc main() {}");
    PsiElement at = file.findElementAt(myFixture.getCaretOffset());
    assertNotNull(at);
    ConfigurationContext configurationContext = new ConfigurationContext(at);
    GoRunFileConfigurationProducer producer = new GoRunFileConfigurationProducer();
    GoRunFileConfiguration runConfiguration = createFileConfiguration(file.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createFileConfiguration(file.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) GoRunFileConfigurationProducer(com.goide.runconfig.file.GoRunFileConfigurationProducer) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) GoRunFileConfiguration(com.goide.runconfig.file.GoRunFileConfiguration)

Aggregations

ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)26 PsiFile (com.intellij.psi.PsiFile)9 PsiElement (com.intellij.psi.PsiElement)7 GotestRunConfigurationProducer (com.goide.runconfig.testing.frameworks.gotest.GotestRunConfigurationProducer)5 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)5 InheritorChooser (com.intellij.execution.junit.InheritorChooser)5 List (java.util.List)5 RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)4 Project (com.intellij.openapi.project.Project)4 Location (com.intellij.execution.Location)3 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 MethodLocation (com.intellij.execution.junit2.info.MethodLocation)3 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)3 PsiClass (com.intellij.psi.PsiClass)3 PsiMethod (com.intellij.psi.PsiMethod)3 GoApplicationConfiguration (com.goide.runconfig.application.GoApplicationConfiguration)2 GoApplicationRunConfigurationProducer (com.goide.runconfig.application.GoApplicationRunConfigurationProducer)2 GoRunFileConfiguration (com.goide.runconfig.file.GoRunFileConfiguration)2 GoRunFileConfigurationProducer (com.goide.runconfig.file.GoRunFileConfigurationProducer)2