Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: pkg/analyzer/lib/src/dart/analysis/file_state.dart

Issue 2561933002: Manage known file paths set in FileSystemState. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698