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

Unified Diff: pkg/analyzer_experimental/lib/src/analyzer_impl.dart

Issue 15780010: Issue 10871. Fix for analyzing file without absolute path (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « pkg/analyzer_experimental/lib/options.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_experimental/lib/src/analyzer_impl.dart
diff --git a/pkg/analyzer_experimental/lib/src/analyzer_impl.dart b/pkg/analyzer_experimental/lib/src/analyzer_impl.dart
index 40b8deb3cba517f9dfd1c8ac4a883b4155922b0c..84cfb8dc34358ccf1bcb0337924237e0366f8f43 100644
--- a/pkg/analyzer_experimental/lib/src/analyzer_impl.dart
+++ b/pkg/analyzer_experimental/lib/src/analyzer_impl.dart
@@ -71,7 +71,12 @@ class AnalyzerImpl {
List<UriResolver> resolvers = [new DartUriResolver(sdk), new FileUriResolver()];
// may be add package resolver
{
- var packageDirectory = getPackageDirectoryFor(sourceFile);
+ JavaFile packageDirectory;
+ if (options.packageRootPath != null) {
+ packageDirectory = new JavaFile(options.packageRootPath);
+ } else {
+ packageDirectory = getPackageDirectoryFor(sourceFile);
+ }
if (packageDirectory != null) {
resolvers.add(new PackageUriResolver([packageDirectory]));
}
@@ -138,11 +143,18 @@ class AnalyzerImpl {
}
static JavaFile getPackageDirectoryFor(JavaFile sourceFile) {
- JavaFile sourceFolder = sourceFile.getParentFile();
- JavaFile packagesFolder = new JavaFile.relative(sourceFolder, "packages");
- if (packagesFolder.exists()) {
- return packagesFolder;
+ // we are going to ask parent file, so get absolute path
+ sourceFile = sourceFile.getAbsoluteFile();
+ // look in the containing directories
+ JavaFile dir = sourceFile.getParentFile();
+ while (dir != null) {
+ JavaFile packagesDir = new JavaFile.relative(dir, "packages");
+ if (packagesDir.exists()) {
+ return packagesDir;
+ }
+ dir = dir.getParentFile();
}
+ // not found
return null;
}
}
« no previous file with comments | « pkg/analyzer_experimental/lib/options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698