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

Unified Diff: pkg/analyzer/lib/src/context/builder.dart

Issue 2681153002: Possible fix for 28038 (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/builder_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/builder.dart
diff --git a/pkg/analyzer/lib/src/context/builder.dart b/pkg/analyzer/lib/src/context/builder.dart
index 98e5effaff71de30dbb70cd8291fb9affb69127d..fe6f5c3db81a532b6cd4d621eb3704e0298ba167 100644
--- a/pkg/analyzer/lib/src/context/builder.dart
+++ b/pkg/analyzer/lib/src/context/builder.dart
@@ -252,6 +252,11 @@ class ContextBuilder {
}
Workspace createWorkspace(String rootPath) {
+ if (_hasPackageFileInPath(rootPath)) {
+ // Bazel workspaces that include package files are treated like normal
+ // (non-Bazel) directories.
+ return _BasicWorkspace.find(resourceProvider, rootPath, this);
+ }
Workspace workspace = BazelWorkspace.find(resourceProvider, rootPath);
workspace ??= GnWorkspace.find(resourceProvider, rootPath);
return workspace ?? _BasicWorkspace.find(resourceProvider, rootPath, this);
@@ -553,6 +558,22 @@ class ContextBuilder {
}
return null;
}
+
+ /**
+ * Return `true` if either the directory at [rootPath] or a parent of that
+ * directory contains a `.packages` file.
+ */
+ bool _hasPackageFileInPath(String rootPath) {
+ Folder folder = resourceProvider.getFolder(rootPath);
+ while (folder != null) {
+ File file = folder.getChildAssumingFile('.packages');
+ if (file.exists) {
+ return true;
+ }
+ folder = folder.parent;
+ }
+ return false;
+ }
}
/**
@@ -736,15 +757,15 @@ class _BasicWorkspace extends Workspace {
_BasicWorkspace._(this.provider, this.root, this._builder);
@override
+ // Alternately, we could check the pubspec for "sdk: flutter"
+ bool get hasFlutterDependency => packageMap.containsKey('flutter');
+
+ @override
Map<String, List<Folder>> get packageMap {
_packageMap ??= _builder.convertPackagesToMap(packages);
return _packageMap;
}
- @override
- // Alternately, we could check the pubspec for "sdk: flutter"
- bool get hasFlutterDependency => packageMap.containsKey('flutter');
-
Packages get packages {
_packages ??= _builder.createPackageMap(root);
return _packages;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698