Beispiel #1
0
  private void appendBodySortDeclarations(Body node) {
    // this is sort of hack, bypass the usual append method
    appendComments(node.getOpeningComments(), true);

    if (!isCompressing()) cssOnly.ensureSeparator();
    append(node.getOpeningCurlyBrace());
    if (!isCompressing()) cssOnly.ensureNewLine().increaseIndentationLevel();

    Iterator<ASTCssNode> declarations = node.getDeclarations().iterator();
    List<ASTCssNode> notDeclarations = node.getNotDeclarations();
    while (declarations.hasNext()) {
      ASTCssNode declaration = declarations.next();
      append(declaration);
      if (!isCompressing() && (declarations.hasNext() || notDeclarations.isEmpty()))
        cssOnly.ensureNewLine();
    }

    appendAll(notDeclarations);

    appendComments(node.getOrphanComments(), false);
    if (!isCompressing()) cssOnly.decreaseIndentationLevel();
    append(node.getClosingCurlyBrace());

    // this is sort of hack, bypass the usual append method
    appendComments(node.getTrailingComments(), false);
  }
Beispiel #2
0
  protected void appendComments(List<Comment> comments, boolean ensureSeparator) {
    if (comments == null || comments.isEmpty() || isCompressing()) return;

    cssOnly.ensureSeparator();

    for (Comment comment : comments) {
      String text = comment.getComment();
      if (text != null) cssOnly.append(text);
      if (comment.hasNewLine()) cssOnly.ensureNewLine();
    }

    if (ensureSeparator) cssOnly.ensureSeparator();
  }
Beispiel #3
0
  private boolean appendBodyOptimizeDuplicates(Body body) {
    if (body.isEmpty()) return false;

    if (!isCompressing()) cssOnly.ensureSeparator();
    append(body.getOpeningCurlyBrace());
    if (!isCompressing()) cssOnly.ensureNewLine().increaseIndentationLevel();
    Iterable<CssPrinter> declarationsBuilders = collectUniqueBodyMembersStrings(body);
    for (CssPrinter miniBuilder : declarationsBuilders) {
      append(miniBuilder);
    }

    appendComments(body.getOrphanComments(), false);
    cssOnly.decreaseIndentationLevel();
    append(body.getClosingCurlyBrace());

    return true;
  }
Beispiel #4
0
 private void appendAll(List<? extends ASTCssNode> all) {
   for (ASTCssNode kid : all) {
     if (append(kid) && !isCompressing()) cssOnly.ensureNewLine();
   }
 }