Search in sources :

Example 1 with Parser

use of gherkin.parser.Parser in project cucumber-jvm by cucumber.

the class FeatureBuilder method parse.

public void parse(Resource resource, List<Object> filters) {
    String gherkin = read(resource);
    String checksum = checksum(gherkin);
    String path = pathsByChecksum.get(checksum);
    if (path != null) {
        return;
    }
    pathsByChecksum.put(checksum, resource.getPath());
    Formatter formatter = this;
    if (!filters.isEmpty()) {
        formatter = new FilterFormatter(this, filters);
    }
    Parser parser = new Parser(formatter);
    try {
        parser.parse(gherkin, convertFileSeparatorToForwardSlash(resource.getPath()), 0);
    } catch (Exception e) {
        throw new CucumberException(String.format("Error parsing feature file %s", convertFileSeparatorToForwardSlash(resource.getPath())), e);
    }
    I18n i18n = parser.getI18nLanguage();
    if (currentCucumberFeature != null) {
        // The current feature may be null if we used a very restrictive filter, say a tag that isn't used.
        // Might also happen if the feature file itself is empty.
        currentCucumberFeature.setI18n(i18n);
    }
}
Also used : Formatter(gherkin.formatter.Formatter) FilterFormatter(gherkin.formatter.FilterFormatter) FilterFormatter(gherkin.formatter.FilterFormatter) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Parser(gherkin.parser.Parser) I18n(gherkin.I18n)

Aggregations

I18n (gherkin.I18n)1 FilterFormatter (gherkin.formatter.FilterFormatter)1 Formatter (gherkin.formatter.Formatter)1 Parser (gherkin.parser.Parser)1 IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1