5
5
// DO NOT EDIT. This file was generated from async_environment.dart.
6
6
// See tool/grind/synchronize.dart for details.
7
7
//
8
- // Checksum: add8a3972aec53ef29de3639af2bc84edcbde9e7
8
+ // Checksum: 72b802e4004aae8a84f7aa78ec728861339b846b
9
9
//
10
10
// ignore_for_file: unused_import
11
11
@@ -128,6 +128,10 @@ final class Environment {
128
128
UserDefinedCallable <Environment >? get content => _content;
129
129
UserDefinedCallable <Environment >? _content;
130
130
131
+ /// The set of variable names that could be configured when loading the
132
+ /// module.
133
+ final Set <String > _configurableVariables;
134
+
131
135
/// Whether the environment is lexically at the root of the document.
132
136
bool get atRoot => _variables.length == 1 ;
133
137
@@ -167,27 +171,28 @@ final class Environment {
167
171
_functions = [{}],
168
172
_functionIndices = {},
169
173
_mixins = [{}],
170
- _mixinIndices = {};
174
+ _mixinIndices = {},
175
+ _configurableVariables = {};
171
176
172
177
Environment ._(
173
- this ._modules,
174
- this ._namespaceNodes,
175
- this ._globalModules,
176
- this ._importedModules,
177
- this ._forwardedModules,
178
- this ._nestedForwardedModules,
179
- this ._allModules,
180
- this ._variables,
181
- this ._variableNodes,
182
- this ._functions,
183
- this ._mixins,
184
- this ._content,
185
- )
186
- // Lazily fill in the indices rather than eagerly copying them from the
187
- // existing environment in closure() because the copying took a lot of
188
- // time and was rarely helpful. This saves a bunch of time on Susy's
189
- // tests.
190
- : _variableIndices = {},
178
+ this ._modules,
179
+ this ._namespaceNodes,
180
+ this ._globalModules,
181
+ this ._importedModules,
182
+ this ._forwardedModules,
183
+ this ._nestedForwardedModules,
184
+ this ._allModules,
185
+ this ._variables,
186
+ this ._variableNodes,
187
+ this ._functions,
188
+ this ._mixins,
189
+ this ._content,
190
+ this ._configurableVariables)
191
+ // Lazily fill in the indices rather than eagerly copying them from the
192
+ // existing environment in closure() because the copying took a lot of
193
+ // time and was rarely helpful. This saves a bunch of time on Susy's
194
+ // tests.
195
+ : _variableIndices = {},
191
196
_functionIndices = {},
192
197
_mixinIndices = {};
193
198
@@ -209,6 +214,9 @@ final class Environment {
209
214
_functions.toList (),
210
215
_mixins.toList (),
211
216
_content,
217
+ // Closures are always in nested contexts where configurable variables
218
+ // are never added.
219
+ const {},
212
220
);
213
221
214
222
/// Returns a new environment to use for an imported file.
@@ -229,6 +237,7 @@ final class Environment {
229
237
_functions.toList (),
230
238
_mixins.toList (),
231
239
_content,
240
+ _configurableVariables,
232
241
);
233
242
234
243
/// Adds [module] to the set of modules visible in this environment.
@@ -648,6 +657,15 @@ final class Environment {
648
657
_variableNodes[index][name] = nodeWithSpan;
649
658
}
650
659
660
+ /// Records that [name] is a variable that could have been configured for this
661
+ /// module, whether or not it actually was.
662
+ ///
663
+ /// This is used to determine whether to throw an error when passing a new
664
+ /// configuration through `@forward` to an already-loaded module.
665
+ void markVariableConfigurable (String name) {
666
+ _configurableVariables.add (name);
667
+ }
668
+
651
669
/// Returns the value of the function named [name] , optionally with the given
652
670
/// [namespace] , or `null` if no such variable is declared.
653
671
///
@@ -1080,6 +1098,26 @@ final class _EnvironmentModule implements Module<Callable> {
1080
1098
return module == null ? this : module.variableIdentity (name);
1081
1099
}
1082
1100
1101
+ bool couldHaveBeenConfigured (Set <String > variables) =>
1102
+ // Check if this module defines a configurable variable with any of the
1103
+ // given names.
1104
+ (variables.length < _environment._configurableVariables.length
1105
+ ? variables.any (_environment._configurableVariables.contains)
1106
+ : _environment._configurableVariables.any (variables.contains)) ||
1107
+ // Find forwarded modules whose variables overlap with [variables] and
1108
+ // check if they define configurable variables with any of the given
1109
+ // names.
1110
+ (variables.length < _modulesByVariable.length
1111
+ ? {
1112
+ for (var variable in variables)
1113
+ if (_modulesByVariable[variable] case var module? ) module
1114
+ }
1115
+ : {
1116
+ for (var (variable, module) in _modulesByVariable.pairs)
1117
+ if (variables.contains (variable)) module
1118
+ })
1119
+ .any ((module) => module.couldHaveBeenConfigured (variables));
1120
+
1083
1121
Module <Callable > cloneCss () {
1084
1122
if (! transitivelyContainsCss) return this ;
1085
1123
0 commit comments