Skip to content

Commit fe23411

Browse files
committed
Rename IfExpression to LegacyIfExpression
1 parent 1d69beb commit fe23411

File tree

16 files changed

+35
-30
lines changed

16 files changed

+35
-30
lines changed

lib/src/ast/sass.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export 'sass/expression/binary_operation.dart';
1313
export 'sass/expression/boolean.dart';
1414
export 'sass/expression/color.dart';
1515
export 'sass/expression/function.dart';
16-
export 'sass/expression/if.dart';
1716
export 'sass/expression/interpolated_function.dart';
17+
export 'sass/expression/legacy_if.dart';
1818
export 'sass/expression/list.dart';
1919
export 'sass/expression/map.dart';
2020
export 'sass/expression/null.dart';

lib/src/ast/sass/expression/if.dart renamed to lib/src/ast/sass/expression/legacy_if.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import '../../../visitor/interface/expression.dart';
1414
/// evaluated.
1515
///
1616
/// {@category AST}
17-
final class IfExpression extends Expression implements CallableInvocation {
17+
final class LegacyIfExpression extends Expression
18+
implements CallableInvocation {
1819
/// The declaration of `if()`, as though it were a normal function.
1920
static final declaration = ParameterList.parse(
2021
r"@function if($condition, $if-true, $if-false) {",
@@ -25,9 +26,10 @@ final class IfExpression extends Expression implements CallableInvocation {
2526

2627
final FileSpan span;
2728

28-
IfExpression(this.arguments, this.span);
29+
LegacyIfExpression(this.arguments, this.span);
2930

30-
T accept<T>(ExpressionVisitor<T> visitor) => visitor.visitIfExpression(this);
31+
T accept<T>(ExpressionVisitor<T> visitor) =>
32+
visitor.visitLegacyIfExpression(this);
3133

3234
String toString() => "if$arguments";
3335
}

lib/src/functions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final List<BuiltInCallable> globalFunctions = UnmodifiableListView([
2929
...meta.global,
3030

3131
// This is only invoked using `call()`. Hand-authored `if()`s are parsed as
32-
// [IfExpression]s.
32+
// [LegacyIfExpression]s.
3333
BuiltInCallable.function(
3434
"if",
3535
r"$condition, $if-true, $if-false",

lib/src/functions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ built-in modules. Each of the files here exports a corresponding
1010
There are a few functions that Sass supports that aren't defined here:
1111

1212
* The `if()` function is defined directly in the [`functions.dart`] file,
13-
although in most cases this is actually parsed as an [`IfExpression`] and
13+
although in most cases this is actually parsed as a [`LegacyIfExpression`] and
1414
handled directly by [the evaluator] since it has special behavior about when
1515
its arguments are evaluated. The function itself only exists for edge cases
1616
like `if(...$args)` or `meta.get-function("if")`.
1717

1818
[`functions.dart`]: ../functions.dart
19-
[`IfExpression`]: ../ast/sass/expression/if.dart
19+
[`LegacyIfExpression`]: ../ast/sass/expression/legacy_if.dart
2020
[the evaluator]: ../visitor/async_evaluate.dart
2121

2222
* Certain functions in the `sass:meta` module require runtime information that's

lib/src/js/parser.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ void _updateAstPrototypes() {
144144
FunctionExpression('a', arguments, bogusSpan),
145145
).defineGetter('arguments', (FunctionExpression self) => self.arguments);
146146
getJSClass(
147-
IfExpression(arguments, bogusSpan),
148-
).defineGetter('arguments', (IfExpression self) => self.arguments);
147+
LegacyIfExpression(arguments, bogusSpan),
148+
).defineGetter('arguments', (LegacyIfExpression self) => self.arguments);
149149
getJSClass(
150150
InterpolatedFunctionExpression(_interpolation, arguments, bogusSpan),
151151
).defineGetter(

lib/src/js/visitor/expression.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class JSExpressionVisitor implements ExpressionVisitor<Object?> {
2525
_inner.visitInterpolatedFunctionExpression(node);
2626
Object? visitFunctionExpression(FunctionExpression node) =>
2727
_inner.visitFunctionExpression(node);
28-
Object? visitIfExpression(IfExpression node) =>
29-
_inner.visitIfExpression(node);
28+
Object? visitLegacyIfExpression(LegacyIfExpression node) =>
29+
_inner.visitLegacyIfExpression(node);
3030
Object? visitListExpression(ListExpression node) =>
3131
_inner.visitListExpression(node);
3232
Object? visitMapExpression(MapExpression node) =>
@@ -62,7 +62,7 @@ class JSExpressionVisitorObject {
6262
InterpolatedFunctionExpression node,
6363
);
6464
external Object? visitFunctionExpression(FunctionExpression node);
65-
external Object? visitIfExpression(IfExpression node);
65+
external Object? visitLegacyIfExpression(LegacyIfExpression node);
6666
external Object? visitListExpression(ListExpression node);
6767
external Object? visitMapExpression(MapExpression node);
6868
external Object? visitNullExpression(NullExpression node);

lib/src/parse/stylesheet.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2939,7 +2939,7 @@ abstract class StylesheetParser extends Parser {
29392939
if (plain != null) {
29402940
if (plain == "if" && scanner.peekChar() == $lparen) {
29412941
var invocation = _argumentInvocation();
2942-
return IfExpression(
2942+
return LegacyIfExpression(
29432943
invocation,
29442944
identifier.span.expand(invocation.span),
29452945
);

lib/src/visitor/ast_search.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ mixin AstSearchVisitor<T> on StatementSearchVisitor<T>
117117
T? visitInterpolatedFunctionExpression(InterpolatedFunctionExpression node) =>
118118
visitInterpolation(node.name) ?? visitArgumentList(node.arguments);
119119

120-
T? visitIfExpression(IfExpression node) => visitArgumentList(node.arguments);
120+
T? visitLegacyIfExpression(LegacyIfExpression node) =>
121+
visitArgumentList(node.arguments);
121122

122123
T? visitListExpression(ListExpression node) =>
123124
node.contents.search((item) => item.accept(this));

lib/src/visitor/async_evaluate.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,9 +2831,10 @@ final class _EvaluateVisitor
28312831
Future<SassBoolean> visitBooleanExpression(BooleanExpression node) async =>
28322832
SassBoolean(node.value);
28332833

2834-
Future<Value> visitIfExpression(IfExpression node) async {
2834+
Future<Value> visitLegacyIfExpression(LegacyIfExpression node) async {
28352835
var (positional, named) = await _evaluateMacroArguments(node);
2836-
_verifyArguments(positional.length, named, IfExpression.declaration, node);
2836+
_verifyArguments(
2837+
positional.length, named, LegacyIfExpression.declaration, node);
28372838

28382839
// ignore: prefer_is_empty
28392840
var condition = positional.elementAtOrNull(0) ?? named["condition"]!;
@@ -3204,7 +3205,7 @@ final class _EvaluateVisitor
32043205
case NumberExpression() ||
32053206
VariableExpression() ||
32063207
FunctionExpression() ||
3207-
IfExpression():
3208+
LegacyIfExpression():
32083209
return switch (await node.accept(this)) {
32093210
SassNumber result => result,
32103211
SassCalculation result => result,

lib/src/visitor/evaluate.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// DO NOT EDIT. This file was generated from async_evaluate.dart.
66
// See tool/grind/synchronize.dart for details.
77
//
8-
// Checksum: 979f29f32c16550e87b78d760d5958b9d2fbe451
8+
// Checksum: 72aeb044260f1f64f121280996c97a762b7313b0
99
//
1010
// ignore_for_file: unused_import
1111

@@ -2834,9 +2834,10 @@ final class _EvaluateVisitor
28342834
SassBoolean visitBooleanExpression(BooleanExpression node) =>
28352835
SassBoolean(node.value);
28362836

2837-
Value visitIfExpression(IfExpression node) {
2837+
Value visitLegacyIfExpression(LegacyIfExpression node) {
28382838
var (positional, named) = _evaluateMacroArguments(node);
2839-
_verifyArguments(positional.length, named, IfExpression.declaration, node);
2839+
_verifyArguments(
2840+
positional.length, named, LegacyIfExpression.declaration, node);
28402841

28412842
// ignore: prefer_is_empty
28422843
var condition = positional.elementAtOrNull(0) ?? named["condition"]!;
@@ -3205,7 +3206,7 @@ final class _EvaluateVisitor
32053206
case NumberExpression() ||
32063207
VariableExpression() ||
32073208
FunctionExpression() ||
3208-
IfExpression():
3209+
LegacyIfExpression():
32093210
return switch (node.accept(this)) {
32103211
SassNumber result => result,
32113212
SassCalculation result => result,

0 commit comments

Comments
 (0)