Search in sources :

Example 1 with GroovySnippet

use of cucumber.runtime.groovy.GroovySnippet in project intellij-plugins by JetBrains.

the class GrStepDefinitionCreator method buildStepDefinitionByStep.

private static GrMethodCall buildStepDefinitionByStep(@NotNull final GherkinStep step) {
    final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(step.getProject());
    final Step cucumberStep = new Step(Collections.emptyList(), step.getKeyword().getText(), step.getStepName(), 0, null, null);
    SnippetGenerator generator = new SnippetGenerator(new GroovySnippet());
    final String fqnPendingException;
    if (GrCucumberUtil.isCucumber_1_1_orAbove(step)) {
        fqnPendingException = "cucumber.api.PendingException";
    } else {
        fqnPendingException = "cucumber.runtime.PendingException";
    }
    String snippet = generator.getSnippet(cucumberStep, null).replace("PendingException", fqnPendingException);
    return (GrMethodCall) factory.createStatementFromText(snippet, step);
}
Also used : GroovyPsiElementFactory(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory) GrMethodCall(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall) SnippetGenerator(cucumber.runtime.snippets.SnippetGenerator) Step(gherkin.formatter.model.Step) GherkinStep(org.jetbrains.plugins.cucumber.psi.GherkinStep) GroovySnippet(cucumber.runtime.groovy.GroovySnippet)

Aggregations

GroovySnippet (cucumber.runtime.groovy.GroovySnippet)1 SnippetGenerator (cucumber.runtime.snippets.SnippetGenerator)1 Step (gherkin.formatter.model.Step)1 GherkinStep (org.jetbrains.plugins.cucumber.psi.GherkinStep)1 GroovyPsiElementFactory (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory)1 GrMethodCall (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall)1