Search in sources :

Example 11 with ConfigurationFromContext

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());
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) BallerinaApplicationRunConfigurationProducer(org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) BallerinaApplicationConfiguration(org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationConfiguration)

Example 12 with ConfigurationFromContext

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) CpanminusAdapter(com.perl5.lang.perl.adapters.CpanminusAdapter) UIUtil(com.intellij.util.ui.UIUtil) Arrays(java.util.Arrays) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) com.intellij.testFramework(com.intellij.testFramework) PerlPackageUtil(com.perl5.lang.perl.util.PerlPackageUtil) VirtualFile(com.intellij.openapi.vfs.VirtualFile) TestTreeView(com.intellij.execution.testframework.TestTreeView) BiFunction(java.util.function.BiFunction) com.intellij.execution.process(com.intellij.execution.process) PsiManager(com.intellij.psi.PsiManager) BooleanSupplier(java.util.function.BooleanSupplier) GenericPerlRunConfiguration(com.perl5.lang.perl.idea.run.GenericPerlRunConfiguration) Promise(org.jetbrains.concurrency.Promise) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Semaphore(com.intellij.util.concurrency.Semaphore) Disposer(com.intellij.openapi.util.Disposer) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) PerlHostData(com.perl5.lang.perl.idea.sdk.host.PerlHostData) Notifications(com.intellij.notification.Notifications) NonBlockingReadActionImpl(com.intellij.openapi.application.impl.NonBlockingReadActionImpl) Description(org.junit.runner.Description) FileEditor(com.intellij.openapi.fileEditor.FileEditor) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) Objects(java.util.Objects) Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) PsiUtilCore(com.intellij.psi.util.PsiUtilCore) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ApplicationManager(com.intellij.openapi.application.ApplicationManager) LangDataKeys(com.intellij.openapi.actionSystem.LangDataKeys) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) PerlTestRunConfiguration(com.perl5.lang.perl.idea.run.prove.PerlTestRunConfiguration) SMTestRunnerResultsForm(com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm) PerlProjectManager(com.perl5.lang.perl.idea.project.PerlProjectManager) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) DataContext(com.intellij.openapi.actionSystem.DataContext) RunWith(org.junit.runner.RunWith) Function(java.util.function.Function) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) PerlSMTRunnerConsoleView(com.perl5.lang.perl.idea.run.prove.PerlSMTRunnerConsoleView) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy) PerlRunUtil(com.perl5.lang.perl.util.PerlRunUtil) Assume(org.junit.Assume) PerlSdkTable(com.intellij.openapi.projectRoots.impl.PerlSdkTable) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) ProgramRunner(com.intellij.execution.runners.ProgramRunner) TreeUtil(com.intellij.util.ui.tree.TreeUtil) CodeInsightTestFixtureImpl(com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl) StringUtil(com.intellij.openapi.util.text.StringUtil) Key(com.intellij.openapi.util.Key) AnAction(com.intellij.openapi.actionSystem.AnAction) IOException(java.io.IOException) Disposable(com.intellij.openapi.Disposable) Sdk(com.intellij.openapi.projectRoots.Sdk) File(java.io.File) com.intellij.execution(com.intellij.execution) TimeUnit(java.util.concurrent.TimeUnit) CpanAdapter(com.perl5.lang.perl.adapters.CpanAdapter) ModuleRootModificationUtil(com.intellij.openapi.roots.ModuleRootModificationUtil) Pair(com.pty4j.util.Pair) Collections(java.util.Collections) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with ConfigurationFromContext

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();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) Test(org.junit.Test)

Example 14 with ConfigurationFromContext

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();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) Test(org.junit.Test)

Example 15 with ConfigurationFromContext

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);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) FuncallExpression(com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Aggregations

ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)76 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)69 Test (org.junit.Test)61 PsiFile (com.intellij.psi.PsiFile)56 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)54 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)50 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)38 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)38 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)13 PsiClass (com.intellij.psi.PsiClass)13 PsiDirectory (com.intellij.psi.PsiDirectory)10 PyFunction (com.jetbrains.python.psi.PyFunction)8 PsiElement (com.intellij.psi.PsiElement)6 TestContextRunConfigurationProducer (com.google.idea.blaze.base.run.producers.TestContextRunConfigurationProducer)4 DataContext (com.intellij.openapi.actionSystem.DataContext)4 Project (com.intellij.openapi.project.Project)4 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)3 RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)3 BallerinaApplicationConfiguration (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationConfiguration)3 BallerinaApplicationRunConfigurationProducer (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer)3