Chromium Code Reviews| Index: pkg/analyzer/lib/src/summary/resynthesize.dart |
| diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart |
| index 9771f0205a86c639bcdf4852641d7aca289cd7d0..e29c65fe07feb43e783704e0bbf530d6d5709bf7 100644 |
| --- a/pkg/analyzer/lib/src/summary/resynthesize.dart |
| +++ b/pkg/analyzer/lib/src/summary/resynthesize.dart |
| @@ -673,10 +673,14 @@ class _LibraryResynthesizer { |
| unlinkedDefiningUnit.exports[i])); |
| } |
| libraryElement.exports = exports; |
| - populateUnit(definingCompilationUnit, 0); |
| + FunctionElement entryPoint = populateUnit(definingCompilationUnit, 0); |
| for (int i = 0; i < parts.length; i++) { |
| - populateUnit(parts[i], i + 1); |
| + FunctionElement unitEntryPoint = populateUnit(parts[i], i + 1); |
|
scheglov
2016/01/08 06:17:44
We need to check also exported libraries.
18.4 Sc
Paul Berry
2016/01/08 18:25:57
Oops, good catch! I've added failing tests and a
|
| + if (entryPoint == null) { |
| + entryPoint = unitEntryPoint; |
| + } |
| } |
| + libraryElement.entryPoint = entryPoint; |
| if (isCoreLibrary) { |
| ClassElement objectElement = libraryElement.getType('Object'); |
| assert(objectElement != null); |
| @@ -930,8 +934,10 @@ class _LibraryResynthesizer { |
| /** |
| * Populate a [CompilationUnitElement] by deserializing all the elements |
| * contained in it. |
| + * |
| + * If the compilation unit has an entry point, it is returned. |
| */ |
| - void populateUnit(CompilationUnitElementImpl unit, int unitNum) { |
| + FunctionElement populateUnit(CompilationUnitElementImpl unit, int unitNum) { |
| prelinkedUnit = prelinkedLibrary.units[unitNum]; |
| unlinkedUnit = unlinkedUnits[unitNum]; |
| unitHolder = new ElementHolder(); |
| @@ -963,9 +969,17 @@ class _LibraryResynthesizer { |
| for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) { |
| elementMap[typeAlias.name] = typeAlias; |
| } |
| + FunctionElement entryPoint = null; |
| + for (FunctionElement function in unit.functions) { |
| + if (function.name == 'main') { |
|
scheglov
2016/01/08 06:17:44
Or could also use `function.isEntryPoint` instead.
Paul Berry
2016/01/08 18:25:57
Done.
|
| + entryPoint = function; |
| + break; |
| + } |
| + } |
| resummarizedElements[absoluteUri] = elementMap; |
| unitHolder = null; |
| prelinkedUnit = null; |
| unlinkedUnit = null; |
| + return entryPoint; |
| } |
| } |