Example usage for com.google.common.css.compiler.passes PassRunner runPasses

List of usage examples for com.google.common.css.compiler.passes PassRunner runPasses

Introduction

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

Prototype

public void runPasses(CssTree cssTree) 

Source Link

Document

Runs the passes on the specified CssTree .

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.  ja  va2 s . 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 w w. ja v  a2 s .  co 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...");
    }
}