Example usage for com.google.common.css.compiler.ast CssFunctionNode getFunction

List of usage examples for com.google.common.css.compiler.ast CssFunctionNode getFunction

Introduction

In this page you can find the example usage for com.google.common.css.compiler.ast CssFunctionNode getFunction.

Prototype

public Function getFunction() 

Source Link

Usage

From source file:io.bazel.rules.closure.webfiles.WebfilesValidator.java

private void validateCss(final Path path, final Webpath origin, String source) {
    CssTree stylesheet = cssParser.parse(path.toString(), source);
    new PassRunner(new JobDescriptionBuilder().getJobDescription(), new BasicErrorManager() {
        @Override/*  www.  j  a  v a 2 s. c  o m*/
        public void print(String message) {
            WebfilesValidator.this.errors.put(CSS_VALIDATION_ERROR, String.format("%s: %s", path, message));
        }
    }).runPasses(stylesheet);
    stylesheet.getVisitController().startVisit(new DefaultTreeVisitor() {
        private boolean inUrlFunction;

        @Override
        public boolean enterFunctionNode(CssFunctionNode function) {
            return (inUrlFunction = function.getFunction().getFunctionName().equals("url"));
        }

        @Override
        public void leaveFunctionNode(CssFunctionNode value) {
            inUrlFunction = false;
        }

        @Override
        public boolean enterArgumentNode(CssValueNode argument) {
            if (inUrlFunction) {
                String uri = nullToEmpty(argument.getValue());
                if (!shouldIgnoreUri(uri)) {
                    addRelationship(path, origin, Webpath.get(uri));
                }
            }
            return false;
        }
    });
}