createUnitInline method
ScopeUnit
createUnitInline(
{ - StyleName? styleName,
- RegExpRecipe? match,
- RegExpPair? matchPair,
- Map<GroupRef, StyleName>? captures,
- Map<GroupRef, StyleName>? beginCaptures,
- Map<GroupRef, StyleName>? endCaptures,
- List<ScopeUnit>? innerUnits()?,
})
Implementation
ScopeUnit createUnitInline(
{
StyleName? styleName,
RegExpRecipe? match,
RegExpPair? matchPair,
Map<GroupRef, StyleName>? captures,
Map<GroupRef, StyleName>? beginCaptures,
Map<GroupRef, StyleName>? endCaptures,
List<ScopeUnit>? Function()? innerUnits,
}
) {
if (!_linker.isLinkingInnerUnits) throw StateError("`createUnitInline()` units can only be used inside an 'inner units' list. (Did you include one as a root unit?)");
// linker values have to be read/stored now while in a valid linking state
var identifier = "${_linker.parentIdentifier}.inline${_linker.countNewInline()}";
var resolvedStyleName = styleName ?? _linker.parentStyle;
return ScopeUnit._(
identifier,
isInline: true,
baseSyntax: this,
createBody: (debugName, innerPatterns) =>
_smartCreateBody(
match: match,
matchPair: matchPair,
captures: captures,
beginCaptures: beginCaptures,
endCaptures: endCaptures,
styleName: resolvedStyleName,
debugName: debugName,
innerPatterns: innerPatterns,
),
createInnerUnits: () => _linker.linkInnerUnits(
innerUnits: innerUnits,
parentStyleName: resolvedStyleName,
parentIdentifier: identifier,
),
);
}