Example usage for com.google.common.css.compiler.passes PrettyPrinter getPrettyPrintedString

List of usage examples for com.google.common.css.compiler.passes PrettyPrinter getPrettyPrintedString

Introduction

In this page you can find the example usage for com.google.common.css.compiler.passes PrettyPrinter getPrettyPrintedString.

Prototype

public String getPrettyPrintedString() 

Source Link

Usage

From source file:com.log4ic.compressor.utils.Compressor.java

public static String parseGss(JobDescription job) throws GssParserException {
    logger.debug("?GSS...");
    try {//from  w w w  .  j  ava 2s . c o m
        GssParser parser = new GssParser(job.inputs);
        CssTree cssTree = parser.parse();
        CompilerErrorManager errorManager = new CompilerErrorManager();
        PassRunner passRunner = new ExtendedPassRunner(job, errorManager);
        passRunner.runPasses(cssTree);
        PrettyPrinter prettyPrinterPass = new PrettyPrinter(cssTree.getVisitController());
        prettyPrinterPass.runPass();
        return prettyPrinterPass.getPrettyPrintedString();
    } finally {
        logger.debug("?GSS...");
    }
}

From source file:com.log4ic.compressor.utils.Compressor.java

/**
 * css// w  ww.  j a v  a 2s. c  o  m
 *
 * @param job
 * @return
 * @throws GssParserException
 */
public static String compressGss(JobDescription job) throws GssParserException {
    logger.debug("CSS...");
    try {
        GssParser parser = new GssParser(job.inputs);
        CssTree cssTree = parser.parse();
        if (job.outputFormat != JobDescription.OutputFormat.DEBUG) {
            CompilerErrorManager errorManager = new CompilerErrorManager();
            PassRunner passRunner = new ExtendedPassRunner(job, errorManager);
            passRunner.runPasses(cssTree);
        }

        if (job.outputFormat == JobDescription.OutputFormat.COMPRESSED) {
            CompactPrinter compactPrinterPass = new CompactPrinter(cssTree);
            compactPrinterPass.runPass();
            return compactPrinterPass.getCompactPrintedString();
        } else {
            PrettyPrinter prettyPrinterPass = new PrettyPrinter(cssTree.getVisitController());
            prettyPrinterPass.runPass();
            return prettyPrinterPass.getPrettyPrintedString();
        }
    } finally {
        logger.debug("CSS...");
    }
}