Search in sources :

Example 1 with FeatureChild

use of io.cucumber.messages.types.FeatureChild in project cucumber-jvm by cucumber.

the class TestSourcesModel method parseGherkinSource.

private void parseGherkinSource(URI path) {
    if (!pathToReadEventMap.containsKey(path)) {
        return;
    }
    String source = pathToReadEventMap.get(path).getSource();
    List<Envelope> sources = singletonList(makeSourceEnvelope(source, path.toString()));
    List<Envelope> envelopes = Gherkin.fromSources(sources, true, true, true, () -> String.valueOf(UUID.randomUUID())).collect(toList());
    GherkinDocument gherkinDocument = envelopes.stream().map(Envelope::getGherkinDocument).filter(Objects::nonNull).findFirst().orElse(null);
    pathToAstMap.put(path, gherkinDocument);
    Map<Long, AstNode> nodeMap = new HashMap<>();
    AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null);
    for (FeatureChild child : gherkinDocument.getFeature().getChildren()) {
        processFeatureDefinition(nodeMap, child, currentParent);
    }
    pathToNodeMap.put(path, nodeMap);
}
Also used : HashMap(java.util.HashMap) Objects(java.util.Objects) FeatureChild(io.cucumber.messages.types.FeatureChild) GherkinDocument(io.cucumber.messages.types.GherkinDocument) Envelope(io.cucumber.messages.types.Envelope) Gherkin.makeSourceEnvelope(io.cucumber.gherkin.Gherkin.makeSourceEnvelope)

Aggregations

Gherkin.makeSourceEnvelope (io.cucumber.gherkin.Gherkin.makeSourceEnvelope)1 Envelope (io.cucumber.messages.types.Envelope)1 FeatureChild (io.cucumber.messages.types.FeatureChild)1 GherkinDocument (io.cucumber.messages.types.GherkinDocument)1 HashMap (java.util.HashMap)1 Objects (java.util.Objects)1