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

Unified Diff: pkg/analyzer/lib/src/generated/testing/test_type_provider.dart

Issue 2581803002: Add access to FutureOr in TypeProviders (and add implementation in mock sdks) (Closed)
Patch Set: Created 4 years 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/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 953dcee3f328390123eddd88dc53f1f46688ebf7..c2a3a43320d9f52a655aac16f0629008fedcd108 100644
--- a/pkg/analyzer/lib/src/generated/testing/test_type_provider.dart
+++ b/pkg/analyzer/lib/src/generated/testing/test_type_provider.dart
@@ -64,6 +64,11 @@ class TestTypeProvider extends TypeProviderBase {
InterfaceType _futureNullType;
/**
+ * The type representing the built-in type 'FutureOr'
+ */
+ InterfaceType _futureOrType;
+
+ /**
* The type representing the built-in type 'Future'
*/
InterfaceType _futureType;
@@ -262,6 +267,26 @@ 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];
+ }
+ return _futureOrType;
+ }
+
+ @override
InterfaceType get futureType {
if (_futureType == null) {
Source asyncSource = _context.sourceFactory.forUri(DartSdk.DART_ASYNC);

Powered by Google App Engine
This is Rietveld 408576698