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

Unified Diff: pkg/analyzer/lib/src/generated/element.dart

Issue 1405963005: Create `loadLibrary` function element eagerly. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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/lib/src/generated/element.dart
diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart
index 0fcb8e5241b10b1fbea9f461b06da21b6ef7253e..9983700ee0ee284b782a7807022059c66397fa87 100644
--- a/pkg/analyzer/lib/src/generated/element.dart
+++ b/pkg/analyzer/lib/src/generated/element.dart
@@ -7628,52 +7628,10 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
@override
FunctionElement get loadLibraryFunction {
- if (_loadLibraryFunction == null) {
- FunctionElementImpl function =
- new FunctionElementImpl(FunctionElement.LOAD_LIBRARY_NAME, -1);
- function.synthetic = true;
- function.enclosingElement = this;
- function.returnType = loadLibraryReturnType;
- function.type = new FunctionTypeImpl(function);
- _loadLibraryFunction = function;
- }
+ assert(_loadLibraryFunction != null);
return _loadLibraryFunction;
}
- /**
- * Return the object representing the type 'Future' from the 'dart:async'
- * library, or the type 'void' if the type 'Future' cannot be accessed.
- */
- DartType get loadLibraryReturnType {
- try {
- Source asyncSource = context.sourceFactory.forUri(DartSdk.DART_ASYNC);
- if (asyncSource == null) {
- AnalysisEngine.instance.logger
- .logError("Could not create a source for dart:async");
- return VoidTypeImpl.instance;
- }
- LibraryElement asyncElement = context.computeLibraryElement(asyncSource);
- if (asyncElement == null) {
- AnalysisEngine.instance.logger
- .logError("Could not build the element model for dart:async");
- return VoidTypeImpl.instance;
- }
- ClassElement futureElement = asyncElement.getType("Future");
- if (futureElement == null) {
- AnalysisEngine.instance.logger
- .logError("Could not find type Future in dart:async");
- return VoidTypeImpl.instance;
- }
- InterfaceType futureType = futureElement.type;
- return futureType.substitute4(<DartType>[DynamicTypeImpl.instance]);
- } on AnalysisException catch (exception, stackTrace) {
- AnalysisEngine.instance.logger.logError(
- "Could not build the element model for dart:async",
- new CaughtException(exception, stackTrace));
- return VoidTypeImpl.instance;
- }
- }
-
@override
List<CompilationUnitElement> get parts => _parts;
@@ -7732,6 +7690,20 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
@override
accept(ElementVisitor visitor) => visitor.visitLibraryElement(this);
+ /**
+ * Create the [FunctionElement] to be returned by [loadLibraryFunction],
+ * using types provided by [typeProvider].
+ */
+ void createLoadLibraryFunction(TypeProvider typeProvider) {
+ FunctionElementImpl function =
+ new FunctionElementImpl(FunctionElement.LOAD_LIBRARY_NAME, -1);
+ function.synthetic = true;
+ function.enclosingElement = this;
+ function.returnType = typeProvider.futureDynamicType;
+ function.type = new FunctionTypeImpl(function);
+ _loadLibraryFunction = function;
+ }
+
@override
ElementImpl getChild(String identifier) {
if ((_definingCompilationUnit as CompilationUnitElementImpl).identifier ==

Powered by Google App Engine
This is Rietveld 408576698