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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations