Class CssCustomFunctionNode
- java.lang.Object
-
- com.google.common.css.compiler.ast.CssNode
-
- com.google.common.css.compiler.ast.CssValueNode
-
- com.google.common.css.compiler.ast.CssFunctionNode
-
- com.google.common.css.compiler.ast.CssCustomFunctionNode
-
- All Implemented Interfaces:
ChunkAware,Proxiable<CssCustomFunctionNode>,Locatable
- Direct Known Subclasses:
CssCustomFunctionNode.CssCustomFunctionNodeProxy
public class CssCustomFunctionNode extends CssFunctionNode implements Proxiable<CssCustomFunctionNode>
A node representing a custom GSS function call.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCssCustomFunctionNode.CssCustomFunctionNodeProxyCopy-on-Write proxy forCssCustomFunctionNodeused to avoid copying of function call subtrees inReplaceConstantReferencespass.-
Nested classes/interfaces inherited from class com.google.common.css.compiler.ast.CssFunctionNode
CssFunctionNode.Function
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<CssValueNode>resultNodes
-
Constructor Summary
Constructors Constructor Description CssCustomFunctionNode(CssCustomFunctionNode function)Copy constructor.CssCustomFunctionNode(java.lang.String gssFunctionName, SourceCodeLocation sourceCodeLocation)Constructor of the node.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CssCustomFunctionNodecreateProxy()Creates the proxy object.CssCustomFunctionNodedeepCopy()static java.util.List<CssValueNode>fixupFunctionArguments(java.lang.Iterable<CssValueNode> functionParameters)TurnsfunctionParameterscontaining comma and space literals into a correctly-grouped list ofCssValueNodes.java.lang.StringgetFunctionName()java.util.List<CssValueNode>getResult()voidsetArguments(CssFunctionArgumentsNode arguments)voidsetResult(java.util.List<CssValueNode> functionResult)Saves the value of function computation for later use.java.lang.StringtoString()Use for debugging only.-
Methods inherited from class com.google.common.css.compiler.ast.CssFunctionNode
getArguments, getChunk, getFunction, getValue, setChunk
-
Methods inherited from class com.google.common.css.compiler.ast.CssValueNode
getIsDefault, setIsDefault, setValue
-
Methods inherited from class com.google.common.css.compiler.ast.CssNode
ancestors, appendComment, deepCopyNodes, equals, getComments, getParent, getShouldBeFlipped, getSourceCodeLocation, getVisitController, hasComment, hashCode, inFunArgs, setComments, setShouldBeFlipped, setSourceCodeLocation
-
-
-
-
Field Detail
-
resultNodes
protected java.util.List<CssValueNode> resultNodes
-
-
Constructor Detail
-
CssCustomFunctionNode
public CssCustomFunctionNode(java.lang.String gssFunctionName, SourceCodeLocation sourceCodeLocation)Constructor of the node.- Parameters:
gssFunctionName- name of the function "called" by this nodesourceCodeLocation- location of this node
-
CssCustomFunctionNode
public CssCustomFunctionNode(CssCustomFunctionNode function)
Copy constructor.- Parameters:
function- the copied custom function node
-
-
Method Detail
-
deepCopy
public CssCustomFunctionNode deepCopy()
- Overrides:
deepCopyin classCssFunctionNode
-
getFunctionName
public java.lang.String getFunctionName()
- Overrides:
getFunctionNamein classCssFunctionNode
-
toString
public java.lang.String toString()
Description copied from class:CssValueNodeUse for debugging only.- Overrides:
toStringin classCssFunctionNode- See Also:
Object.toString()
-
setArguments
public void setArguments(CssFunctionArgumentsNode arguments)
- Overrides:
setArgumentsin classCssFunctionNode
-
createProxy
public CssCustomFunctionNode createProxy()
Description copied from interface:ProxiableCreates the proxy object. If the original object is immutable and does not have any children, it can return itself.- Specified by:
createProxyin interfaceProxiable<CssCustomFunctionNode>- Returns:
- the copy-on-write proxy for this node
-
getResult
public java.util.List<CssValueNode> getResult()
- Returns:
- cached result of function value computation
-
setResult
public void setResult(java.util.List<CssValueNode> functionResult)
Saves the value of function computation for later use.- Parameters:
functionResult- the list of nodes returned by the call to theGssFunction
-
fixupFunctionArguments
public static java.util.List<CssValueNode> fixupFunctionArguments(java.lang.Iterable<CssValueNode> functionParameters)
TurnsfunctionParameterscontaining comma and space literals into a correctly-grouped list ofCssValueNodes. For example, in this code:
the* @def A 1 2 3 4; @def B 6 7 8 9; @def USE_A true; @def MARGIN selectFrom(USE_A, A, B);selectFromgets expanded to:
where each value in braces is one parameter. That's 17 parameters. Passing that parameter list to this function returns a list with 3 values:* @def MARGIN selectFrom([true][,][1][ ][2][ ][3][ ][4][,][6][ ][7][ ][8][ ][9])true,1 2 3 4, and6 7 8 9.Note that this function must be passed value nodes that are already expanded as it will create
CssLiteralNodes out of the values between commas via concatenation of theirtoStringmethods.- Parameters:
functionParameters- an iterable that contains resolved parameter values (no references)- Returns:
- a list values that represent the actual arguments to the function, one value per argument
-
-