Search in sources :

Example 1 with BallerinaApplicationRunConfigurationProducer

use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.

the class BallerinaRunConfigurationProducerTest method testMainWithoutPackageRunConfiguration.

public void testMainWithoutPackageRunConfiguration() {
    PsiFile file = myFixture.configureByText("a.bal", "<caret>\nfunction main() {}");
    PsiElement element = file.findElementAt(myFixture.getCaretOffset());
    assertNotNull(element);
    ConfigurationContext configurationContext = new ConfigurationContext(element);
    BallerinaApplicationRunConfigurationProducer producer = new BallerinaApplicationRunConfigurationProducer();
    BallerinaApplicationConfiguration runConfiguration = createRunMainPackageConfiguration(file.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createRunMainPackageConfiguration(file.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) 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 2 with BallerinaApplicationRunConfigurationProducer

use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer 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 3 with BallerinaApplicationRunConfigurationProducer

use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.

the class BallerinaRunConfigurationProducerTest method testServiceWithPackageRunConfiguration.

public void testServiceWithPackageRunConfiguration() {
    PsiFile file = myFixture.addFileToProject("org/test/a.bal", "package org.test; <caret>\nservice<http> main {}");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    PsiElement element = file.findElementAt(myFixture.getCaretOffset());
    assertNotNull(element);
    ConfigurationContext configurationContext = new ConfigurationContext(element);
    BallerinaApplicationRunConfigurationProducer producer = new BallerinaApplicationRunConfigurationProducer();
    BallerinaApplicationConfiguration runConfiguration = createRunMainPackageConfiguration(file.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createRunMainPackageConfiguration(file.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) 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 4 with BallerinaApplicationRunConfigurationProducer

use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.

the class BallerinaRunConfigurationProducerTest method testServiceWithPackageRunConfigurationFromContext.

public void testServiceWithPackageRunConfigurationFromContext() {
    PsiFile file = myFixture.addFileToProject("org/test/a.bal", "package org.test;\nservice<http> <caret>main {}");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    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.SERVICE, ballerinaApplicationConfiguration.getRunKind());
    assertEquals(file.getVirtualFile().getPath(), ballerinaApplicationConfiguration.getFilePath());
    assertEquals("org/test", 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 5 with BallerinaApplicationRunConfigurationProducer

use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer in project ballerina by ballerina-lang.

the class BallerinaRunConfigurationProducerTest method testServiceWithoutPackageRunConfiguration.

public void testServiceWithoutPackageRunConfiguration() {
    PsiFile file = myFixture.configureByText("a.bal", "<caret>\nservice<http> main {}");
    PsiElement element = file.findElementAt(myFixture.getCaretOffset());
    assertNotNull(element);
    ConfigurationContext configurationContext = new ConfigurationContext(element);
    BallerinaApplicationRunConfigurationProducer producer = new BallerinaApplicationRunConfigurationProducer();
    BallerinaApplicationConfiguration runConfiguration = createRunMainPackageConfiguration(file.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createRunMainPackageConfiguration(file.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) 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)

Aggregations

ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)8 PsiElement (com.intellij.psi.PsiElement)8 PsiFile (com.intellij.psi.PsiFile)8 BallerinaApplicationConfiguration (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationConfiguration)8 BallerinaApplicationRunConfigurationProducer (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer)8 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)4 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)4