Package gherkin.formatter

Examples of gherkin.formatter.PrettyFormatter


    public void reformat() throws BadLocationException {
        if (doReformat()) {
            try {
                String source = context.document().getText(0, context.document().getLength());
                StringWriter reformattedWriter = new StringWriter();
                PrettyFormatter formatter = new PrettyFormatter(reformattedWriter, true);
                Parser parser = new Parser(formatter, true);
                parser.parse(source, "UNKNOWN", 0); //parser.parse(input, file.getPath(), 0);
                writeSource(reformattedWriter.getBuffer().toString());
            } catch (Exception e) {
                showError(e);
View Full Code Here


        return new ArrayList<String>(result);
    }

    public String getKeywordTable() {
        StringWriter writer = new StringWriter();
        PrettyFormatter pf = new PrettyFormatter(writer, true, false);
        List<Row> table = new ArrayList<Row>();
        for (String key : KEYWORD_KEYS) {
            List<String> cells = Arrays.asList(key, join(map(keywords(key), QUOTE_MAPPER), ", "));
            table.add(new DataTableRow(Collections.<Comment>emptyList(), cells, -1));
        }
        for (String key : STEP_KEYWORD_KEYS) {
            List<String> codeKeywordList = new ArrayList<String>(keywords.get(key));
            codeKeywordList.remove("* ");
            String codeKeywords = join(map(map(codeKeywordList, CODE_KEYWORD_MAPPER), QUOTE_MAPPER), ", ");

            List<String> cells = Arrays.asList(key + " (code)", codeKeywords);
            table.add(new DataTableRow(Collections.<Comment>emptyList(), cells, -1));
        }
        pf.table(table);
        return writer.getBuffer().toString();
    }
View Full Code Here

    private Parser parser;
    private final Writer out;

    public Main(final Writer out) {
        this.out = out;
        final Formatter formatter = new PrettyFormatter(out, false, true);
        parser = new Parser(formatter);
    }
View Full Code Here

  public void format() throws UnsupportedEncodingException {
    String gherkin = GherkinTestFixtures.unformatted_feature;

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PrintWriter out = new PrintWriter(output);
    Formatter formatter = new PrettyFormatter(out, true, false);

    Parser parser = new Parser(formatter);
    parser.parse(gherkin, "", 0);

    out.flush();
View Full Code Here

  public static String format(String contents) {
    // set up
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PrintWriter out = new PrintWriter(output);
    Formatter formatter = new PrettyFormatter(out, true, false);

    // parse
    new Parser(formatter).parse(contents, "", 0);

    out.flush();
View Full Code Here

TOP

Related Classes of gherkin.formatter.PrettyFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.