Examples of PrettyFormatter


Examples of com.google.gerrit.prettify.common.PrettyFormatter

  protected SparseHtmlFile getSparseHtmlFileA(PatchScript s) {
    AccountDiffPreference dp = new AccountDiffPreference(s.getDiffPrefs());
    dp.setShowWhitespaceErrors(false);

    PrettyFormatter f = ClientSideFormatter.FACTORY.get();
    f.setDiffPrefs(dp);
    f.setFileName(s.getA().getPath());
    f.setEditFilter(PrettyFormatter.A);
    f.setEditList(s.getEdits());
    f.format(s.getA());
    return f;
  }
View Full Code Here

Examples of com.google.gerrit.prettify.common.PrettyFormatter

  }

  protected SparseHtmlFile getSparseHtmlFileB(PatchScript s) {
    AccountDiffPreference dp = new AccountDiffPreference(s.getDiffPrefs());

    PrettyFormatter f = ClientSideFormatter.FACTORY.get();
    f.setDiffPrefs(dp);
    f.setFileName(s.getB().getPath());
    f.setEditFilter(PrettyFormatter.B);
    f.setEditList(s.getEdits());

    if (dp.isSyntaxHighlighting() && s.getA().isWholeFile() && !s.getB().isWholeFile()) {
      f.format(s.getB().apply(s.getA(), s.getEdits()));
    } else {
      f.format(s.getB());
    }
    return f;
  }
View Full Code Here

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

Examples of gherkin.formatter.PrettyFormatter

        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

Examples of gherkin.formatter.PrettyFormatter

    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

Examples of gherkin.formatter.PrettyFormatter

  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

Examples of gherkin.formatter.PrettyFormatter

  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
Copyright © 2018 www.massapi.com. 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.