Index: pkg/analyzer/lib/src/generated/testing/test_type_provider.dart |
diff --git a/pkg/analyzer/lib/src/generated/testing/test_type_provider.dart b/pkg/analyzer/lib/src/generated/testing/test_type_provider.dart |
index cb70a5333183e6f887d0a72c26e7c67546f1b6c5..3e8ceb4a1d08cff6fe012b1caaf0741f82f2d719 100644 |
--- a/pkg/analyzer/lib/src/generated/testing/test_type_provider.dart |
+++ b/pkg/analyzer/lib/src/generated/testing/test_type_provider.dart |
@@ -17,6 +17,7 @@ import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
import 'package:analyzer/src/generated/source.dart' show Source; |
import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
import 'package:analyzer/src/generated/testing/element_factory.dart'; |
+import 'package:analyzer/src/string_source.dart'; |
/** |
* A type provider that can be used by tests without creating the element model |
@@ -282,19 +283,7 @@ class TestTypeProvider extends TypeProviderBase { |
@override |
InterfaceType get futureOrType { |
if (_futureOrType == null) { |
- Source asyncSource = _context.sourceFactory.forUri(DartSdk.DART_ASYNC); |
- _context.setContents(asyncSource, ""); |
- CompilationUnitElementImpl asyncUnit = |
- new CompilationUnitElementImpl("async.dart"); |
- LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode( |
- _context, AstTestFactory.libraryIdentifier2(["dart.async"])); |
- asyncLibrary.definingCompilationUnit = asyncUnit; |
- asyncUnit.librarySource = asyncUnit.source = asyncSource; |
- |
- ClassElementImpl futureOr = |
- ElementFactory.classElement2("FutureOr", ["T"]); |
- _futureOrType = futureOr.type; |
- asyncUnit.types = <ClassElement>[futureOr]; |
+ _initDartAsync(); |
} |
return _futureOrType; |
} |
@@ -302,18 +291,7 @@ class TestTypeProvider extends TypeProviderBase { |
@override |
InterfaceType get futureType { |
if (_futureType == null) { |
- Source asyncSource = _context.sourceFactory.forUri(DartSdk.DART_ASYNC); |
- _context.setContents(asyncSource, ""); |
- CompilationUnitElementImpl asyncUnit = |
- new CompilationUnitElementImpl("async.dart"); |
- LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode( |
- _context, AstTestFactory.libraryIdentifier2(["dart.async"])); |
- asyncLibrary.definingCompilationUnit = asyncUnit; |
- asyncUnit.librarySource = asyncUnit.source = asyncSource; |
- |
- ClassElementImpl future = ElementFactory.classElement2("Future", ["T"]); |
- _futureType = future.type; |
- asyncUnit.types = <ClassElement>[future]; |
+ _initDartAsync(); |
} |
return _futureType; |
} |
@@ -436,11 +414,20 @@ class TestTypeProvider extends TypeProviderBase { |
@override |
InterfaceType get nullType { |
if (_nullType == null) { |
- ClassElementImpl nullElement = ElementFactory.classElement2("Null"); |
+ var nullElement = ElementFactory.classElement2("Null"); |
nullElement.constructors = <ConstructorElement>[ |
ElementFactory.constructorElement( |
nullElement, '_uninstantiatable', false)..factory = true |
]; |
+ // Create a library element for "dart:core" |
+ // This enables the "isDartCoreNull" getter. |
+ var library = new LibraryElementImpl.forNode( |
+ _context, AstTestFactory.libraryIdentifier2(["dart.core"])); |
+ var unit = new CompilationUnitElementImpl("core.dart"); |
+ library.definingCompilationUnit = unit; |
+ unit.librarySource = unit.source = new StringSource('', null); |
+ |
+ nullElement.enclosingElement = library; |
_nullType = nullElement.type; |
} |
return _nullType; |
@@ -569,6 +556,24 @@ class TestTypeProvider extends TypeProviderBase { |
return _undefinedType; |
} |
+ void _initDartAsync() { |
+ Source asyncSource = _context.sourceFactory.forUri(DartSdk.DART_ASYNC); |
+ _context.setContents(asyncSource, ""); |
+ CompilationUnitElementImpl asyncUnit = |
+ new CompilationUnitElementImpl("async.dart"); |
+ LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode( |
+ _context, AstTestFactory.libraryIdentifier2(["dart.async"])); |
+ asyncLibrary.definingCompilationUnit = asyncUnit; |
+ asyncUnit.librarySource = asyncUnit.source = asyncSource; |
+ |
+ ClassElementImpl future = ElementFactory.classElement2("Future", ["T"]); |
+ _futureType = future.type; |
+ asyncUnit.types = <ClassElement>[future]; |
+ ClassElementImpl futureOr = ElementFactory.classElement2("FutureOr", ["T"]); |
+ _futureOrType = futureOr.type; |
+ asyncUnit.types = <ClassElement>[future, futureOr]; |
+ } |
+ |
/** |
* Initialize the numeric types. They are created as a group so that we can |
* (a) create the right hierarchy and (b) add members to them. |