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

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

Issue 27278004: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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_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 2104617c3b789c58759d34ac15683dca9f661e96..c7beef72ad41fd5a5b415b05dd0d889cf8f85b46 100644
--- a/pkg/analyzer_experimental/lib/src/analyzer_impl.dart
+++ b/pkg/analyzer_experimental/lib/src/analyzer_impl.dart
@@ -48,7 +48,8 @@ class AnalyzerImpl {
throw new ArgumentError("sourcePath cannot be null");
}
var sourceFile = new JavaFile(sourcePath);
- var librarySource = new FileBasedSource.con1(contentCache, sourceFile);
+ var uriKind = getUriKind(sourceFile);
+ var librarySource = new FileBasedSource.con2(contentCache, sourceFile, uriKind);
// resolve library
prepareAnalysisContext(sourceFile);
var libraryElement = context.computeLibraryElement(librarySource);
@@ -89,6 +90,7 @@ class AnalyzerImpl {
// set options for context
AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl();
+ contextOptions.cacheSize = 256;
contextOptions.hint = !options.disableHints;
context.analysisOptions = contextOptions;
}
@@ -165,4 +167,22 @@ class AnalyzerImpl {
// not found
return null;
}
+
+ /**
+ * Returns the [UriKind] for the given input file. Usually {@link UriKind#FILE_URI}, but if
+ * the given file is located in the "lib" directory of the [sdk], then returns
+ * {@link UriKind#DART_URI}.
+ */
+ static UriKind getUriKind(JavaFile file) {
+ // may be file in SDK
+ if (sdk is DirectoryBasedDartSdk) {
+ DirectoryBasedDartSdk directoryBasedSdk = sdk;
+ String sdkLibPath = directoryBasedSdk.libraryDirectory.getPath() + JavaFile.separator;
+ if (file.getPath().startsWith(sdkLibPath)) {
+ return UriKind.DART_URI;
+ }
+ }
+ // some generic file
+ return UriKind.FILE_URI;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698