OLD | NEW |
---|---|
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
8 | 8 |
9 import 'package:convert/convert.dart'; | 9 import 'package:convert/convert.dart'; |
10 import 'package:crypto/crypto.dart'; | 10 import 'package:crypto/crypto.dart'; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 _FileSystemView _fileSystemView; | 274 _FileSystemView _fileSystemView; |
275 | 275 |
276 /// Mapping from import URIs to corresponding [FileState]s. For example, this | 276 /// Mapping from import URIs to corresponding [FileState]s. For example, this |
277 /// may contain an entry for `dart:core`. | 277 /// may contain an entry for `dart:core`. |
278 final Map<Uri, FileState> _uriToFile = {}; | 278 final Map<Uri, FileState> _uriToFile = {}; |
279 | 279 |
280 /// Mapping from file URIs to corresponding [FileState]s. This map should only | 280 /// Mapping from file URIs to corresponding [FileState]s. This map should only |
281 /// contain `file:*` URIs as keys. | 281 /// contain `file:*` URIs as keys. |
282 final Map<Uri, FileState> _fileUriToFile = {}; | 282 final Map<Uri, FileState> _fileUriToFile = {}; |
283 | 283 |
284 /// If `true`, then files with the `dart` scheme should be skipped. | |
285 /// We do this when we use SDK outline instead of compiling SDK sources. | |
286 bool skipSdkLibraries = false; | |
287 | |
284 FileSystemState(this._byteStore, this.fileSystem, this.uriTranslator, | 288 FileSystemState(this._byteStore, this.fileSystem, this.uriTranslator, |
285 this._salt, this._newFileFn); | 289 this._salt, this._newFileFn); |
286 | 290 |
287 /// Return the [FileSystem] that is backed by this [FileSystemState]. The | 291 /// Return the [FileSystem] that is backed by this [FileSystemState]. The |
288 /// files in this [FileSystem] always have the same content as the | 292 /// files in this [FileSystem] always have the same content as the |
289 /// corresponding [FileState]s, thus avoiding race conditions when a file | 293 /// corresponding [FileState]s, thus avoiding race conditions when a file |
290 /// is updated on the actual file system. | 294 /// is updated on the actual file system. |
291 FileSystem get fileSystemView { | 295 FileSystem get fileSystemView { |
292 return _fileSystemView ??= new _FileSystemView(this); | 296 return _fileSystemView ??= new _FileSystemView(this); |
293 } | 297 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 urisToRemove.forEach(_uriToFile.remove); | 330 urisToRemove.forEach(_uriToFile.remove); |
327 fileUrisToRemove.forEach(_fileUriToFile.remove); | 331 fileUrisToRemove.forEach(_fileUriToFile.remove); |
328 return filesToRemove; | 332 return filesToRemove; |
329 } | 333 } |
330 | 334 |
331 /// Return the [FileState] for the given [absoluteUri], or `null` if the | 335 /// Return the [FileState] for the given [absoluteUri], or `null` if the |
332 /// [absoluteUri] cannot be resolved into a file URI. | 336 /// [absoluteUri] cannot be resolved into a file URI. |
333 /// | 337 /// |
334 /// The returned file has the last known state since it was last refreshed. | 338 /// The returned file has the last known state since it was last refreshed. |
335 Future<FileState> getFile(Uri absoluteUri) async { | 339 Future<FileState> getFile(Uri absoluteUri) async { |
340 // We don't need to process SDK libraries if we have SK outline. | |
Siggi Cherem (dart-lang)
2017/08/05 03:22:47
nit: "SK" => "an SDK"
scheglov
2017/08/06 21:04:06
Done.
| |
341 if (skipSdkLibraries && absoluteUri.isScheme('dart')) { | |
Siggi Cherem (dart-lang)
2017/08/05 03:22:47
rather than skipping any `dart:*` library, could w
scheglov
2017/08/06 21:04:06
I'm adding TODO for now.
aam
2017/08/07 14:41:34
Good point! Yes, it seems it won't work with how v
Siggi Cherem (dart-lang)
2017/08/07 15:29:52
Konstantin: I was thinking more about this over th
aam
2017/08/07 15:42:11
Ah, true, I don't see patch_sdk.dart using increme
scheglov
2017/08/07 15:51:25
The first problem is that we need to make sure tha
scheglov
2017/08/07 15:51:25
So, is there still a reason to change the way `dar
aam
2017/08/07 16:04:38
Not sure, about short term, but in long term, to m
Siggi Cherem (dart-lang)
2017/08/07 16:27:42
So basically we need ProcessedOptions to expose th
| |
342 return null; | |
343 } | |
344 | |
336 // Resolve the absolute URI into the absolute file URI. | 345 // Resolve the absolute URI into the absolute file URI. |
337 Uri fileUri; | 346 Uri fileUri; |
338 if (absoluteUri.isScheme('file')) { | 347 if (absoluteUri.isScheme('file')) { |
339 fileUri = absoluteUri; | 348 fileUri = absoluteUri; |
340 } else { | 349 } else { |
341 fileUri = uriTranslator.translate(absoluteUri); | 350 fileUri = uriTranslator.translate(absoluteUri); |
342 if (fileUri == null) return null; | 351 if (fileUri == null) return null; |
343 } | 352 } |
344 | 353 |
345 FileState file = _uriToFile[absoluteUri]; | 354 FileState file = _uriToFile[absoluteUri]; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 cycle.libraries.add(node.file); | 520 cycle.libraries.add(node.file); |
512 fileToCycleMap[node.file] = cycle; | 521 fileToCycleMap[node.file] = cycle; |
513 } | 522 } |
514 topologicallySortedCycles.add(cycle); | 523 topologicallySortedCycles.add(cycle); |
515 } | 524 } |
516 | 525 |
517 _LibraryNode getNode(FileState file) { | 526 _LibraryNode getNode(FileState file) { |
518 return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file)); | 527 return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file)); |
519 } | 528 } |
520 } | 529 } |
OLD | NEW |