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 /// The set of absolute URIs with the `dart` scheme that should be skipped. |
| 285 /// We do this when we use SDK outline instead of compiling SDK sources. |
| 286 final Set<Uri> skipSdkLibraries = new Set<Uri>(); |
| 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 SDK outline. |
| 341 if (skipSdkLibraries.contains(absoluteUri)) { |
| 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 |