Example #1
0
  private Iterable<CssPrinter> collectUniqueBodyMembersStrings(Body body) {
    // the same declaration must be printed only once
    LastOfKindSet<String, CssPrinter> declarationsStrings = new LastOfKindSet<String, CssPrinter>();
    for (ASTCssNode declaration : body.getMembers()) {
      CssPrinter miniPrinter = new CssPrinter(this);

      miniPrinter.append(declaration);
      if (!isCompressing()) miniPrinter.cssOnly.ensureNewLine();

      declarationsStrings.add(miniPrinter.toCss().toString(), miniPrinter);
    }

    return declarationsStrings;
  }
  private String doCompile(String lessContent) throws Less4jException {

    ANTLRParser.ParseResult result = parser.parseStyleSheet(lessContent);
    if (result.hasErrors()) {
      CompilationResult compilationResult =
          new CompilationResult("Errors during parsing phase, partial result is not available.");
      throw new Less4jException(result.getErrors(), compilationResult);
    }
    StyleSheet lessStyleSheet = astBuilder.parse(result.getTree());
    ASTCssNode cssStyleSheet = compiler.compileToCss(lessStyleSheet);

    CssPrinter builder = new CssPrinter();
    builder.append(cssStyleSheet);
    return builder.toString();
  }