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: 7a3ae06379ca09dbf3e92d01c1fd974c5b3b9154
8
+ // Checksum: 5cdb3467b517bf381d525a1a4bc4f9b6a0eeefad
9
9
//
10
10
// ignore_for_file: unused_import
11
11
@@ -32,6 +32,7 @@ import '../callable.dart';
32
32
import '../color_names.dart' ;
33
33
import '../configuration.dart' ;
34
34
import '../configured_value.dart' ;
35
+ import '../evaluation_context.dart' ;
35
36
import '../exception.dart' ;
36
37
import '../extend/extension_store.dart' ;
37
38
import '../extend/extension.dart' ;
@@ -48,7 +49,6 @@ import '../syntax.dart';
48
49
import '../utils.dart' ;
49
50
import '../util/nullable.dart' ;
50
51
import '../value.dart' ;
51
- import '../warn.dart' ;
52
52
import 'interface/css.dart' ;
53
53
import 'interface/expression.dart' ;
54
54
import 'interface/modifiable_css.dart' ;
@@ -503,7 +503,7 @@ class _EvaluateVisitor
503
503
}
504
504
505
505
EvaluateResult run (Importer ? importer, Stylesheet node) {
506
- return _withWarnCallback ( node, () {
506
+ return withEvaluationContext ( _EvaluationContext ( this , node) , () {
507
507
var url = node.span.sourceUrl;
508
508
if (url != null ) {
509
509
_activeModules[url] = null ;
@@ -517,29 +517,17 @@ class _EvaluateVisitor
517
517
}
518
518
519
519
Value runExpression (Importer ? importer, Expression expression) =>
520
- _withWarnCallback (
521
- expression,
520
+ withEvaluationContext (
521
+ _EvaluationContext ( this , expression) ,
522
522
() => _withFakeStylesheet (
523
523
importer, expression, () => expression.accept (this )));
524
524
525
525
void runStatement (Importer ? importer, Statement statement) =>
526
- _withWarnCallback (
527
- statement,
526
+ withEvaluationContext (
527
+ _EvaluationContext ( this , statement) ,
528
528
() => _withFakeStylesheet (
529
529
importer, statement, () => statement.accept (this )));
530
530
531
- /// Runs [callback] with a definition for the top-level `warn` function.
532
- ///
533
- /// If no other span can be found to report a warning, falls back on
534
- /// [nodeWithSpan] 's.
535
- T _withWarnCallback <T >(AstNode nodeWithSpan, T callback ()) {
536
- return withWarnCallback (
537
- (message, deprecation) => _warn (
538
- message, _importSpan ?? _callableNode? .span ?? nodeWithSpan.span,
539
- deprecation: deprecation),
540
- callback);
541
- }
542
-
543
531
/// Asserts that [value] is not `null` and returns it.
544
532
///
545
533
/// This is used for fields that are set whenever the evaluator is evaluating
@@ -2573,8 +2561,7 @@ class _EvaluateVisitor
2573
2561
2574
2562
Value result;
2575
2563
try {
2576
- result = withCurrentCallableNode (
2577
- nodeWithSpan, () => callback (evaluated.positional));
2564
+ result = callback (evaluated.positional);
2578
2565
} on SassRuntimeException {
2579
2566
rethrow ;
2580
2567
} on MultiSpanSassScriptException catch (error) {
@@ -3403,6 +3390,34 @@ class _ImportedCssVisitor implements ModifiableCssVisitor<void> {
3403
3390
_visitor._addChild (node, through: (node) => node is CssStyleRule );
3404
3391
}
3405
3392
3393
+ /// An implementation of [EvaluationContext] using the information available in
3394
+ /// [_EvaluateVisitor] .
3395
+ class _EvaluationContext implements EvaluationContext {
3396
+ /// The visitor backing this context.
3397
+ final _EvaluateVisitor _visitor;
3398
+
3399
+ /// The AST node whose span should be used for [warn] if no other span is
3400
+ /// avaiable.
3401
+ final AstNode _defaultWarnNodeWithSpan;
3402
+
3403
+ _EvaluationContext (this ._visitor, this ._defaultWarnNodeWithSpan);
3404
+
3405
+ FileSpan get currentCallableSpan {
3406
+ var callableNode = _visitor._callableNode;
3407
+ if (callableNode != null ) return callableNode.span;
3408
+ throw StateError ("No Sass callable is currently being evaluated." );
3409
+ }
3410
+
3411
+ void warn (String message, {bool deprecation = false }) {
3412
+ _visitor._warn (
3413
+ message,
3414
+ _visitor._importSpan ??
3415
+ _visitor._callableNode? .span ??
3416
+ _defaultWarnNodeWithSpan.span,
3417
+ deprecation: deprecation);
3418
+ }
3419
+ }
3420
+
3406
3421
/// The result of evaluating arguments to a function or mixin.
3407
3422
class _ArgumentResults {
3408
3423
/// Arguments passed by position.
0 commit comments