| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.task.dart; | 5 library analyzer.src.task.dart; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 BuildTypeProviderTask( | 1571 BuildTypeProviderTask( |
| 1572 InternalAnalysisContext context, AnalysisContextTarget target) | 1572 InternalAnalysisContext context, AnalysisContextTarget target) |
| 1573 : super(context, target); | 1573 : super(context, target); |
| 1574 | 1574 |
| 1575 @override | 1575 @override |
| 1576 TaskDescriptor get descriptor => DESCRIPTOR; | 1576 TaskDescriptor get descriptor => DESCRIPTOR; |
| 1577 | 1577 |
| 1578 @override | 1578 @override |
| 1579 void internalPerform() { | 1579 void internalPerform() { |
| 1580 LibraryElement coreLibrary = getRequiredInput(CORE_INPUT); | 1580 LibraryElement coreLibrary = getRequiredInput(CORE_INPUT); |
| 1581 LibraryElement asyncLibrary = getRequiredInput(ASYNC_INPUT); | 1581 LibraryElement asyncLibrary = getOptionalInput(ASYNC_INPUT); |
| 1582 if (asyncLibrary == null) { |
| 1583 asyncLibrary = |
| 1584 (context as AnalysisContextImpl).createMockAsyncLib(coreLibrary); |
| 1585 } |
| 1582 Namespace coreNamespace = coreLibrary.publicNamespace; | 1586 Namespace coreNamespace = coreLibrary.publicNamespace; |
| 1583 Namespace asyncNamespace = asyncLibrary.publicNamespace; | 1587 Namespace asyncNamespace = asyncLibrary.publicNamespace; |
| 1584 // | 1588 // |
| 1585 // Record outputs. | 1589 // Record outputs. |
| 1586 // | 1590 // |
| 1587 if (!context.analysisOptions.enableAsync) { | 1591 if (!context.analysisOptions.enableAsync) { |
| 1588 AnalysisContextImpl contextImpl = context; | 1592 AnalysisContextImpl contextImpl = context; |
| 1589 asyncLibrary = contextImpl.createMockAsyncLib(coreLibrary); | 1593 asyncLibrary = contextImpl.createMockAsyncLib(coreLibrary); |
| 1590 asyncNamespace = asyncLibrary.publicNamespace; | 1594 asyncNamespace = asyncLibrary.publicNamespace; |
| 1591 } | 1595 } |
| 1592 TypeProvider typeProvider = | 1596 TypeProvider typeProvider = |
| 1593 new TypeProviderImpl.forNamespaces(coreNamespace, asyncNamespace); | 1597 new TypeProviderImpl.forNamespaces(coreNamespace, asyncNamespace); |
| 1594 (context as InternalAnalysisContext).typeProvider = typeProvider; | 1598 (context as InternalAnalysisContext).typeProvider = typeProvider; |
| 1595 outputs[TYPE_PROVIDER] = typeProvider; | 1599 outputs[TYPE_PROVIDER] = typeProvider; |
| 1596 } | 1600 } |
| 1597 | 1601 |
| 1598 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 1602 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 1599 AnalysisContextTarget contextTarget = target; | 1603 AnalysisContextTarget contextTarget = target; |
| 1600 SourceFactory sourceFactory = contextTarget.context.sourceFactory; | 1604 SourceFactory sourceFactory = contextTarget.context.sourceFactory; |
| 1601 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | 1605 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 1602 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); | 1606 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); |
| 1607 if (asyncSource == null) { |
| 1608 return <String, TaskInput>{CORE_INPUT: LIBRARY_ELEMENT3.of(coreSource)}; |
| 1609 } |
| 1603 return <String, TaskInput>{ | 1610 return <String, TaskInput>{ |
| 1604 CORE_INPUT: LIBRARY_ELEMENT3.of(coreSource), | 1611 CORE_INPUT: LIBRARY_ELEMENT3.of(coreSource), |
| 1605 ASYNC_INPUT: LIBRARY_ELEMENT3.of(asyncSource) | 1612 ASYNC_INPUT: LIBRARY_ELEMENT3.of(asyncSource) |
| 1606 }; | 1613 }; |
| 1607 } | 1614 } |
| 1608 | 1615 |
| 1609 /** | 1616 /** |
| 1610 * Create a [BuildTypeProviderTask] based on the given [context]. | 1617 * Create a [BuildTypeProviderTask] based on the given [context]. |
| 1611 */ | 1618 */ |
| 1612 static BuildTypeProviderTask createTask( | 1619 static BuildTypeProviderTask createTask( |
| (...skipping 3770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5383 | 5390 |
| 5384 @override | 5391 @override |
| 5385 bool moveNext() { | 5392 bool moveNext() { |
| 5386 if (_newSources.isEmpty) { | 5393 if (_newSources.isEmpty) { |
| 5387 return false; | 5394 return false; |
| 5388 } | 5395 } |
| 5389 currentTarget = _newSources.removeLast(); | 5396 currentTarget = _newSources.removeLast(); |
| 5390 return true; | 5397 return true; |
| 5391 } | 5398 } |
| 5392 } | 5399 } |
| OLD | NEW |