Index: pkg/analyzer/lib/src/dart/analysis/file_state.dart |
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart |
index 7ab09c13f5d48125d2f2169a04b6ff344f68d020..ecb8b6750ef275fe40cfdac21dab185d14876168 100644 |
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart |
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart |
@@ -548,6 +548,11 @@ class FileSystemState { |
final Map<Uri, FileState> _uriToFile = {}; |
/** |
+ * All known file paths. |
+ */ |
+ final Set<String> knownFilePaths = new Set<String>(); |
+ |
+ /** |
* Mapping from a path to the corresponding [FileState]s, canonical or not. |
*/ |
final Map<String, List<FileState>> _pathToFiles = {}; |
@@ -577,11 +582,6 @@ class FileSystemState { |
} |
/** |
- * Return the set of known file paths. |
- */ |
- Set<String> get knownFilePaths => _pathToFiles.keys.toSet(); |
- |
- /** |
* Return the known files. |
*/ |
Iterable<FileState> get knownFiles => |
@@ -614,7 +614,7 @@ class FileSystemState { |
FileSource uriSource = new FileSource(resource, uri); |
file = new FileState._(this, path, uri, uriSource); |
_uriToFile[uri] = file; |
- _pathToFiles.putIfAbsent(path, () => <FileState>[]).add(file); |
+ _addFileWithPath(path, file); |
_pathToCanonicalFile[path] = file; |
file.refresh(); |
} |
@@ -640,7 +640,7 @@ class FileSystemState { |
FileSource source = new FileSource(resource, uri); |
file = new FileState._(this, path, uri, source); |
_uriToFile[uri] = file; |
- _pathToFiles.putIfAbsent(path, () => <FileState>[]).add(file); |
+ _addFileWithPath(path, file); |
file.refresh(); |
} |
return file; |
@@ -660,6 +660,16 @@ class FileSystemState { |
..remove(canonicalFile) |
..insert(0, canonicalFile); |
} |
+ |
+ void _addFileWithPath(String path, FileState file) { |
+ var files = _pathToFiles[path]; |
+ if (files == null) { |
+ knownFilePaths.add(path); |
+ files = <FileState>[]; |
+ _pathToFiles[path] = files; |
+ } |
+ files.add(file); |
+ } |
} |
@visibleForTesting |