| 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;
|
| + }
|
| }
|
|
|