assertComplexSelector method
Parses this as a complex selector, in the same manner as the
selector-parse() function.
Throws a SassScriptException if this isn't a type that can be parsed as a
selector, or if parsing fails. If allowParent is true, this allows
ParentSelectors. Otherwise, they're considered parse errors.
If this came from a function argument, name is the argument name
(without the $). It's used for error reporting.
Implementation
ComplexSelector assertComplexSelector({
String? name,
bool allowParent = false,
}) {
var string = _selectorString(name);
try {
return ComplexSelector.parse(string, allowParent: allowParent);
} on SassFormatException catch (error, stackTrace) {
// TODO(nweiz): colorize this if we're running in an environment where
// that works.
throwWithTrace(
SassScriptException(error.toString().replaceFirst("Error: ", ""), name),
error,
stackTrace,
);
}
}