mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-26 20:24:42 +01:00
Use ?[] instead of .andGet()
This commit is contained in:
parent
59b9dac236
commit
c2e02a50da
@ -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 = <String, ConfiguredValue>{};
|
||||
for (var i = 0; i < _variables.length; i++) {
|
||||
var values = _variables[i];
|
||||
var nodes = _variableNodes.andGet(i) ?? <String, AstNode>{};
|
||||
var nodes = _variableNodes?[i] ?? <String, AstNode>{};
|
||||
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.
|
||||
|
@ -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 = <String, ConfiguredValue>{};
|
||||
for (var i = 0; i < _variables.length; i++) {
|
||||
var values = _variables[i];
|
||||
var nodes = _variableNodes.andGet(i) ?? <String, AstNode>{};
|
||||
var nodes = _variableNodes?[i] ?? <String, AstNode>{};
|
||||
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.
|
||||
|
@ -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<K, V> extends MapBase<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
|
@ -13,26 +13,6 @@ extension NullableExtension<T> on T? {
|
||||
}
|
||||
}
|
||||
|
||||
extension NullableListExtension<T> on List<T>? {
|
||||
/// 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<K, V> on Map<K, V>? {
|
||||
/// 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<T> on Set<T?> {
|
||||
/// Destructively removes the `null` element from this set, if it exists, and
|
||||
/// returns a view of it casted to a non-nullable type.
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user