5
5
// DO NOT EDIT. This file was generated from async_evaluate.dart.
6
6
// See tool/grind/synchronize.dart for details.
7
7
//
8
- // Checksum: 1c3027293ac9cb8a0d03b18c9ca447d62c2733d7
8
+ // Checksum: 358960b72c6e4f48d3e2e9d52be3abbe9e8b5a9f
9
9
//
10
10
// ignore_for_file: unused_import
11
11
@@ -426,6 +426,19 @@ final class _EvaluateVisitor
426
426
});
427
427
}, url: "sass:meta" ),
428
428
429
+ BuiltInCallable .function ("module-mixins" , r"$module" , (arguments) {
430
+ var namespace = arguments[0 ].assertString ("module" );
431
+ var module = _environment.modules[namespace.text];
432
+ if (module == null ) {
433
+ throw 'There is no module with namespace "${namespace .text }".' ;
434
+ }
435
+
436
+ return SassMap ({
437
+ for (var (name, value) in module.mixins.pairs)
438
+ SassString (name): SassMixin (value)
439
+ });
440
+ }, url: "sass:meta" ),
441
+
429
442
BuiltInCallable .function (
430
443
"get-function" , r"$name, $css: false, $module: null" , (arguments) {
431
444
var name = arguments[0 ].assertString ("name" );
@@ -452,6 +465,20 @@ final class _EvaluateVisitor
452
465
return SassFunction (callable);
453
466
}, url: "sass:meta" ),
454
467
468
+ BuiltInCallable .function ("get-mixin" , r"$name, $module: null" ,
469
+ (arguments) {
470
+ var name = arguments[0 ].assertString ("name" );
471
+ var module = arguments[1 ].realNull? .assertString ("module" );
472
+
473
+ var callable = _addExceptionSpan (
474
+ _callableNode! ,
475
+ () => _environment.getMixin (name.text.replaceAll ("_" , "-" ),
476
+ namespace: module? .text));
477
+ if (callable == null ) throw "Mixin not found: $name " ;
478
+
479
+ return SassMixin (callable);
480
+ }, url: "sass:meta" ),
481
+
455
482
BuiltInCallable .function ("call" , r"$function, $args..." , (arguments) {
456
483
var function = arguments[0 ];
457
484
var args = arguments[1 ] as SassArgumentList ;
@@ -522,7 +549,32 @@ final class _EvaluateVisitor
522
549
configuration: configuration,
523
550
namesInErrors: true );
524
551
_assertConfigurationIsEmpty (configuration, nameInError: true );
525
- }, url: "sass:meta" )
552
+ }, url: "sass:meta" ),
553
+ BuiltInCallable .mixin ("apply" , r"$mixin, $args..." , (arguments) {
554
+ var mixin = arguments[0 ];
555
+ var args = arguments[1 ] as SassArgumentList ;
556
+
557
+ var callableNode = _callableNode! ;
558
+ var invocation = ArgumentInvocation (
559
+ const [],
560
+ const {},
561
+ callableNode.span,
562
+ rest: ValueExpression (args, callableNode.span),
563
+ );
564
+
565
+ var callable = mixin .assertMixin ("mixin" ).callable;
566
+ var content = _environment.content;
567
+
568
+ // ignore: unnecessary_type_check
569
+ if (callable is Callable ) {
570
+ _applyMixin (
571
+ callable, content, invocation, callableNode, callableNode);
572
+ } else {
573
+ throw SassScriptException (
574
+ "The mixin ${callable .name } is asynchronous.\n "
575
+ "This is probably caused by a bug in a Sass plugin." );
576
+ }
577
+ }, url: "sass:meta" , acceptsContent: true ),
526
578
];
527
579
528
580
var metaModule = BuiltInModule ("meta" ,
@@ -1730,40 +1782,55 @@ final class _EvaluateVisitor
1730
1782
}
1731
1783
}
1732
1784
1733
- Value ? visitIncludeRule (IncludeRule node) {
1734
- var nodeWithSpan = AstNode .fake (() => node.spanWithoutContent);
1735
- var mixin = _addExceptionSpan (node,
1736
- () => _environment.getMixin (node.name, namespace: node.namespace));
1785
+ /// Evaluate a given [mixin] with [arguments] and [contentCallable]
1786
+ void _applyMixin (
1787
+ Callable ? mixin ,
1788
+ UserDefinedCallable <Environment >? contentCallable,
1789
+ ArgumentInvocation arguments,
1790
+ AstNode nodeWithSpan,
1791
+ AstNode nodeWithSpanWithoutContent) {
1737
1792
switch (mixin ) {
1738
1793
case null :
1739
- throw _exception ("Undefined mixin." , node.span);
1740
-
1741
- case BuiltInCallable () when node.content != null :
1742
- throw _exception ("Mixin doesn't accept a content block." , node.span);
1794
+ throw _exception ("Undefined mixin." , nodeWithSpan.span);
1743
1795
1796
+ case BuiltInCallable (acceptsContent: false ) when contentCallable != null :
1797
+ {
1798
+ var evaluated = _evaluateArguments (arguments);
1799
+ var (overload, _) = mixin .callbackFor (
1800
+ evaluated.positional.length, MapKeySet (evaluated.named));
1801
+ throw MultiSpanSassRuntimeException (
1802
+ "Mixin doesn't accept a content block." ,
1803
+ nodeWithSpanWithoutContent.span,
1804
+ "invocation" ,
1805
+ {overload.spanWithName: "declaration" },
1806
+ _stackTrace (nodeWithSpanWithoutContent.span));
1807
+ }
1744
1808
case BuiltInCallable ():
1745
- _runBuiltInCallable (node.arguments, mixin , nodeWithSpan);
1809
+ _environment.withContent (contentCallable, () {
1810
+ _environment.asMixin (() {
1811
+ _runBuiltInCallable (arguments, mixin , nodeWithSpanWithoutContent);
1812
+ });
1813
+ });
1746
1814
1747
1815
case UserDefinedCallable <Environment >(
1748
1816
declaration: MixinRule (hasContent: false )
1749
1817
)
1750
- when node.content != null :
1818
+ when contentCallable != null :
1751
1819
throw MultiSpanSassRuntimeException (
1752
1820
"Mixin doesn't accept a content block." ,
1753
- node.spanWithoutContent ,
1821
+ nodeWithSpanWithoutContent.span ,
1754
1822
"invocation" ,
1755
1823
{mixin .declaration.arguments.spanWithName: "declaration" },
1756
- _stackTrace (node.spanWithoutContent ));
1824
+ _stackTrace (nodeWithSpanWithoutContent.span ));
1757
1825
1758
1826
case UserDefinedCallable <Environment >():
1759
- var contentCallable = node.content.andThen ((content) =>
1760
- UserDefinedCallable (content, _environment.closure (),
1761
- inDependency: _inDependency));
1762
- _runUserDefinedCallable (node.arguments, mixin , nodeWithSpan, () {
1827
+ _runUserDefinedCallable (arguments, mixin , nodeWithSpanWithoutContent,
1828
+ () {
1763
1829
_environment.withContent (contentCallable, () {
1764
1830
_environment.asMixin (() {
1765
1831
for (var statement in mixin .declaration.children) {
1766
- _addErrorSpan (nodeWithSpan, () => statement.accept (this ));
1832
+ _addErrorSpan (
1833
+ nodeWithSpanWithoutContent, () => statement.accept (this ));
1767
1834
}
1768
1835
});
1769
1836
});
@@ -1772,6 +1839,20 @@ final class _EvaluateVisitor
1772
1839
case _:
1773
1840
throw UnsupportedError ("Unknown callable type $mixin ." );
1774
1841
}
1842
+ }
1843
+
1844
+ Value ? visitIncludeRule (IncludeRule node) {
1845
+ var mixin = _addExceptionSpan (node,
1846
+ () => _environment.getMixin (node.name, namespace: node.namespace));
1847
+ var contentCallable = node.content.andThen ((content) => UserDefinedCallable (
1848
+ content, _environment.closure (),
1849
+ inDependency: _inDependency));
1850
+
1851
+ var nodeWithSpanWithoutContent =
1852
+ AstNode .fake (() => node.spanWithoutContent);
1853
+
1854
+ _applyMixin (mixin , contentCallable, node.arguments, node,
1855
+ nodeWithSpanWithoutContent);
1775
1856
1776
1857
return null ;
1777
1858
}
0 commit comments