Example usage for com.google.common.css.compiler.passes ConstantDefinitions getConstantDefinition

List of usage examples for com.google.common.css.compiler.passes ConstantDefinitions getConstantDefinition

Introduction

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

Prototype

public CssDefinitionNode getConstantDefinition(String constant) 

Source Link

Document

Returns the last definition of a constant.

Usage

From source file:com.google.gwt.resources.rg.GssResourceGenerator.java

private boolean writeUserMethod(TreeLogger logger, JMethod userMethod, SourceWriter sw,
        OptimizationInfo optimizationInfo, Map<String, String> substitutionMap)
        throws UnableToCompleteException {
    String className = getClassName(userMethod);
    // method to access style class ?
    if (substitutionMap.containsKey(className)) {
        return writeClassMethod(logger, userMethod, substitutionMap, sw);
    }//from   w  ww.  ja  va 2  s  .c om

    // method to access constant value ?
    ConstantDefinitions constantDefinitions = optimizationInfo.constantDefinitions;
    CssDefinitionNode definitionNode = constantDefinitions.getConstantDefinition(userMethod.getName());

    if (definitionNode == null) {
        // try with upper case
        definitionNode = constantDefinitions.getConstantDefinition(toUpperCase(userMethod.getName()));
    }

    if (definitionNode != null) {
        return writeDefMethod(definitionNode, logger, userMethod, sw);
    }

    // the method doesn't match a style class nor a constant
    logger.log(Type.ERROR, "The following method [" + userMethod.getName() + "()] doesn't match a constant"
            + " nor a style class. You could fix that by adding ." + className + " {}");
    return false;
}