com.vaadin.sass.internal.parser
Class FormalArgumentList
java.lang.Object
com.vaadin.sass.internal.parser.FormalArgumentList
- All Implemented Interfaces:
- Serializable, Iterable<VariableNode>
public class FormalArgumentList
- extends Object
- implements Serializable, Iterable<VariableNode>
FormalArgumentList is used for representing the parameter list of a mixin or
a function definition. Formal arguments are always named and may optionally
have a default value. FormalArgumentList also supports variable arguments,
which means that if there are more actual than formal parameters, all actual
parameters not corresponding to an ordinary formal parameter are packed into
a list. The list becomes the value of the variable argument. When variable
arguments are used, the number of actual arguments can also be one less than
the number of formal arguments. In that case the value of the variable
argument is an empty list.
- Author:
- Vaadin
- See Also:
- Serialized Form
FormalArgumentList
public FormalArgumentList(Collection<VariableNode> args,
boolean hasVariableArguments)
replaceVariables
public FormalArgumentList replaceVariables(Collection<VariableNode> variables)
replaceFormalArguments
public FormalArgumentList replaceFormalArguments(ActualArgumentList actualArgumentList)
- Returns a new FormalArgumentList that is obtained from this list by
replacing all formal arguments with the corresponding actual arguments.
Does not modify this list.
The replacement works in several phases. The first phase replaces formal
arguments that have the same name as one of the actual arguments. The
second phase replaces the remaining unset formal arguments with the
values of the unnamed actual arguments. Default values are then given for
any remaining formal arguments without a value. Finally, if there are
variable arguments, any unused actual arguments are packed into a list,
which becomes the value of the variable argument.
Examples:
1) formal argument list ($a, $b, $c: 10, $d: 7, $e: 5), actual argument
list (1, 2, $d: 4, $c: 3). After the first phase the list is ($a: null,
$b: null, $c: 3, $d: 4, $e: null). The second phase transforms that to
($a: 1, $b: 2, $c: 3, $d: 4, $e: null). The remaining variable is then
given its default value with result ($a: 1, $b: 2, $c: 3, $d: 4, $e: 5).
2) formal argument list ($a...), actual argument list empty. After
replacement the formal argument list is ($a: ()).
3) formal argument list ($a, $b...), actual argument list (1, 2, 3, $c:
4). After replacement the formal argument list is ($a: 1, $b: (2, 3, $c:
4).
Note that if named arguments are packed into a list for a variable
argument as in example 3, they cannot be accessed by the mixin or the
function. It is, however, possible to pass them to another function or a
mixin using an @include or a function call with variable arguments.
- Parameters:
actualArgumentList - The actual arguments.
- Returns:
- A FormalArgumentList with the values of the arguments taken from
the actual argument list and from the default values.
hasVariableArguments
public boolean hasVariableArguments()
isEmpty
public boolean isEmpty()
iterator
public Iterator<VariableNode> iterator()
- Specified by:
iterator in interface Iterable<VariableNode>
size
public int size()
get
public VariableNode get(int i)
getArguments
public List<VariableNode> getArguments()
toString
public String toString()
- Overrides:
toString in class Object
Copyright © 2013–2014 Vaadin. All rights reserved.