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:typed_data'; | 6 import 'dart:typed_data'; |
7 | 7 |
8 import 'package:crypto/crypto.dart'; | 8 import 'package:crypto/crypto.dart'; |
9 import 'package:front_end/file_system.dart'; | 9 import 'package:front_end/file_system.dart'; |
10 import 'package:front_end/src/base/resolve_relative_uri.dart'; | 10 import 'package:front_end/src/base/resolve_relative_uri.dart'; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 /// Information about known file system state. | 217 /// Information about known file system state. |
218 class FileSystemState { | 218 class FileSystemState { |
219 final FileSystem fileSystem; | 219 final FileSystem fileSystem; |
220 final TranslateUri uriTranslator; | 220 final TranslateUri uriTranslator; |
221 | 221 |
222 _FileSystemView _fileSystemView; | 222 _FileSystemView _fileSystemView; |
223 | 223 |
224 /// Mapping from file URIs to corresponding [FileState]s. | 224 /// Mapping from import URIs to corresponding [FileState]s. For example, this |
| 225 /// may contain an entry for `dart:core`. |
225 final Map<Uri, FileState> _uriToFile = {}; | 226 final Map<Uri, FileState> _uriToFile = {}; |
226 | 227 |
227 /// Mapping from file URIs to corresponding [FileState]s. | 228 /// Mapping from file URIs to corresponding [FileState]s. This map should only |
| 229 /// contain `file:*` URIs as keys. |
228 final Map<Uri, FileState> _fileUriToFile = {}; | 230 final Map<Uri, FileState> _fileUriToFile = {}; |
229 | 231 |
230 FileSystemState(this.fileSystem, this.uriTranslator); | 232 FileSystemState(this.fileSystem, this.uriTranslator); |
231 | 233 |
232 /// Return the [FileSystem] that is backed by this [FileSystemState]. The | 234 /// Return the [FileSystem] that is backed by this [FileSystemState]. The |
233 /// files in this [FileSystem] always have the same content as the | 235 /// files in this [FileSystem] always have the same content as the |
234 /// corresponding [FileState]s, thus avoiding race conditions when a file | 236 /// corresponding [FileState]s, thus avoiding race conditions when a file |
235 /// is updated on the actual file system. | 237 /// is updated on the actual file system. |
236 FileSystem get fileSystemView { | 238 FileSystem get fileSystemView { |
237 return _fileSystemView ??= new _FileSystemView(this); | 239 return _fileSystemView ??= new _FileSystemView(this); |
238 } | 240 } |
239 | 241 |
| 242 /// The `file:` URI of all files currently tracked by this instance. |
| 243 Iterable<Uri> get fileUris => _fileUriToFile.keys; |
| 244 |
240 /// Return the [FileState] for the given [absoluteUri], or `null` if the | 245 /// Return the [FileState] for the given [absoluteUri], or `null` if the |
241 /// [absoluteUri] cannot be resolved into a file URI. | 246 /// [absoluteUri] cannot be resolved into a file URI. |
242 /// | 247 /// |
243 /// The returned file has the last known state since it was last refreshed. | 248 /// The returned file has the last known state since it was last refreshed. |
244 Future<FileState> getFile(Uri absoluteUri) async { | 249 Future<FileState> getFile(Uri absoluteUri) async { |
245 // Resolve the absolute URI into the absolute file URI. | 250 // Resolve the absolute URI into the absolute file URI. |
246 Uri fileUri; | 251 Uri fileUri; |
247 if (absoluteUri.isScheme('file')) { | 252 if (absoluteUri.isScheme('file')) { |
248 fileUri = absoluteUri; | 253 fileUri = absoluteUri; |
249 } else { | 254 } else { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 node.isEvaluated = true; | 403 node.isEvaluated = true; |
399 cycle.libraries.add(node.file); | 404 cycle.libraries.add(node.file); |
400 } | 405 } |
401 topologicallySortedCycles.add(cycle); | 406 topologicallySortedCycles.add(cycle); |
402 } | 407 } |
403 | 408 |
404 _LibraryNode getNode(FileState file) { | 409 _LibraryNode getNode(FileState file) { |
405 return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file)); | 410 return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file)); |
406 } | 411 } |
407 } | 412 } |
OLD | NEW |