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

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

Issue 2361433002: Async is no longer optional (Closed)
Patch Set: Created 4 years, 3 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 | « pkg/analysis_server/test/context_manager_test.dart ('k') | pkg/analyzer/lib/src/generated/engine.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 7e8b4d3a1a8b4498451d0a6c8b9acf78f5566344..3b6846fb6b3db9ca99dbbc5ccf78ac4033f9c6cc 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -9,7 +9,6 @@ import 'dart:collection';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
@@ -19,14 +18,12 @@ import 'package:analyzer/src/cancelable_future.dart';
import 'package:analyzer/src/context/builder.dart' show EmbedderYamlLocator;
import 'package:analyzer/src/context/cache.dart';
import 'package:analyzer/src/dart/element/element.dart';
-import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/generated/constant.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/incremental_resolver.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/testing/ast_factory.dart';
import 'package:analyzer/src/generated/utilities_collection.dart';
import 'package:analyzer/src/task/dart.dart';
import 'package:analyzer/src/task/dart_work_manager.dart';
@@ -308,7 +305,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
this._options.enableStrictCallChecks !=
options.enableStrictCallChecks ||
this._options.enableGenericMethods != options.enableGenericMethods ||
- this._options.enableAsync != options.enableAsync ||
this._options.enableSuperMixins != options.enableSuperMixins;
int cacheSize = options.cacheSize;
if (this._options.cacheSize != cacheSize) {
@@ -323,7 +319,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
this._options.enableAssertInitializer = options.enableAssertInitializer;
this._options.enableAssertMessage = options.enableAssertMessage;
this._options.enableStrictCallChecks = options.enableStrictCallChecks;
- this._options.enableAsync = options.enableAsync;
this._options.enableInitializingFormalAccess =
options.enableInitializingFormalAccess;
this._options.enableSuperMixins = options.enableSuperMixins;
@@ -545,22 +540,14 @@ class AnalysisContextImpl implements InternalAnalysisContext {
throw new AnalysisException("Could not create an element for dart:core");
}
- LibraryElement asyncElement;
- if (analysisOptions.enableAsync) {
- Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
- if (asyncSource == null) {
- throw new AnalysisException("Could not create a source for dart:async");
- }
- asyncElement = computeLibraryElement(asyncSource);
- if (asyncElement == null) {
- throw new AnalysisException(
- "Could not create an element for dart:async");
- }
- } else {
- Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
- asyncElement = createMockAsyncLib(coreElement, asyncSource);
+ Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
+ if (asyncSource == null) {
+ throw new AnalysisException("Could not create a source for dart:async");
+ }
+ LibraryElement asyncElement = computeLibraryElement(asyncSource);
+ if (asyncElement == null) {
+ throw new AnalysisException("Could not create an element for dart:async");
}
-
_typeProvider = new TypeProviderImpl(coreElement, asyncElement);
return _typeProvider;
}
@@ -773,55 +760,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
return cache;
}
- /**
- * Create a minimalistic mock dart:async library
- * to stand in for a real one if one does not exist
- * facilitating creation a type provider without dart:async.
- */
- LibraryElement createMockAsyncLib(
- LibraryElement coreLibrary, Source asyncSource) {
- InterfaceType objType = coreLibrary.getType('Object').type;
-
- ClassElement _classElement(String typeName, [List<String> parameterNames]) {
- ClassElementImpl element =
- new ClassElementImpl.forNode(AstFactory.identifier3(typeName));
- element.supertype = objType;
- if (parameterNames != null) {
- int count = parameterNames.length;
- if (count > 0) {
- List<TypeParameterElementImpl> typeParameters =
- new List<TypeParameterElementImpl>(count);
- List<TypeParameterTypeImpl> typeArguments =
- new List<TypeParameterTypeImpl>(count);
- for (int i = 0; i < count; i++) {
- TypeParameterElementImpl typeParameter =
- new TypeParameterElementImpl.forNode(
- AstFactory.identifier3(parameterNames[i]));
- typeParameters[i] = typeParameter;
- typeArguments[i] = new TypeParameterTypeImpl(typeParameter);
- typeParameter.type = typeArguments[i];
- }
- element.typeParameters = typeParameters;
- }
- }
- return element;
- }
-
- InterfaceType futureType = _classElement('Future', ['T']).type;
- InterfaceType streamType = _classElement('Stream', ['T']).type;
- CompilationUnitElementImpl asyncUnit =
- new CompilationUnitElementImpl("mock_async.dart");
- 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);
- return mockLib;
- }
-
@override
void dispose() {
_disposed = true;
« no previous file with comments | « pkg/analysis_server/test/context_manager_test.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698