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
This compiler pass evaluates
CssCustomFunctionNode instances 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 of ConstantDefinitions per chunk; there are no nested calls.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe prefix for definitions of calls with referencesFields inherited from class com.google.common.css.compiler.passes.ResolveCustomFunctionNodes
functionMap -
Constructor Summary
ConstructorsConstructorDescriptionResolveCustomFunctionNodesForChunks(MutatingVisitController visitController, ErrorManager errorManager, Map<String, GssFunction> functionMap, boolean allowUnknownFunctions, Set<String> allowedNonStandardFunctions, com.google.common.base.Function<T, String> nextUniqueSuffix) Constructs the pass. -
Method Summary
Modifier and TypeMethodDescriptionprotected List<CssValueNode>evaluateFunction(CssCustomFunctionNode node, GssFunction function, List<CssValueNode> arguments, ErrorManager errorManager) Evaluates the given function node.Gets the constant definitions for the replaced calls with references.Methods inherited from class com.google.common.css.compiler.passes.ResolveCustomFunctionNodes
leaveFunctionNode, runPassMethods 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 Details
-
DEF_PREFIX
The prefix for definitions of calls with references- See Also:
-
-
Constructor Details
-
ResolveCustomFunctionNodesForChunks
public ResolveCustomFunctionNodesForChunks(MutatingVisitController visitController, ErrorManager errorManager, Map<String, GssFunction> functionMap, boolean allowUnknownFunctions, Set<String> allowedNonStandardFunctions, com.google.common.base.Function<T, 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 Details
-
evaluateFunction
protected List<CssValueNode> evaluateFunction(CssCustomFunctionNode node, GssFunction function, 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
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
-