| 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 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 static const String PARTS_UNIT_INPUT = 'PARTS_UNIT_INPUT'; | 1134 static const String PARTS_UNIT_INPUT = 'PARTS_UNIT_INPUT'; |
| 1135 | 1135 |
| 1136 /** | 1136 /** |
| 1137 * The task descriptor describing this kind of task. | 1137 * The task descriptor describing this kind of task. |
| 1138 */ | 1138 */ |
| 1139 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 1139 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1140 'BuildLibraryElementTask', createTask, buildInputs, <ResultDescriptor>[ | 1140 'BuildLibraryElementTask', createTask, buildInputs, <ResultDescriptor>[ |
| 1141 BUILD_LIBRARY_ERRORS, | 1141 BUILD_LIBRARY_ERRORS, |
| 1142 CLASS_ELEMENTS, | 1142 CLASS_ELEMENTS, |
| 1143 LIBRARY_ELEMENT1, | 1143 LIBRARY_ELEMENT1, |
| 1144 IS_LAUNCHABLE, | 1144 IS_LAUNCHABLE |
| 1145 HAS_HTML_IMPORT | |
| 1146 ]); | 1145 ]); |
| 1147 | 1146 |
| 1148 /** | 1147 /** |
| 1149 * The constant used as an unknown common library name in parts. | 1148 * The constant used as an unknown common library name in parts. |
| 1150 */ | 1149 */ |
| 1151 static const String _UNKNOWN_LIBRARY_NAME = 'unknown-library-name'; | 1150 static const String _UNKNOWN_LIBRARY_NAME = 'unknown-library-name'; |
| 1152 | 1151 |
| 1153 /** | 1152 /** |
| 1154 * Initialize a newly created task to build a library element for the given | 1153 * Initialize a newly created task to build a library element for the given |
| 1155 * [target] in the given [context]. | 1154 * [target] in the given [context]. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1175 // Process inputs. | 1174 // Process inputs. |
| 1176 // | 1175 // |
| 1177 CompilationUnitElementImpl definingCompilationUnitElement = | 1176 CompilationUnitElementImpl definingCompilationUnitElement = |
| 1178 definingCompilationUnit.element; | 1177 definingCompilationUnit.element; |
| 1179 Map<Source, CompilationUnit> partUnitMap = | 1178 Map<Source, CompilationUnit> partUnitMap = |
| 1180 new HashMap<Source, CompilationUnit>(); | 1179 new HashMap<Source, CompilationUnit>(); |
| 1181 for (CompilationUnit partUnit in partUnits) { | 1180 for (CompilationUnit partUnit in partUnits) { |
| 1182 Source partSource = partUnit.element.source; | 1181 Source partSource = partUnit.element.source; |
| 1183 partUnitMap[partSource] = partUnit; | 1182 partUnitMap[partSource] = partUnit; |
| 1184 } | 1183 } |
| 1185 Source htmlSource = context.sourceFactory.forUri(DartSdk.DART_HTML); | |
| 1186 // | 1184 // |
| 1187 // Update "part" directives. | 1185 // Update "part" directives. |
| 1188 // | 1186 // |
| 1189 LibraryIdentifier libraryNameNode = null; | 1187 LibraryIdentifier libraryNameNode = null; |
| 1190 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; | 1188 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; |
| 1191 bool hasHtmlImport = false; | |
| 1192 bool hasPartDirective = false; | 1189 bool hasPartDirective = false; |
| 1193 FunctionElement entryPoint = | 1190 FunctionElement entryPoint = |
| 1194 _findEntryPoint(definingCompilationUnitElement); | 1191 _findEntryPoint(definingCompilationUnitElement); |
| 1195 List<Directive> directivesToResolve = <Directive>[]; | 1192 List<Directive> directivesToResolve = <Directive>[]; |
| 1196 List<CompilationUnitElementImpl> sourcedCompilationUnits = | 1193 List<CompilationUnitElementImpl> sourcedCompilationUnits = |
| 1197 <CompilationUnitElementImpl>[]; | 1194 <CompilationUnitElementImpl>[]; |
| 1198 for (Directive directive in definingCompilationUnit.directives) { | 1195 for (Directive directive in definingCompilationUnit.directives) { |
| 1199 if (directive is ImportDirective) { | 1196 if (directive is LibraryDirective) { |
| 1200 hasHtmlImport = hasHtmlImport || directive.source == htmlSource; | |
| 1201 } else if (directive is LibraryDirective) { | |
| 1202 if (libraryNameNode == null) { | 1197 if (libraryNameNode == null) { |
| 1203 libraryNameNode = directive.name; | 1198 libraryNameNode = directive.name; |
| 1204 directivesToResolve.add(directive); | 1199 directivesToResolve.add(directive); |
| 1205 } | 1200 } |
| 1206 } else if (directive is PartDirective) { | 1201 } else if (directive is PartDirective) { |
| 1207 PartDirective partDirective = directive; | 1202 PartDirective partDirective = directive; |
| 1208 StringLiteral partUri = partDirective.uri; | 1203 StringLiteral partUri = partDirective.uri; |
| 1209 Source partSource = partDirective.source; | 1204 Source partSource = partDirective.source; |
| 1210 if (context.exists(partSource)) { | 1205 if (context.exists(partSource)) { |
| 1211 hasPartDirective = true; | 1206 hasPartDirective = true; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 .map((CompilationUnitElement unitElement) => unitElement.types) | 1274 .map((CompilationUnitElement unitElement) => unitElement.types) |
| 1280 .expand((List<ClassElement> unitClassElements) => unitClassElements) | 1275 .expand((List<ClassElement> unitClassElements) => unitClassElements) |
| 1281 .toList(); | 1276 .toList(); |
| 1282 // | 1277 // |
| 1283 // Record outputs. | 1278 // Record outputs. |
| 1284 // | 1279 // |
| 1285 outputs[BUILD_LIBRARY_ERRORS] = errors; | 1280 outputs[BUILD_LIBRARY_ERRORS] = errors; |
| 1286 outputs[CLASS_ELEMENTS] = classElements; | 1281 outputs[CLASS_ELEMENTS] = classElements; |
| 1287 outputs[LIBRARY_ELEMENT1] = libraryElement; | 1282 outputs[LIBRARY_ELEMENT1] = libraryElement; |
| 1288 outputs[IS_LAUNCHABLE] = entryPoint != null; | 1283 outputs[IS_LAUNCHABLE] = entryPoint != null; |
| 1289 outputs[HAS_HTML_IMPORT] = hasHtmlImport; | |
| 1290 } | 1284 } |
| 1291 | 1285 |
| 1292 /** | 1286 /** |
| 1293 * Add all of the non-synthetic [getters] and [setters] defined in the given | 1287 * Add all of the non-synthetic [getters] and [setters] defined in the given |
| 1294 * [unit] that have no corresponding accessor to one of the given collections. | 1288 * [unit] that have no corresponding accessor to one of the given collections. |
| 1295 */ | 1289 */ |
| 1296 void _collectAccessors(Map<String, PropertyAccessorElement> getters, | 1290 void _collectAccessors(Map<String, PropertyAccessorElement> getters, |
| 1297 List<PropertyAccessorElement> setters, CompilationUnitElement unit) { | 1291 List<PropertyAccessorElement> setters, CompilationUnitElement unit) { |
| 1298 for (PropertyAccessorElement accessor in unit.accessors) { | 1292 for (PropertyAccessorElement accessor in unit.accessors) { |
| 1299 if (accessor.isGetter) { | 1293 if (accessor.isGetter) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 /** | 1448 /** |
| 1455 * The name of the export closure. | 1449 * The name of the export closure. |
| 1456 */ | 1450 */ |
| 1457 static const String EXPORT_CLOSURE_INPUT = 'EXPORT_CLOSURE_INPUT'; | 1451 static const String EXPORT_CLOSURE_INPUT = 'EXPORT_CLOSURE_INPUT'; |
| 1458 | 1452 |
| 1459 /** | 1453 /** |
| 1460 * The task descriptor describing this kind of task. | 1454 * The task descriptor describing this kind of task. |
| 1461 */ | 1455 */ |
| 1462 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 1456 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1463 'BuildExportSourceClosureTask', createTask, buildInputs, | 1457 'BuildExportSourceClosureTask', createTask, buildInputs, |
| 1464 <ResultDescriptor>[IMPORT_SOURCE_CLOSURE, EXPORT_SOURCE_CLOSURE]); | 1458 <ResultDescriptor>[ |
| 1459 IMPORT_SOURCE_CLOSURE, |
| 1460 EXPORT_SOURCE_CLOSURE, |
| 1461 IS_CLIENT |
| 1462 ]); |
| 1465 | 1463 |
| 1466 BuildSourceClosuresTask( | 1464 BuildSourceClosuresTask( |
| 1467 InternalAnalysisContext context, AnalysisTarget target) | 1465 InternalAnalysisContext context, AnalysisTarget target) |
| 1468 : super(context, target); | 1466 : super(context, target); |
| 1469 | 1467 |
| 1470 @override | 1468 @override |
| 1471 TaskDescriptor get descriptor => DESCRIPTOR; | 1469 TaskDescriptor get descriptor => DESCRIPTOR; |
| 1472 | 1470 |
| 1473 @override | 1471 @override |
| 1474 void internalPerform() { | 1472 void internalPerform() { |
| 1475 List<Source> importClosure = getRequiredInput(IMPORT_CLOSURE_INPUT); | 1473 List<Source> importClosure = getRequiredInput(IMPORT_CLOSURE_INPUT); |
| 1476 List<Source> exportClosure = getRequiredInput(EXPORT_CLOSURE_INPUT); | 1474 List<Source> exportClosure = getRequiredInput(EXPORT_CLOSURE_INPUT); |
| 1475 Source htmlSource = context.sourceFactory.forUri(DartSdk.DART_HTML); |
| 1477 // | 1476 // |
| 1478 // Record outputs. | 1477 // Record outputs. |
| 1479 // | 1478 // |
| 1480 outputs[IMPORT_SOURCE_CLOSURE] = importClosure; | 1479 outputs[IMPORT_SOURCE_CLOSURE] = importClosure; |
| 1481 outputs[EXPORT_SOURCE_CLOSURE] = exportClosure; | 1480 outputs[EXPORT_SOURCE_CLOSURE] = exportClosure; |
| 1481 outputs[IS_CLIENT] = importClosure.contains(htmlSource); |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 /** | 1484 /** |
| 1485 * Return a map from the names of the inputs of this kind of task to the task | 1485 * Return a map from the names of the inputs of this kind of task to the task |
| 1486 * input descriptors describing those inputs for a task with the | 1486 * input descriptors describing those inputs for a task with the |
| 1487 * given library [libSource]. | 1487 * given library [libSource]. |
| 1488 */ | 1488 */ |
| 1489 static Map<String, TaskInput> buildInputs(Source libSource) { | 1489 static Map<String, TaskInput> buildInputs(Source libSource) { |
| 1490 return <String, TaskInput>{ | 1490 return <String, TaskInput>{ |
| 1491 IMPORT_CLOSURE_INPUT: new _ImportSourceClosureTaskInput(libSource), | 1491 IMPORT_CLOSURE_INPUT: new _ImportSourceClosureTaskInput(libSource), |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2534 @override | 2534 @override |
| 2535 bool moveNext() { | 2535 bool moveNext() { |
| 2536 if (_newSources.isEmpty) { | 2536 if (_newSources.isEmpty) { |
| 2537 return false; | 2537 return false; |
| 2538 } | 2538 } |
| 2539 currentTarget = _newSources.first; | 2539 currentTarget = _newSources.first; |
| 2540 _newSources.remove(currentTarget); | 2540 _newSources.remove(currentTarget); |
| 2541 return true; | 2541 return true; |
| 2542 } | 2542 } |
| 2543 } | 2543 } |
| OLD | NEW |