| 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/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 * libraries exports one. | 108 * libraries exports one. |
| 109 * | 109 * |
| 110 * Also [LibraryElement.exportNamespace] is set. | 110 * Also [LibraryElement.exportNamespace] is set. |
| 111 * | 111 * |
| 112 * The result is only available for targets representing a Dart library. | 112 * The result is only available for targets representing a Dart library. |
| 113 */ | 113 */ |
| 114 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT4 = | 114 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT4 = |
| 115 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT4', null); | 115 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT4', null); |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * The errors produced while resolving type names. |
| 119 * |
| 120 * The list will be empty if there were no errors, but will not be `null`. |
| 121 * |
| 122 * The result is only available for targets representing a Dart library. |
| 123 */ |
| 124 final ResultDescriptor<List<AnalysisError>> RESOLVE_TYPE_NAMES_ERRORS = |
| 125 new ResultDescriptor<List<AnalysisError>>( |
| 126 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS, |
| 127 contributesTo: DART_ERRORS); |
| 128 |
| 129 /** |
| 118 * The partially resolved [CompilationUnit] associated with a unit. | 130 * The partially resolved [CompilationUnit] associated with a unit. |
| 119 * | 131 * |
| 120 * All declarations bound to the element defined by the declaration. | 132 * All declarations bound to the element defined by the declaration. |
| 121 * | 133 * |
| 122 * The result is only available for targets representing a unit. | 134 * The result is only available for targets representing a unit. |
| 123 */ | 135 */ |
| 124 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = | 136 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = |
| 125 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null); | 137 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null); |
| 126 | 138 |
| 127 /** | 139 /** |
| (...skipping 30 matching lines...) Expand all Loading... |
| 158 * The partially resolved [CompilationUnit] associated with a unit. | 170 * The partially resolved [CompilationUnit] associated with a unit. |
| 159 * | 171 * |
| 160 * All the function type aliases are resolved. | 172 * All the function type aliases are resolved. |
| 161 * | 173 * |
| 162 * The result is only available for targets representing a unit. | 174 * The result is only available for targets representing a unit. |
| 163 */ | 175 */ |
| 164 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 = | 176 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 = |
| 165 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null); | 177 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null); |
| 166 | 178 |
| 167 /** | 179 /** |
| 180 * The partially resolved [CompilationUnit] associated with a unit. |
| 181 * |
| 182 * [RESOLVED_UNIT5] with resolved type names. |
| 183 * |
| 184 * The result is only available for targets representing a unit. |
| 185 */ |
| 186 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 = |
| 187 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null); |
| 188 |
| 189 /** |
| 168 * The [TypeProvider] of the context. | 190 * The [TypeProvider] of the context. |
| 169 */ | 191 */ |
| 170 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = | 192 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = |
| 171 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); | 193 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); |
| 172 | 194 |
| 173 /** | 195 /** |
| 174 * A task that builds a compilation unit element for a single compilation unit. | 196 * A task that builds a compilation unit element for a single compilation unit. |
| 175 */ | 197 */ |
| 176 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { | 198 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { |
| 177 /** | 199 /** |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 Set<LibraryElement> libraries, LibraryElement library) { | 716 Set<LibraryElement> libraries, LibraryElement library) { |
| 695 if (library != null && libraries.add(library)) { | 717 if (library != null && libraries.add(library)) { |
| 696 for (ExportElement exportElement in library.exports) { | 718 for (ExportElement exportElement in library.exports) { |
| 697 _buildExportClosure(libraries, exportElement.exportedLibrary); | 719 _buildExportClosure(libraries, exportElement.exportedLibrary); |
| 698 } | 720 } |
| 699 } | 721 } |
| 700 } | 722 } |
| 701 } | 723 } |
| 702 | 724 |
| 703 /** | 725 /** |
| 704 * A task that builds [RESOLVED_UNIT5] for a library. | 726 * A task that builds [RESOLVED_UNIT5] for a unit. |
| 705 */ | 727 */ |
| 706 class BuildFunctionTypeAliasesTask extends SourceBasedAnalysisTask { | 728 class BuildFunctionTypeAliasesTask extends SourceBasedAnalysisTask { |
| 707 /** | 729 /** |
| 708 * The name of the [TYPE_PROVIDER] input. | 730 * The name of the [TYPE_PROVIDER] input. |
| 709 */ | 731 */ |
| 710 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 732 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 711 | 733 |
| 712 /** | 734 /** |
| 713 * The name of the [RESOLVED_UNIT3] input. | 735 * The name of the [RESOLVED_UNIT3] input. |
| 714 */ | 736 */ |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 void _addPublicNames(CompilationUnitElement compilationUnit) { | 1515 void _addPublicNames(CompilationUnitElement compilationUnit) { |
| 1494 compilationUnit.accessors.forEach(_addIfPublic); | 1516 compilationUnit.accessors.forEach(_addIfPublic); |
| 1495 compilationUnit.enums.forEach(_addIfPublic); | 1517 compilationUnit.enums.forEach(_addIfPublic); |
| 1496 compilationUnit.functions.forEach(_addIfPublic); | 1518 compilationUnit.functions.forEach(_addIfPublic); |
| 1497 compilationUnit.functionTypeAliases.forEach(_addIfPublic); | 1519 compilationUnit.functionTypeAliases.forEach(_addIfPublic); |
| 1498 compilationUnit.types.forEach(_addIfPublic); | 1520 compilationUnit.types.forEach(_addIfPublic); |
| 1499 } | 1521 } |
| 1500 } | 1522 } |
| 1501 | 1523 |
| 1502 /** | 1524 /** |
| 1525 * A task that builds [RESOLVED_UNIT6] for a unit. |
| 1526 */ |
| 1527 class ResolveTypeNamesTask extends SourceBasedAnalysisTask { |
| 1528 /** |
| 1529 * The name of the [RESOLVED_UNIT5] input. |
| 1530 */ |
| 1531 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 1532 |
| 1533 /** |
| 1534 * The task descriptor describing this kind of task. |
| 1535 */ |
| 1536 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1537 'ResolveTypeNamesTask', createTask, buildInputs, <ResultDescriptor>[ |
| 1538 RESOLVE_TYPE_NAMES_ERRORS, |
| 1539 RESOLVED_UNIT6 |
| 1540 ]); |
| 1541 |
| 1542 ResolveTypeNamesTask(InternalAnalysisContext context, AnalysisTarget target) |
| 1543 : super(context, target); |
| 1544 |
| 1545 @override |
| 1546 TaskDescriptor get descriptor => DESCRIPTOR; |
| 1547 |
| 1548 @override |
| 1549 void internalPerform() { |
| 1550 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1551 // |
| 1552 // Prepare inputs. |
| 1553 // |
| 1554 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 1555 CompilationUnitElement unitElement = unit.element; |
| 1556 // |
| 1557 // Resolve TypeName nodes. |
| 1558 // |
| 1559 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( |
| 1560 unitElement.library, unitElement.source, context.typeProvider, |
| 1561 errorListener); |
| 1562 unit.accept(visitor); |
| 1563 // |
| 1564 // Record outputs. |
| 1565 // |
| 1566 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors; |
| 1567 outputs[RESOLVED_UNIT6] = unit; |
| 1568 } |
| 1569 |
| 1570 /** |
| 1571 * 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 |
| 1573 * given [target]. |
| 1574 */ |
| 1575 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { |
| 1576 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT5.inputFor(target)}; |
| 1577 } |
| 1578 |
| 1579 /** |
| 1580 * Create a [ResolveTypeNamesTask] based on the given [target] in |
| 1581 * the given [context]. |
| 1582 */ |
| 1583 static ResolveTypeNamesTask createTask( |
| 1584 AnalysisContext context, AnalysisTarget target) { |
| 1585 return new ResolveTypeNamesTask(context, target); |
| 1586 } |
| 1587 } |
| 1588 |
| 1589 /** |
| 1503 * A task that scans the content of a file, producing a set of Dart tokens. | 1590 * A task that scans the content of a file, producing a set of Dart tokens. |
| 1504 */ | 1591 */ |
| 1505 class ScanDartTask extends SourceBasedAnalysisTask { | 1592 class ScanDartTask extends SourceBasedAnalysisTask { |
| 1506 /** | 1593 /** |
| 1507 * The name of the input whose value is the content of the file. | 1594 * The name of the input whose value is the content of the file. |
| 1508 */ | 1595 */ |
| 1509 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; | 1596 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; |
| 1510 | 1597 |
| 1511 /** | 1598 /** |
| 1512 * The task descriptor describing this kind of task. | 1599 * The task descriptor describing this kind of task. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 } | 1639 } |
| 1553 | 1640 |
| 1554 /** | 1641 /** |
| 1555 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 1642 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 1556 */ | 1643 */ |
| 1557 static ScanDartTask createTask( | 1644 static ScanDartTask createTask( |
| 1558 AnalysisContext context, AnalysisTarget target) { | 1645 AnalysisContext context, AnalysisTarget target) { |
| 1559 return new ScanDartTask(context, target); | 1646 return new ScanDartTask(context, target); |
| 1560 } | 1647 } |
| 1561 } | 1648 } |
| OLD | NEW |