use of com.intellij.execution.actions.ConfigurationFromContext in project ballerina by ballerina-lang.
the class BallerinaRunConfigurationProducerTest method testMainWithoutPackageRunConfigurationFromContext.
public void testMainWithoutPackageRunConfigurationFromContext() {
PsiFile file = myFixture.configureByText("a.bal", "function <caret>main() {}");
PsiElement element = file.findElementAt(myFixture.getCaretOffset());
assertNotNull(element);
ConfigurationContext configurationContext = new ConfigurationContext(element);
BallerinaApplicationRunConfigurationProducer producer = new BallerinaApplicationRunConfigurationProducer();
ConfigurationFromContext configurationFromContext = producer.createConfigurationFromContext(configurationContext);
assertNotNull(configurationFromContext);
RunConfiguration runConfiguration = configurationFromContext.getConfiguration();
assertTrue(runConfiguration instanceof BallerinaApplicationConfiguration);
BallerinaApplicationConfiguration ballerinaApplicationConfiguration = (BallerinaApplicationConfiguration) runConfiguration;
assertEquals(RunConfigurationKind.MAIN, ballerinaApplicationConfiguration.getRunKind());
assertEquals(file.getVirtualFile().getPath(), ballerinaApplicationConfiguration.getFilePath());
assertEmpty(ballerinaApplicationConfiguration.getPackage());
}
use of com.intellij.execution.actions.ConfigurationFromContext in project Perl5-IDEA by Camelcade.
the class PerlPlatformTestCase method getRunConfigurationsFromFileContext.
@NotNull
protected List<ConfigurationFromContext> getRunConfigurationsFromFileContext(@NotNull String relativePath) {
VirtualFile virtualFile = getModuleFile(relativePath);
PsiElement psiElement = getPsiElement(virtualFile);
ConfigurationContext configurationContext = ConfigurationContext.getFromContext(createDataContext(it -> LangDataKeys.PSI_ELEMENT_ARRAY.is(it) ? new PsiElement[] { psiElement } : null));
List<ConfigurationFromContext> configurationsFromContext = configurationContext.getConfigurationsFromContext();
assertNotNull(configurationsFromContext);
return configurationsFromContext;
}
use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.
the class AllInDirectoryRecursiveTestContextProviderTest method testProducedFromFile.
@Test
public void testProducedFromFile() {
setProjectView("directories:", " java/com/google/test", "targets:", " //java/com/google/test:lib");
PsiFile file = workspace.createPsiFile(new WorkspacePath("java/com/google/test/i_am_a_normal_file"), "I am just a normal file!");
List<ConfigurationFromContext> configurations = createContextFromPsi(file).getConfigurationsFromContext();
assertThat(configurations).isNull();
}
use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.
the class AllInBuildFileTestContextProviderTest method testProducedFromNonBuildFile.
@Test
public void testProducedFromNonBuildFile() {
setProjectView("directories:", " java/com/google/test", "targets:", " //java/com/google/test:lib");
PsiFile nonBuildFile = workspace.createPsiFile(new WorkspacePath("java/com/google/test/i_am_not_a_build_file"), "I am not a build file!");
List<ConfigurationFromContext> configurations = createContextFromPsi(nonBuildFile).getConfigurationsFromContext();
assertThat(configurations).isNull();
}
use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.
the class BlazeBuildFileRunConfigurationProducerTest method testTestSuiteMacroNameRecognized.
@Test
public void testTestSuiteMacroNameRecognized() {
PsiFile buildFile = workspace.createPsiFile(new WorkspacePath("java/com/google/test/BUILD"), "random_junit4_test_suites(name='gen_tests'");
FuncallExpression target = PsiUtils.findFirstChildOfClassRecursive(buildFile, FuncallExpression.class);
ConfigurationContext context = createContextFromPsi(target);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeBuildFileRunConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTargets()).containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:gen_tests"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
Aggregations