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

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1561073007: Set LibraryElement.entryPoint properly during summary resynthesis. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698