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

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

Issue 2044383003: Issue 26639. Set source for mock 'dart:async' library. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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/lib/src/task/dart.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/context.dart
diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart
index 6ad3363fec5d920014a2ba6a09dec04e87d625df..59c94c4f30cebb76df26f24cd4fa7e33730b02da 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -487,6 +487,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (coreElement == null) {
throw new AnalysisException("Could not create an element for dart:core");
}
+
LibraryElement asyncElement;
if (analysisOptions.enableAsync) {
Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
@@ -499,8 +500,10 @@ class AnalysisContextImpl implements InternalAnalysisContext {
"Could not create an element for dart:async");
}
} else {
- asyncElement = createMockAsyncLib(coreElement);
+ Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
+ asyncElement = createMockAsyncLib(coreElement, asyncSource);
}
+
_typeProvider = new TypeProviderImpl(coreElement, asyncElement);
return _typeProvider;
}
@@ -725,7 +728,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
* to stand in for a real one if one does not exist
* facilitating creation a type provider without dart:async.
*/
- LibraryElement createMockAsyncLib(LibraryElement coreLibrary) {
+ LibraryElement createMockAsyncLib(LibraryElement coreLibrary, Source asyncSource) {
InterfaceType objType = coreLibrary.getType('Object').type;
ClassElement _classElement(String typeName, [List<String> parameterNames]) {
@@ -760,6 +763,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
asyncUnit.types = <ClassElement>[futureType.element, streamType.element];
LibraryElementImpl mockLib = new LibraryElementImpl.forNode(
this, AstFactory.libraryIdentifier2(["dart.async"]));
+ asyncUnit.librarySource = asyncSource;
+ asyncUnit.source = asyncSource;
mockLib.definingCompilationUnit = asyncUnit;
mockLib.publicNamespace =
new NamespaceBuilder().createPublicNamespaceForLibrary(mockLib);
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698