5
5
// DO NOT EDIT. This file was generated from async_import_cache.dart.
6
6
// See tool/grind/synchronize.dart for details.
7
7
//
8
- // Checksum: 8555cca43b8d54d392e81f33935fd379d1eb3c72
8
+ // Checksum: 3ca2f221c3c1503c688be49d4f7501bd9be8031a
9
9
//
10
10
// ignore_for_file: unused_import
11
11
@@ -16,6 +16,7 @@ import 'package:tuple/tuple.dart';
16
16
import 'ast/sass.dart' ;
17
17
import 'importer.dart' ;
18
18
import 'importer/result.dart' ;
19
+ import 'importer/utils.dart' ;
19
20
import 'io.dart' ;
20
21
import 'logger.dart' ;
21
22
import 'sync_package_resolver.dart' ;
@@ -31,11 +32,14 @@ class ImportCache {
31
32
32
33
/// The canonicalized URLs for each non-canonical URL.
33
34
///
35
+ /// The second item in each key's tuple is true when this canonicalization is
36
+ /// for an `@import` rule. Otherwise, it's for a `@use` or `@forward` rule.
37
+ ///
34
38
/// This map's values are the same as the return value of [canonicalize] .
35
39
///
36
40
/// This cache isn't used for relative imports, because they're
37
41
/// context-dependent.
38
- final Map <Uri , Tuple3 <Importer , Uri , Uri >> _canonicalizeCache;
42
+ final Map <Tuple2 < Uri , bool > , Tuple3 <Importer , Uri , Uri >> _canonicalizeCache;
39
43
40
44
/// The parsed stylesheets for each canonicalized import URL.
41
45
final Map <Uri , Stylesheet > _importCache;
@@ -114,18 +118,18 @@ class ImportCache {
114
118
/// If any importers understand [url] , returns that importer as well as the
115
119
/// canonicalized URL. Otherwise, returns `null` .
116
120
Tuple3 <Importer , Uri , Uri > canonicalize (Uri url,
117
- [ Importer baseImporter, Uri baseUrl] ) {
121
+ { Importer baseImporter, Uri baseUrl, bool forImport = false } ) {
118
122
if (baseImporter != null ) {
119
123
var resolvedUrl = baseUrl != null ? baseUrl.resolveUri (url) : url;
120
- var canonicalUrl = _canonicalize (baseImporter, resolvedUrl);
124
+ var canonicalUrl = _canonicalize (baseImporter, resolvedUrl, forImport );
121
125
if (canonicalUrl != null ) {
122
126
return Tuple3 (baseImporter, canonicalUrl, resolvedUrl);
123
127
}
124
128
}
125
129
126
- return _canonicalizeCache.putIfAbsent (url, () {
130
+ return _canonicalizeCache.putIfAbsent (Tuple2 ( url, forImport) , () {
127
131
for (var importer in _importers) {
128
- var canonicalUrl = _canonicalize (importer, url);
132
+ var canonicalUrl = _canonicalize (importer, url, forImport );
129
133
if (canonicalUrl != null ) {
130
134
return Tuple3 (importer, canonicalUrl, url);
131
135
}
@@ -137,8 +141,10 @@ class ImportCache {
137
141
138
142
/// Calls [importer.canonicalize] and prints a deprecation warning if it
139
143
/// returns a relative URL.
140
- Uri _canonicalize (Importer importer, Uri url) {
141
- var result = importer.canonicalize (url);
144
+ Uri _canonicalize (Importer importer, Uri url, bool forImport) {
145
+ var result = (forImport
146
+ ? inImportRule (() => importer.canonicalize (url))
147
+ : importer.canonicalize (url));
142
148
if (result? .scheme == '' ) {
143
149
_logger.warn ("""
144
150
Importer $importer canonicalized $url to $result .
@@ -158,8 +164,9 @@ Relative canonical URLs are deprecated and will eventually be disallowed.
158
164
///
159
165
/// Caches the result of the import and uses cached results if possible.
160
166
Tuple2 <Importer , Stylesheet > import (Uri url,
161
- [Importer baseImporter, Uri baseUrl]) {
162
- var tuple = canonicalize (url, baseImporter, baseUrl);
167
+ {Importer baseImporter, Uri baseUrl, bool forImport = false }) {
168
+ var tuple = canonicalize (url,
169
+ baseImporter: baseImporter, baseUrl: baseUrl, forImport: forImport);
163
170
if (tuple == null ) return null ;
164
171
var stylesheet = importCanonical (tuple.item1, tuple.item2, tuple.item3);
165
172
return Tuple2 (tuple.item1, stylesheet);
@@ -220,7 +227,8 @@ Relative canonical URLs are deprecated and will eventually be disallowed.
220
227
///
221
228
/// Has no effect if the canonical version of [url] has not been cached.
222
229
void clearCanonicalize (Uri url) {
223
- _canonicalizeCache.remove (url);
230
+ _canonicalizeCache.remove (Tuple2 (url, false ));
231
+ _canonicalizeCache.remove (Tuple2 (url, true ));
224
232
}
225
233
226
234
/// Clears the cached parse tree for the stylesheet with the given
0 commit comments