diff --git a/lib/src/async_environment.dart b/lib/src/async_environment.dart index 3f03344ea..5c1b2d33b 100644 --- a/lib/src/async_environment.dart +++ b/lib/src/async_environment.dart @@ -314,7 +314,7 @@ class AsyncEnvironment { } if (type == "variable") name = "\$$name"; - var span = _forwardedModuleNodes.andGet(oldModule)?.span; + var span = _forwardedModuleNodes?[oldModule]?.span; throw MultiSpanSassScriptException( 'Two forwarded modules both define a $type named $name.', "new @forward", @@ -617,7 +617,7 @@ class AsyncEnvironment { _lastVariableName = name; _lastVariableIndex = index; _variables[index][name] = value; - _variableNodes?.andGet(index)![name] = nodeWithSpan!; + _variableNodes?[index][name] = nodeWithSpan!; } /// Sets the variable named [name] to [value], associated with @@ -636,7 +636,7 @@ class AsyncEnvironment { _variableIndices[name] = index; _variables[index][name] = value; if (nodeWithSpan != null) { - _variableNodes?.andGet(index)![name] = nodeWithSpan; + _variableNodes?[index][name] = nodeWithSpan; } } @@ -818,7 +818,7 @@ class AsyncEnvironment { var configuration = {}; for (var i = 0; i < _variables.length; i++) { var values = _variables[i]; - var nodes = _variableNodes.andGet(i) ?? {}; + var nodes = _variableNodes?[i] ?? {}; for (var entry in values.entries) { // Implicit configurations are never invalid, making [configurationSpan] // unnecessary, so we pass null here to avoid having to compute it. diff --git a/lib/src/environment.dart b/lib/src/environment.dart index b120e0511..da4910951 100644 --- a/lib/src/environment.dart +++ b/lib/src/environment.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_environment.dart. // See tool/grind/synchronize.dart for details. // -// Checksum: 1ef0f32701764f4b160ef045ca162b38653e0504 +// Checksum: bb0b47fc04e32f36a0f87dc73bdfe3f89dc51aa4 // // ignore_for_file: unused_import @@ -322,7 +322,7 @@ class Environment { } if (type == "variable") name = "\$$name"; - var span = _forwardedModuleNodes.andGet(oldModule)?.span; + var span = _forwardedModuleNodes?[oldModule]?.span; throw MultiSpanSassScriptException( 'Two forwarded modules both define a $type named $name.', "new @forward", @@ -625,7 +625,7 @@ class Environment { _lastVariableName = name; _lastVariableIndex = index; _variables[index][name] = value; - _variableNodes?.andGet(index)![name] = nodeWithSpan!; + _variableNodes?[index][name] = nodeWithSpan!; } /// Sets the variable named [name] to [value], associated with @@ -644,7 +644,7 @@ class Environment { _variableIndices[name] = index; _variables[index][name] = value; if (nodeWithSpan != null) { - _variableNodes?.andGet(index)![name] = nodeWithSpan; + _variableNodes?[index][name] = nodeWithSpan; } } @@ -824,7 +824,7 @@ class Environment { var configuration = {}; for (var i = 0; i < _variables.length; i++) { var values = _variables[i]; - var nodes = _variableNodes.andGet(i) ?? {}; + var nodes = _variableNodes?[i] ?? {}; for (var entry in values.entries) { // Implicit configurations are never invalid, making [configurationSpan] // unnecessary, so we pass null here to avoid having to compute it. diff --git a/lib/src/util/merged_map_view.dart b/lib/src/util/merged_map_view.dart index b84f6ad51..df749871f 100644 --- a/lib/src/util/merged_map_view.dart +++ b/lib/src/util/merged_map_view.dart @@ -5,8 +5,6 @@ import 'dart:collection'; import '../utils.dart'; -import '../util/nullable.dart'; -import 'nullable.dart'; /// An unmodifiable view of multiple maps merged together as though they were a /// single map. @@ -46,7 +44,7 @@ class MergedMapView extends MapBase { } } - V? operator [](Object? key) => _mapsByKey[key as K].andGet(key); + V? operator [](Object? key) => _mapsByKey[key as K]?[key]; operator []=(K key, V value) { var child = _mapsByKey[key]; diff --git a/lib/src/util/nullable.dart b/lib/src/util/nullable.dart index 7d1511dc8..f5bf6258c 100644 --- a/lib/src/util/nullable.dart +++ b/lib/src/util/nullable.dart @@ -13,26 +13,6 @@ extension NullableExtension on T? { } } -extension NullableListExtension on List? { - /// If [this] is `null`, returns `null`. Otherwise, returns `this[index]`. - /// - /// This is the equivalent of `list?.[key]`, if such a thing existed. - T? andGet(int index) { - var self = this; - return self == null ? null : self[index]; - } -} - -extension NullableMapExtension on Map? { - /// If [this] is `null`, returns `null`. Otherwise, returns `this[key]`. - /// - /// This is the equivalent of `map?.[key]`, if such a thing existed. - V? andGet(Object? key) { - var self = this; - return self == null ? null : self[key]; - } -} - extension SetExtension on Set { /// Destructively removes the `null` element from this set, if it exists, and /// returns a view of it casted to a non-nullable type. diff --git a/lib/src/visitor/async_evaluate.dart b/lib/src/visitor/async_evaluate.dart index 0cac6b70b..83b910270 100644 --- a/lib/src/visitor/async_evaluate.dart +++ b/lib/src/visitor/async_evaluate.dart @@ -2219,7 +2219,7 @@ class _EvaluateVisitor _environment.setLocalVariable( declaredArguments[i].name, evaluated.positional[i].withoutSlash(), - evaluated.positionalNodes.andGet(i)); + evaluated.positionalNodes?[i]); } for (var i = evaluated.positional.length; @@ -2231,7 +2231,7 @@ class _EvaluateVisitor _environment.setLocalVariable( argument.name, value.withoutSlash(), - evaluated.namedNodes.andGet(argument.name) ?? + evaluated.namedNodes?[argument.name] ?? argument.defaultValue.andThen(_expressionNode)); } diff --git a/lib/src/visitor/evaluate.dart b/lib/src/visitor/evaluate.dart index 3b8bce68a..dc2b70566 100644 --- a/lib/src/visitor/evaluate.dart +++ b/lib/src/visitor/evaluate.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_evaluate.dart. // See tool/grind/synchronize.dart for details. // -// Checksum: 01a7ae41ae622e64443597ea82b27b7aeb73d260 +// Checksum: 6b82405fdc448ac69ca703bc6bffbb8d50f3fced // // ignore_for_file: unused_import @@ -2206,7 +2206,7 @@ class _EvaluateVisitor _environment.setLocalVariable( declaredArguments[i].name, evaluated.positional[i].withoutSlash(), - evaluated.positionalNodes.andGet(i)); + evaluated.positionalNodes?[i]); } for (var i = evaluated.positional.length; @@ -2218,7 +2218,7 @@ class _EvaluateVisitor _environment.setLocalVariable( argument.name, value.withoutSlash(), - evaluated.namedNodes.andGet(argument.name) ?? + evaluated.namedNodes?[argument.name] ?? argument.defaultValue.andThen(_expressionNode)); }