Search in sources :

Example 6 with BallerinaApplicationConfiguration

use of org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationConfiguration 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)

Example 7 with BallerinaApplicationConfiguration

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

the class BallerinaRunConfigurationProducerTest method createRunMainPackageConfiguration.

private BallerinaApplicationConfiguration createRunMainPackageConfiguration(String filePath) {
    BallerinaApplicationRunConfigurationType type = BallerinaApplicationRunConfigurationType.getInstance();
    BallerinaApplicationConfiguration result = new BallerinaApplicationConfiguration(myFixture.getProject(), "Run Application", type);
    result.setFilePath(filePath);
    return result;
}
Also used : BallerinaApplicationRunConfigurationType(org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationType) BallerinaApplicationConfiguration(org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationConfiguration)

Example 8 with BallerinaApplicationConfiguration

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

the class BallerinaRunConfigurationProducerTest method testMainWithPackageRunConfiguration.

public void testMainWithPackageRunConfiguration() {
    PsiFile file = myFixture.addFileToProject("org/test/a.bal", "package org.test; <caret>\nfunction 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 9 with BallerinaApplicationConfiguration

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

the class BallerinaRunConfigurationProducerTest method testMainWithPackageRunConfigurationFromContext.

public void testMainWithPackageRunConfigurationFromContext() {
    PsiFile file = myFixture.addFileToProject("org/test/a.bal", "package org.test;\nfunction <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.MAIN, 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 10 with BallerinaApplicationConfiguration

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

the class BallerinaRunConfigurationProducerTest method testServiceWithoutPackageRunConfigurationFromContext.

public void testServiceWithoutPackageRunConfigurationFromContext() {
    PsiFile file = myFixture.configureByText("a.bal", "service<http> <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.SERVICE, 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)

Aggregations

BallerinaApplicationConfiguration (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationConfiguration)10 PsiElement (com.intellij.psi.PsiElement)9 PsiFile (com.intellij.psi.PsiFile)9 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)8 BallerinaApplicationRunConfigurationProducer (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer)8 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)5 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)4 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 Module (com.intellij.openapi.module.Module)1 FullyQualifiedPackageNameNode (org.ballerinalang.plugins.idea.psi.FullyQualifiedPackageNameNode)1 FunctionDefinitionNode (org.ballerinalang.plugins.idea.psi.FunctionDefinitionNode)1 PackageDeclarationNode (org.ballerinalang.plugins.idea.psi.PackageDeclarationNode)1 ServiceDefinitionNode (org.ballerinalang.plugins.idea.psi.ServiceDefinitionNode)1 BallerinaApplicationRunConfigurationType (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationType)1 BallerinaTestConfiguration (org.ballerinalang.plugins.idea.runconfig.test.BallerinaTestConfiguration)1