private void addTestStepsForPickleSteps(List<PickleStepTestStep> testSteps, PickleEvent pickleEvent) {
for (PickleStep step : pickleEvent.pickle.getSteps()) {
PickleStepDefinitionMatch match;
try {
match = glue.stepDefinitionMatch(pickleEvent.uri, step);
if (match == null) {
List<String> snippets = new ArrayList<>();
for (Backend backend : backends) {
List<String> snippet = backend.getSnippet(step, "**KEYWORD**", runnerOptions.getSnippetType().getFunctionNameGenerator());
snippets.addAll(snippet);
}
if (!snippets.isEmpty()) {
bus.send(new SnippetsSuggestedEvent(bus.getTime(), pickleEvent.uri, step.getLocations(), snippets));
}
match = new UndefinedPickleStepDefinitionMatch(step);
}
} catch (AmbiguousStepDefinitionsException e) {
match = new AmbiguousPickleStepDefinitionsMatch(pickleEvent.uri, step, e);
} catch (Throwable t) {
match = new FailedPickleStepInstantiationMatch(pickleEvent.uri, step, t);
}
List<HookTestStep> afterStepHookSteps = getAfterStepHooks(pickleEvent.pickle.getTags());
List<HookTestStep> beforeStepHookSteps = getBeforeStepHooks(pickleEvent.pickle.getTags());
testSteps.add(new PickleStepTestStep(pickleEvent.uri, step, beforeStepHookSteps, afterStepHookSteps, match));
}
}