All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gherkin.formatter.StepPrinter Maven / Gradle / Ivy

There is a newer version: 2.12.2
Show newest version
package gherkin.formatter;

import java.util.List;

public class StepPrinter {
    public void writeStep(NiceAppendable out, Format textFormat, Format argFormat, String stepName, List arguments) {
        int textStart = 0;
        for (Argument argument : arguments) {
            // can be null if the argument is missing.
            if (argument.getOffset() != null) {
                String text = stepName.substring(textStart, argument.getOffset());
                out.append(textFormat.text(text));
            }
            // val can be null if the argument isn't there, for example @And("(it )?has something")
            if (argument.getVal() != null) {
                out.append(argFormat.text(argument.getVal()));
                textStart = argument.getOffset() + argument.getVal().length();
            }
        }
        if (textStart != stepName.length()) {
            String text = stepName.substring(textStart, stepName.length());
            out.append(textFormat.text(text));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy