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

Side by Side Diff: pkg/analyzer/lib/src/task/dart.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 unified diff | Download patch
OLDNEW
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/src/context/cache.dart'; 9 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 3765 matching lines...) Expand 10 before | Expand all | Expand 10 after
3776 * An artifitial task that does nothing except to force type names resolution 3776 * An artifitial task that does nothing except to force type names resolution
3777 * for the defining and part units of a library. 3777 * for the defining and part units of a library.
3778 */ 3778 */
3779 class ResolveLibraryTypeNamesTask extends SourceBasedAnalysisTask { 3779 class ResolveLibraryTypeNamesTask extends SourceBasedAnalysisTask {
3780 /** 3780 /**
3781 * The name of the [LIBRARY_ELEMENT4] input. 3781 * The name of the [LIBRARY_ELEMENT4] input.
3782 */ 3782 */
3783 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; 3783 static const String LIBRARY_INPUT = 'LIBRARY_INPUT';
3784 3784
3785 /** 3785 /**
3786 * The name of the [TYPE_PROVIDER] input.
3787 */
3788 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
3789
3790 /**
3786 * The task descriptor describing this kind of task. 3791 * The task descriptor describing this kind of task.
3787 */ 3792 */
3788 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 3793 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
3789 'ResolveLibraryTypeNamesTask', 3794 'ResolveLibraryTypeNamesTask',
3790 createTask, 3795 createTask,
3791 buildInputs, 3796 buildInputs,
3792 <ResultDescriptor>[LIBRARY_ELEMENT5]); 3797 <ResultDescriptor>[LIBRARY_ELEMENT5]);
3793 3798
3794 ResolveLibraryTypeNamesTask( 3799 ResolveLibraryTypeNamesTask(
3795 InternalAnalysisContext context, AnalysisTarget target) 3800 InternalAnalysisContext context, AnalysisTarget target)
3796 : super(context, target); 3801 : super(context, target);
3797 3802
3798 @override 3803 @override
3799 TaskDescriptor get descriptor => DESCRIPTOR; 3804 TaskDescriptor get descriptor => DESCRIPTOR;
3800 3805
3801 @override 3806 @override
3802 void internalPerform() { 3807 void internalPerform() {
3808 //
3809 // Prepare inputs.
3810 //
3803 LibraryElement library = getRequiredInput(LIBRARY_INPUT); 3811 LibraryElement library = getRequiredInput(LIBRARY_INPUT);
3812 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
3813 //
3814 // Create the synthetic element for `loadLibrary`.
3815 //
3816 (library as LibraryElementImpl).createLoadLibraryFunction(typeProvider);
3817 //
3818 // Record outputs.
3819 //
3804 outputs[LIBRARY_ELEMENT5] = library; 3820 outputs[LIBRARY_ELEMENT5] = library;
3805 } 3821 }
3806 3822
3807 /** 3823 /**
3808 * Return a map from the names of the inputs of this kind of task to the task 3824 * Return a map from the names of the inputs of this kind of task to the task
3809 * input descriptors describing those inputs for a task with the 3825 * input descriptors describing those inputs for a task with the
3810 * given [target]. 3826 * given [target].
3811 */ 3827 */
3812 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 3828 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
3813 Source source = target; 3829 Source source = target;
3814 return <String, TaskInput>{ 3830 return <String, TaskInput>{
3815 'resolvedUnit': UNITS.of(source).toList((Source unit) => 3831 'resolvedUnit': UNITS.of(source).toList((Source unit) =>
3816 RESOLVED_UNIT3.of(new LibrarySpecificUnit(source, unit))), 3832 RESOLVED_UNIT3.of(new LibrarySpecificUnit(source, unit))),
3817 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(source) 3833 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(source),
3834 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
3818 }; 3835 };
3819 } 3836 }
3820 3837
3821 /** 3838 /**
3822 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in 3839 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in
3823 * the given [context]. 3840 * the given [context].
3824 */ 3841 */
3825 static ResolveLibraryTypeNamesTask createTask( 3842 static ResolveLibraryTypeNamesTask createTask(
3826 AnalysisContext context, AnalysisTarget target) { 3843 AnalysisContext context, AnalysisTarget target) {
3827 return new ResolveLibraryTypeNamesTask(context, target); 3844 return new ResolveLibraryTypeNamesTask(context, target);
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
4528 4545
4529 @override 4546 @override
4530 bool moveNext() { 4547 bool moveNext() {
4531 if (_newSources.isEmpty) { 4548 if (_newSources.isEmpty) {
4532 return false; 4549 return false;
4533 } 4550 }
4534 currentTarget = _newSources.removeLast(); 4551 currentTarget = _newSources.removeLast();
4535 return true; 4552 return true;
4536 } 4553 }
4537 } 4554 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698