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

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

Issue 2654303003: Ignore files that are hidden by generated files. (Closed)
Patch Set: Created 3 years, 11 months 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
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 eeb734a69a7cc3b2254d3a03ad2c2fa4fd4b77c8..542d032164269820601aca47ae91026e2bd365e8 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -540,6 +540,11 @@ class FileSystemState {
final Set<String> knownFilePaths = new Set<String>();
/**
+ * Mapping from a path to the flag whether there is a URI for the path.
+ */
+ final Map<String, bool> _hasUriForPath = {};
+
+ /**
* Mapping from a path to the corresponding [FileState]s, canonical or not.
*/
final Map<String, List<FileState>> _pathToFiles = {};
@@ -592,7 +597,7 @@ class FileSystemState {
// Try to get the existing instance.
file = _uriToFile[uri];
// If we have a file, call it the canonical one and return it.
- if (file != null && file.path == path) {
+ if (file != null) {
_pathToCanonicalFile[path] = file;
return file;
}
@@ -648,6 +653,26 @@ class FileSystemState {
}
/**
+ * Return `true` if there is a URI that can be resolved to the [path].
+ *
+ * When a file exists, but for the URI that corresponds to the file is
+ * resolved to another file, e.g. a generated one in Bazel, Gn, etc, we
+ * cannot analyze the original file.
+ */
+ bool hasUri(String path) {
+ bool flag = _hasUriForPath[path];
+ if (flag == null) {
+ File resource = _resourceProvider.getFile(path);
+ Source fileSource = resource.createSource();
+ Uri uri = _sourceFactory.restoreUri(fileSource);
+ Source uriSource = _sourceFactory.forUri2(uri);
+ flag = uriSource.fullName == path;
+ _hasUriForPath[path] = flag;
+ }
+ return flag;
+ }
+
+ /**
* Remove the file with the given [path].
*/
void removeFile(String path) {

Powered by Google App Engine
This is Rietveld 408576698