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

Side by Side Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1220743004: Split BuildSourceClosuresTask into two tasks; remove unnecessary computation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:analyzer/src/context/cache.dart'; 10 import 'package:analyzer/src/context/cache.dart';
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 /** 165 /**
166 * The sources representing the combined import/export closure of a library. 166 * The sources representing the combined import/export closure of a library.
167 * The [Source]s include only library sources, not their units. 167 * The [Source]s include only library sources, not their units.
168 * 168 *
169 * The result is only available for [Source]s representing a library. 169 * The result is only available for [Source]s representing a library.
170 */ 170 */
171 final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE = 171 final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE =
172 new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null); 172 new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null);
173 173
174 /** 174 /**
175 * The sources representing the import closure of a library.
176 * The [Source]s include only library sources, not their units.
177 *
178 * The result is only available for [Source]s representing a library.
179 */
180 final ListResultDescriptor<Source> IMPORT_SOURCE_CLOSURE =
181 new ListResultDescriptor<Source>('IMPORT_SOURCE_CLOSURE', null);
182
183 /**
184 * The partial [LibraryElement] associated with a library. 175 * The partial [LibraryElement] associated with a library.
185 * 176 *
186 * The [LibraryElement] and its [CompilationUnitElement]s are attached to each 177 * The [LibraryElement] and its [CompilationUnitElement]s are attached to each
187 * other. Directives 'library', 'part' and 'part of' are resolved. 178 * other. Directives 'library', 'part' and 'part of' are resolved.
188 * 179 *
189 * The result is only available for [Source]s representing a library. 180 * The result is only available for [Source]s representing a library.
190 */ 181 */
191 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 = 182 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 =
192 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT1', null, 183 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT1', null,
193 cachingPolicy: ELEMENT_CACHING_POLICY); 184 cachingPolicy: ELEMENT_CACHING_POLICY);
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 * Create a [BuildPublicNamespaceTask] based on the given [target] in 1499 * Create a [BuildPublicNamespaceTask] based on the given [target] in
1509 * the given [context]. 1500 * the given [context].
1510 */ 1501 */
1511 static BuildPublicNamespaceTask createTask( 1502 static BuildPublicNamespaceTask createTask(
1512 AnalysisContext context, AnalysisTarget target) { 1503 AnalysisContext context, AnalysisTarget target) {
1513 return new BuildPublicNamespaceTask(context, target); 1504 return new BuildPublicNamespaceTask(context, target);
1514 } 1505 }
1515 } 1506 }
1516 1507
1517 /** 1508 /**
1518 * A task that builds [IMPORT_SOURCE_CLOSURE] and [EXPORT_SOURCE_CLOSURE] of 1509 * A task that builds [EXPORT_SOURCE_CLOSURE] of a library.
1519 * a library.
1520 */ 1510 */
1521 class BuildSourceClosuresTask extends SourceBasedAnalysisTask { 1511 class BuildSourceExportClosureTask extends SourceBasedAnalysisTask {
1522 /**
1523 * The name of the import closure.
1524 */
1525 static const String IMPORT_INPUT = 'IMPORT_INPUT';
1526
1527 /** 1512 /**
1528 * The name of the export closure. 1513 * The name of the export closure.
1529 */ 1514 */
1530 static const String EXPORT_INPUT = 'EXPORT_INPUT'; 1515 static const String EXPORT_INPUT = 'EXPORT_INPUT';
1531 1516
1532 /** 1517 /**
1518 * The task descriptor describing this kind of task.
1519 */
1520 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
1521 'BuildSourceExportClosureTask', createTask, buildInputs,
1522 <ResultDescriptor>[EXPORT_SOURCE_CLOSURE]);
1523
1524 BuildSourceExportClosureTask(
1525 InternalAnalysisContext context, AnalysisTarget target)
1526 : super(context, target);
1527
1528 @override
1529 TaskDescriptor get descriptor => DESCRIPTOR;
1530
1531 @override
1532 void internalPerform() {
1533 List<Source> exportClosure = getRequiredInput(EXPORT_INPUT);
1534 //
1535 // Record output.
1536 //
1537 outputs[EXPORT_SOURCE_CLOSURE] = exportClosure;
1538 }
1539
1540 /**
1541 * Return a map from the names of the inputs of this kind of task to the task
1542 * input descriptors describing those inputs for a task with the
1543 * given library [libSource].
1544 */
1545 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
1546 Source source = target;
1547 return <String, TaskInput>{
1548 EXPORT_INPUT: new _ExportSourceClosureTaskInput(source, LIBRARY_ELEMENT2)
1549 };
1550 }
1551
1552 /**
1553 * Create a [BuildSourceExportClosureTask] based on the given [target] in
1554 * the given [context].
1555 */
1556 static BuildSourceExportClosureTask createTask(
1557 AnalysisContext context, AnalysisTarget target) {
1558 return new BuildSourceExportClosureTask(context, target);
1559 }
1560 }
1561
1562 /**
1563 * A task that builds [IMPORT_EXPORT_SOURCE_CLOSURE] of a library, and also
1564 * sets [IS_CLIENT].
1565 */
1566 class BuildSourceImportExportClosureTask extends SourceBasedAnalysisTask {
1567 /**
1533 * The name of the import/export closure. 1568 * The name of the import/export closure.
1534 */ 1569 */
1535 static const String IMPORT_EXPORT_INPUT = 'IMPORT_EXPORT_INPUT'; 1570 static const String IMPORT_EXPORT_INPUT = 'IMPORT_EXPORT_INPUT';
1536 1571
1537 /** 1572 /**
1538 * The task descriptor describing this kind of task. 1573 * The task descriptor describing this kind of task.
1539 */ 1574 */
1540 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 1575 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
1541 'BuildSourceClosuresTask', createTask, buildInputs, <ResultDescriptor>[ 1576 'BuildSourceImportExportClosureTask', createTask, buildInputs,
1542 IMPORT_SOURCE_CLOSURE, 1577 <ResultDescriptor>[IMPORT_EXPORT_SOURCE_CLOSURE, IS_CLIENT]);
1543 EXPORT_SOURCE_CLOSURE,
1544 IMPORT_EXPORT_SOURCE_CLOSURE,
1545 IS_CLIENT
1546 ]);
1547 1578
1548 BuildSourceClosuresTask( 1579 BuildSourceImportExportClosureTask(
1549 InternalAnalysisContext context, AnalysisTarget target) 1580 InternalAnalysisContext context, AnalysisTarget target)
1550 : super(context, target); 1581 : super(context, target);
1551 1582
1552 @override 1583 @override
1553 TaskDescriptor get descriptor => DESCRIPTOR; 1584 TaskDescriptor get descriptor => DESCRIPTOR;
1554 1585
1555 @override 1586 @override
1556 void internalPerform() { 1587 void internalPerform() {
1557 List<Source> importClosure = getRequiredInput(IMPORT_INPUT);
1558 List<Source> exportClosure = getRequiredInput(EXPORT_INPUT);
1559 List<Source> importExportClosure = getRequiredInput(IMPORT_EXPORT_INPUT); 1588 List<Source> importExportClosure = getRequiredInput(IMPORT_EXPORT_INPUT);
1560 Source htmlSource = context.sourceFactory.forUri(DartSdk.DART_HTML); 1589 Source htmlSource = context.sourceFactory.forUri(DartSdk.DART_HTML);
1561 // 1590 //
1562 // Record outputs. 1591 // Record outputs.
1563 // 1592 //
1564 outputs[IMPORT_SOURCE_CLOSURE] = importClosure;
1565 outputs[EXPORT_SOURCE_CLOSURE] = exportClosure;
1566 outputs[IMPORT_EXPORT_SOURCE_CLOSURE] = importExportClosure; 1593 outputs[IMPORT_EXPORT_SOURCE_CLOSURE] = importExportClosure;
1567 outputs[IS_CLIENT] = importExportClosure.contains(htmlSource); 1594 outputs[IS_CLIENT] = importExportClosure.contains(htmlSource);
1568 } 1595 }
1569 1596
1570 /** 1597 /**
1571 * Return a map from the names of the inputs of this kind of task to the task 1598 * Return a map from the names of the inputs of this kind of task to the task
1572 * input descriptors describing those inputs for a task with the 1599 * input descriptors describing those inputs for a task with the
1573 * given library [libSource]. 1600 * given library [libSource].
1574 */ 1601 */
1575 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 1602 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
1576 Source source = target; 1603 Source source = target;
1577 return <String, TaskInput>{ 1604 return <String, TaskInput>{
1578 IMPORT_INPUT: new _ImportSourceClosureTaskInput(source, LIBRARY_ELEMENT2),
1579 EXPORT_INPUT: new _ExportSourceClosureTaskInput(source, LIBRARY_ELEMENT2),
1580 IMPORT_EXPORT_INPUT: 1605 IMPORT_EXPORT_INPUT:
1581 new _ImportExportSourceClosureTaskInput(source, LIBRARY_ELEMENT2) 1606 new _ImportExportSourceClosureTaskInput(source, LIBRARY_ELEMENT2)
1582 }; 1607 };
1583 } 1608 }
1584 1609
1585 /** 1610 /**
1586 * Create a [BuildSourceClosuresTask] based on the given [target] in 1611 * Create a [BuildSourceImportExportClosureTask] based on the given [target]
1587 * the given [context]. 1612 * in the given [context].
1588 */ 1613 */
1589 static BuildSourceClosuresTask createTask( 1614 static BuildSourceImportExportClosureTask createTask(
1590 AnalysisContext context, AnalysisTarget target) { 1615 AnalysisContext context, AnalysisTarget target) {
1591 return new BuildSourceClosuresTask(context, target); 1616 return new BuildSourceImportExportClosureTask(context, target);
1592 } 1617 }
1593 } 1618 }
1594 1619
1595 /** 1620 /**
1596 * A task that builds [TYPE_PROVIDER] for a context. 1621 * A task that builds [TYPE_PROVIDER] for a context.
1597 */ 1622 */
1598 class BuildTypeProviderTask extends SourceBasedAnalysisTask { 1623 class BuildTypeProviderTask extends SourceBasedAnalysisTask {
1599 /** 1624 /**
1600 * The [PUBLIC_NAMESPACE] input of the `dart:core` library. 1625 * The [PUBLIC_NAMESPACE] input of the `dart:core` library.
1601 */ 1626 */
(...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3719 3744
3720 @override 3745 @override
3721 bool moveNext() { 3746 bool moveNext() {
3722 if (_newSources.isEmpty) { 3747 if (_newSources.isEmpty) {
3723 return false; 3748 return false;
3724 } 3749 }
3725 currentTarget = _newSources.removeLast(); 3750 currentTarget = _newSources.removeLast();
3726 return true; 3751 return true;
3727 } 3752 }
3728 } 3753 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/plugin/engine_plugin.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698