Class ResolveCustomFunctionNodesForChunks<T>
- java.lang.Object
-
- com.google.common.css.compiler.ast.DefaultTreeVisitor
-
- com.google.common.css.compiler.passes.ResolveCustomFunctionNodes
-
- com.google.common.css.compiler.passes.ResolveCustomFunctionNodesForChunks<T>
-
- All Implemented Interfaces:
AtRuleHandler,CssCompilerPass,CssTreeVisitor
public class ResolveCustomFunctionNodesForChunks<T> extends ResolveCustomFunctionNodes
This compiler pass evaluatesCssCustomFunctionNodeinstances only when they have no references as arguments. Otherwise, it creates a new definition for the function call even if it's already a definition. At the end, the main tree is free of function calls; all the new definitions are collected in a map ofConstantDefinitionsper chunk; there are no nested calls.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEF_PREFIXThe prefix for definitions of calls with references-
Fields inherited from class com.google.common.css.compiler.passes.ResolveCustomFunctionNodes
functionMap
-
-
Constructor Summary
Constructors Constructor Description ResolveCustomFunctionNodesForChunks(MutatingVisitController visitController, ErrorManager errorManager, java.util.Map<java.lang.String,GssFunction> functionMap, boolean allowUnknownFunctions, java.util.Set<java.lang.String> allowedNonStandardFunctions, com.google.common.base.Function<T,java.lang.String> nextUniqueSuffix)Constructs the pass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<CssValueNode>evaluateFunction(CssCustomFunctionNode node, GssFunction function, java.util.List<CssValueNode> arguments, ErrorManager errorManager)Evaluates the given function node.java.util.Map<T,ConstantDefinitions>getConstantDefinitions()Gets the constant definitions for the replaced calls with references.-
Methods inherited from class com.google.common.css.compiler.passes.ResolveCustomFunctionNodes
leaveFunctionNode, runPass
-
Methods inherited from class com.google.common.css.compiler.ast.DefaultTreeVisitor
enterArgumentNode, enterAttributeSelector, enterBlock, enterCharSet, enterClassSelector, enterCombinator, enterComponent, enterCompositeValueNode, enterCompositeValueNodeOperator, enterConditionalBlock, enterConditionalRule, enterDeclaration, enterDeclarationBlock, enterDefinition, enterFontFace, enterForLoop, enterFunctionNode, enterIdSelector, enterImportBlock, enterImportRule, enterKey, enterKeyBlock, enterKeyframeRuleset, enterKeyframesRule, enterMediaRule, enterMediaTypeListDelimiter, enterMixin, enterMixinDefinition, enterPageRule, enterPageSelector, enterPropertyValue, enterProvideNode, enterPseudoClass, enterPseudoElement, enterRequireNode, enterRuleset, enterSelector, enterSelectorBlock, enterTree, enterUnknownAtRule, enterValueNode, leaveArgumentNode, leaveAttributeSelector, leaveBlock, leaveCharSet, leaveClassSelector, leaveCombinator, leaveComponent, leaveCompositeValueNode, leaveCompositeValueNodeOperator, leaveConditionalBlock, leaveConditionalRule, leaveDeclaration, leaveDeclarationBlock, leaveDefinition, leaveFontFace, leaveForLoop, leaveIdSelector, leaveImportBlock, leaveImportRule, leaveKey, leaveKeyBlock, leaveKeyframeRuleset, leaveKeyframesRule, leaveMediaRule, leaveMediaTypeListDelimiter, leaveMixin, leaveMixinDefinition, leavePageRule, leavePageSelector, leavePropertyValue, leaveProvideNode, leavePseudoClass, leavePseudoElement, leaveRequireNode, leaveRuleset, leaveSelector, leaveSelectorBlock, leaveTree, leaveUnknownAtRule, leaveValueNode
-
-
-
-
Field Detail
-
DEF_PREFIX
public static final java.lang.String DEF_PREFIX
The prefix for definitions of calls with references- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ResolveCustomFunctionNodesForChunks
public ResolveCustomFunctionNodesForChunks(MutatingVisitController visitController, ErrorManager errorManager, java.util.Map<java.lang.String,GssFunction> functionMap, boolean allowUnknownFunctions, java.util.Set<java.lang.String> allowedNonStandardFunctions, com.google.common.base.Function<T,java.lang.String> nextUniqueSuffix)
Constructs the pass.- Parameters:
visitController- the visit controllererrorManager- the error managerfunctionMap- the map from function names to resolve to GSS functionsallowUnknownFunctions- whether to allow unknown function calls, leaving them as is, instead of reporting an errornextUniqueSuffix- a function from a chunk to a globally unique suffix
-
-
Method Detail
-
evaluateFunction
protected java.util.List<CssValueNode> evaluateFunction(CssCustomFunctionNode node, GssFunction function, java.util.List<CssValueNode> arguments, ErrorManager errorManager) throws GssFunctionException
Description copied from class:ResolveCustomFunctionNodesEvaluates the given function node.Subclasses may sublcass this method to change the evaluation process in some circumstances.
- Overrides:
evaluateFunctionin classResolveCustomFunctionNodes- Parameters:
node- the function node to evaluatefunction- the GSS function matching this nodearguments- the arguments of this nodeerrorManager- the error manager passed into the GSS function call- Returns:
- the result of the evaluation as a list of value nodes
- Throws:
GssFunctionException- if the function call is invalid
-
getConstantDefinitions
public java.util.Map<T,ConstantDefinitions> getConstantDefinitions()
Gets the constant definitions for the replaced calls with references. Chunks which have no such calls are not in the map.- Returns:
- A map of constant definitions per chunk
-
-