// Path: src/main/java/com/google/gwt/resources/gss/ast/CssDotPathNode.java
// public class CssDotPathNode extends CssValueNode {
// 
//   public static String resolveExpression(String instance, String path, String prefix, String suffix) {
//     String expression = path.replace(".", "().") + "()";
// 
//     if (!Strings.isNullOrEmpty(instance)) {
//       expression = instance + "." + expression;
//     }
// 
//     if (!Strings.isNullOrEmpty(prefix)) {
//       expression = "\"" + Generator.escape(prefix) + "\" + " + expression;
//     }
// 
//     if (!Strings.isNullOrEmpty(suffix)) {
//       expression += " + \"" + Generator.escape(suffix) + "\"";
//     }
// 
//     return expression;
//   }
// 
//   private String suffix;
//   private String prefix;
//   private String path;
//   private String instance;
// 
//   public CssDotPathNode(String dotPath, String prefix, String suffix, SourceCodeLocation sourceCodeLocation) {
//     this(null, dotPath, prefix, suffix, sourceCodeLocation);
//   }
// 
//   public CssDotPathNode(String instance, String dotPath, String prefix, String suffix,
//       SourceCodeLocation sourceCodeLocation) {
//     super(resolveExpression(instance, dotPath, prefix, suffix), sourceCodeLocation);
// 
//     this.prefix = prefix;
//     this.suffix = suffix;
//     this.path = dotPath;
//     this.instance = instance;
//   }
// 
//   @Override
//   public CssValueNode deepCopy() {
//     return new CssDotPathNode(instance, path, prefix, suffix, getSourceCodeLocation());
//   }
// 
//   public String getPath() {
//     return path;
//   }
// 
//   public String getSuffix() {
//     return suffix;
//   }
// 
//   public String getPrefix() {
//     return prefix;
//   }
// 
//   public String getInstance() {
//     return instance;
//   }
// 
//   public List<String> getPathElements() {
//     return Arrays.asList(path.split("\\."));
//   }
// }
// 
// Path: src/main/java/com/google/gwt/resources/gss/ast/CssJavaExpressionNode.java
// public class CssJavaExpressionNode extends CssValueNode {
// 
//   public CssJavaExpressionNode(String expression) {
//     this(expression, null);
//   }
// 
//   public CssJavaExpressionNode(String expression, SourceCodeLocation sourceCodeLocation) {
//     super(expression, sourceCodeLocation);
//   }
// 
//   @Override
//   public CssValueNode deepCopy() {
//     return new CssJavaExpressionNode(getValue());
//   }
// 
//   @Override
//   public String toString() {
//     return "Java expression : " + getValue();
//   }
// }
// 
// Path: src/main/java/com/google/gwt/resources/gss/ast/CssRuntimeConditionalRuleNode.java
// public class CssRuntimeConditionalRuleNode extends CssConditionalRuleNode {
// 
//   public CssRuntimeConditionalRuleNode(CssConditionalRuleNode node,
//       @Nullable CssJavaExpressionNode condition) {
//     super(node.getType(), node.getName().deepCopy(), null,
//         node.getBlock() != null ? node.getBlock().deepCopy() : null);
//     setSourceCodeLocation(node.getSourceCodeLocation());
// 
//     if (condition != null) {
//       setRuntimeCondition(condition);
//     }
//   }
// 
//   /**
//    * Copy constructor.
//    *
//    * @param node
//    */
//   public CssRuntimeConditionalRuleNode(CssRuntimeConditionalRuleNode node) {
//     this(node, node.getRuntimeCondition());
//   }
// 
//   /**
//    * Can only be called after the node is completely built (meaning it has
//    * the condition set).
//    */
//   public CssJavaExpressionNode getRuntimeCondition() {
//     if (getType() == Type.ELSE) {
//       Preconditions.checkState(getParametersCount() == 0);
//       return null;
//     }
// 
//     Preconditions.checkState(getParametersCount() == 1);
//     return (CssJavaExpressionNode) this.getParameters().get(0);
//   }
// 
//   void setRuntimeCondition(CssJavaExpressionNode condition) {
//     Preconditions.checkState(getType() != Type.ELSE);
//     Preconditions.checkState(getParametersCount() <= 1);
//     this.setParameters(ImmutableList.<CssValueNode>of(condition));
//   }
// 
//   @Override
//   public CssConditionalRuleNode deepCopy() {
//     return new CssRuntimeConditionalRuleNode(this);
//   }
// }


import java.util.Stack;
import com.google.common.css.compiler.ast.CssAtRuleNode.Type;
import com.google.common.css.compiler.ast.CssConditionalBlockNode;
import com.google.common.css.compiler.ast.CssConditionalRuleNode;
import com.google.common.css.compiler.ast.CssNode;
import com.google.common.css.compiler.ast.CssRootNode;
import com.google.common.css.compiler.ast.CssTree;
import com.google.common.css.compiler.ast.CssUnknownAtRuleNode;
import com.google.common.css.compiler.ast.CssValueNode;
import com.google.common.css.compiler.passes.CompactPrinter;
import com.google.gwt.core.ext.Generator;
import com.google.gwt.resources.gss.ast.CssDotPathNode;
import com.google.gwt.resources.gss.ast.CssJavaExpressionNode;
import com.google.gwt.resources.gss.ast.CssRuntimeConditionalRuleNode;

    masterStringBuilder.append(CONTATENATION_BLOCK);

    elseNodeFound.push(false);

    return true;
  }

  @Override
  public void leaveConditionalBlock(CssConditionalBlockNode block) {
    if (!elseNodeFound.pop()) {
      masterStringBuilder.append("\"\"");
    }
    masterStringBuilder.append(CONTATENATION_BLOCK);

    // reset concatenation counter
    concatenationNumber = 0;
  }

  @Override
  public boolean enterConditionalRule(CssConditionalRuleNode node) {
    if (node.getType() == Type.ELSE) {
      elseNodeFound.pop();
      elseNodeFound.push(true);

      masterStringBuilder.append(LEFT_BRACKET);
    } else {
      CssRuntimeConditionalRuleNode conditionalRuleNode = (CssRuntimeConditionalRuleNode) node;

      masterStringBuilder.append(LEFT_BRACKET);
// Path: src/main/java/com/google/gwt/resources/gss/ast/CssDotPathNode.java
// public class CssDotPathNode extends CssValueNode {
// 
//   public static String resolveExpression(String instance, String path, String prefix, String suffix) {
//     String expression = path.replace(".", "().") + "()";
// 
//     if (!Strings.isNullOrEmpty(instance)) {
//       expression = instance + "." + expression;
//     }
// 
//     if (!Strings.isNullOrEmpty(prefix)) {
//       expression = "\"" + Generator.escape(prefix) + "\" + " + expression;
//     }
// 
//     if (!Strings.isNullOrEmpty(suffix)) {
//       expression += " + \"" + Generator.escape(suffix) + "\"";
//     }
// 
//     return expression;
//   }
// 
//   private String suffix;
//   private String prefix;
//   private String path;
//   private String instance;
// 
//   public CssDotPathNode(String dotPath, String prefix, String suffix, SourceCodeLocation sourceCodeLocation) {
//     this(null, dotPath, prefix, suffix, sourceCodeLocation);
//   }
// 
//   public CssDotPathNode(String instance, String dotPath, String prefix, String suffix,
//       SourceCodeLocation sourceCodeLocation) {
//     super(resolveExpression(instance, dotPath, prefix, suffix), sourceCodeLocation);
// 
//     this.prefix = prefix;
//     this.suffix = suffix;
//     this.path = dotPath;
//     this.instance = instance;
//   }
// 
//   @Override
//   public CssValueNode deepCopy() {
//     return new CssDotPathNode(instance, path, prefix, suffix, getSourceCodeLocation());
//   }
// 
//   public String getPath() {
//     return path;
//   }
// 
//   public String getSuffix() {
//     return suffix;
//   }
// 
//   public String getPrefix() {
//     return prefix;
//   }
// 
//   public String getInstance() {
//     return instance;
//   }
// 
//   public List<String> getPathElements() {
//     return Arrays.asList(path.split("\\."));
//   }
// }
// 
// Path: src/main/java/com/google/gwt/resources/gss/ast/CssJavaExpressionNode.java
// public class CssJavaExpressionNode extends CssValueNode {
// 
//   public CssJavaExpressionNode(String expression) {
//     this(expression, null);
//   }
// 
//   public CssJavaExpressionNode(String expression, SourceCodeLocation sourceCodeLocation) {
//     super(expression, sourceCodeLocation);
//   }
// 
//   @Override
//   public CssValueNode deepCopy() {
//     return new CssJavaExpressionNode(getValue());
//   }
// 
//   @Override
//   public String toString() {
//     return "Java expression : " + getValue();
//   }
// }
// 
// Path: src/main/java/com/google/gwt/resources/gss/ast/CssRuntimeConditionalRuleNode.java
// public class CssRuntimeConditionalRuleNode extends CssConditionalRuleNode {
// 
//   public CssRuntimeConditionalRuleNode(CssConditionalRuleNode node,
//       @Nullable CssJavaExpressionNode condition) {
//     super(node.getType(), node.getName().deepCopy(), null,
//         node.getBlock() != null ? node.getBlock().deepCopy() : null);
//     setSourceCodeLocation(node.getSourceCodeLocation());
// 
//     if (condition != null) {
//       setRuntimeCondition(condition);
//     }
//   }
// 
//   /**
//    * Copy constructor.
//    *
//    * @param node
//    */
//   public CssRuntimeConditionalRuleNode(CssRuntimeConditionalRuleNode node) {
//     this(node, node.getRuntimeCondition());
//   }
// 
//   /**
//    * Can only be called after the node is completely built (meaning it has
//    * the condition set).
//    */
//   public CssJavaExpressionNode getRuntimeCondition() {
//     if (getType() == Type.ELSE) {
//       Preconditions.checkState(getParametersCount() == 0);
//       return null;
//     }
// 
//     Preconditions.checkState(getParametersCount() == 1);
//     return (CssJavaExpressionNode) this.getParameters().get(0);
//   }
// 
//   void setRuntimeCondition(CssJavaExpressionNode condition) {
//     Preconditions.checkState(getType() != Type.ELSE);
//     Preconditions.checkState(getParametersCount() <= 1);
//     this.setParameters(ImmutableList.<CssValueNode>of(condition));
//   }
// 
//   @Override
//   public CssConditionalRuleNode deepCopy() {
//     return new CssRuntimeConditionalRuleNode(this);
//   }
// }


// Path: src/main/java/com/google/gwt/resources/gss/CssPrinter.java
import java.util.Stack;
import com.google.common.css.compiler.ast.CssAtRuleNode.Type;
import com.google.common.css.compiler.ast.CssConditionalBlockNode;
import com.google.common.css.compiler.ast.CssConditionalRuleNode;
import com.google.common.css.compiler.ast.CssNode;
import com.google.common.css.compiler.ast.CssRootNode;
import com.google.common.css.compiler.ast.CssTree;
import com.google.common.css.compiler.ast.CssUnknownAtRuleNode;
import com.google.common.css.compiler.ast.CssValueNode;
import com.google.common.css.compiler.passes.CompactPrinter;
import com.google.gwt.core.ext.Generator;
import com.google.gwt.resources.gss.ast.CssDotPathNode;
import com.google.gwt.resources.gss.ast.CssJavaExpressionNode;
import com.google.gwt.resources.gss.ast.CssRuntimeConditionalRuleNode;


    masterStringBuilder.append(CONTATENATION_BLOCK);

    elseNodeFound.push(false);

    return true;
  }

  @Override
  public void leaveConditionalBlock(CssConditionalBlockNode block) {
    if (!elseNodeFound.pop()) {
      masterStringBuilder.append("\"\"");
    }
    masterStringBuilder.append(CONTATENATION_BLOCK);

    // reset concatenation counter
    concatenationNumber = 0;
  }

  @Override
  public boolean enterConditionalRule(CssConditionalRuleNode node) {
    if (node.getType() == Type.ELSE) {
      elseNodeFound.pop();
      elseNodeFound.push(true);

      masterStringBuilder.append(LEFT_BRACKET);
    } else {
      CssRuntimeConditionalRuleNode conditionalRuleNode = (CssRuntimeConditionalRuleNode) node;

      masterStringBuilder.append(LEFT_BRACKET);
      masterStringBuilder.append(conditionalRuleNode.getRuntimeCondition().getValue());