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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 summary_resynthesizer; 5 library summary_resynthesizer;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/element_handle.dart'; 9 import 'package:analyzer/src/generated/element_handle.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 } 666 }
667 libraryElement.imports = imports; 667 libraryElement.imports = imports;
668 List<ExportElement> exports = <ExportElement>[]; 668 List<ExportElement> exports = <ExportElement>[];
669 assert(unlinkedDefiningUnit.exports.length == 669 assert(unlinkedDefiningUnit.exports.length ==
670 unlinkedDefiningUnit.publicNamespace.exports.length); 670 unlinkedDefiningUnit.publicNamespace.exports.length);
671 for (int i = 0; i < unlinkedDefiningUnit.exports.length; i++) { 671 for (int i = 0; i < unlinkedDefiningUnit.exports.length; i++) {
672 exports.add(buildExport(unlinkedDefiningUnit.publicNamespace.exports[i], 672 exports.add(buildExport(unlinkedDefiningUnit.publicNamespace.exports[i],
673 unlinkedDefiningUnit.exports[i])); 673 unlinkedDefiningUnit.exports[i]));
674 } 674 }
675 libraryElement.exports = exports; 675 libraryElement.exports = exports;
676 populateUnit(definingCompilationUnit, 0); 676 FunctionElement entryPoint = populateUnit(definingCompilationUnit, 0);
677 for (int i = 0; i < parts.length; i++) { 677 for (int i = 0; i < parts.length; i++) {
678 populateUnit(parts[i], i + 1); 678 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
679 if (entryPoint == null) {
680 entryPoint = unitEntryPoint;
681 }
679 } 682 }
683 libraryElement.entryPoint = entryPoint;
680 if (isCoreLibrary) { 684 if (isCoreLibrary) {
681 ClassElement objectElement = libraryElement.getType('Object'); 685 ClassElement objectElement = libraryElement.getType('Object');
682 assert(objectElement != null); 686 assert(objectElement != null);
683 for (ClassElementImpl classElement in delayedObjectSubclasses) { 687 for (ClassElementImpl classElement in delayedObjectSubclasses) {
684 classElement.supertype = objectElement.type; 688 classElement.supertype = objectElement.type;
685 } 689 }
686 } 690 }
687 return libraryElement; 691 return libraryElement;
688 } 692 }
689 693
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter, 927 void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter,
924 TypeParameterElementImpl typeParameterElement) { 928 TypeParameterElementImpl typeParameterElement) {
925 if (serializedTypeParameter.bound != null) { 929 if (serializedTypeParameter.bound != null) {
926 typeParameterElement.bound = buildType(serializedTypeParameter.bound); 930 typeParameterElement.bound = buildType(serializedTypeParameter.bound);
927 } 931 }
928 } 932 }
929 933
930 /** 934 /**
931 * Populate a [CompilationUnitElement] by deserializing all the elements 935 * Populate a [CompilationUnitElement] by deserializing all the elements
932 * contained in it. 936 * contained in it.
937 *
938 * If the compilation unit has an entry point, it is returned.
933 */ 939 */
934 void populateUnit(CompilationUnitElementImpl unit, int unitNum) { 940 FunctionElement populateUnit(CompilationUnitElementImpl unit, int unitNum) {
935 prelinkedUnit = prelinkedLibrary.units[unitNum]; 941 prelinkedUnit = prelinkedLibrary.units[unitNum];
936 unlinkedUnit = unlinkedUnits[unitNum]; 942 unlinkedUnit = unlinkedUnits[unitNum];
937 unitHolder = new ElementHolder(); 943 unitHolder = new ElementHolder();
938 unlinkedUnit.classes.forEach(buildClass); 944 unlinkedUnit.classes.forEach(buildClass);
939 unlinkedUnit.enums.forEach(buildEnum); 945 unlinkedUnit.enums.forEach(buildEnum);
940 unlinkedUnit.executables.forEach(buildExecutable); 946 unlinkedUnit.executables.forEach(buildExecutable);
941 unlinkedUnit.typedefs.forEach(buildTypedef); 947 unlinkedUnit.typedefs.forEach(buildTypedef);
942 unlinkedUnit.variables.forEach(buildVariable); 948 unlinkedUnit.variables.forEach(buildVariable);
943 String absoluteUri = unit.source.uri.toString(); 949 String absoluteUri = unit.source.uri.toString();
944 unit.accessors = unitHolder.accessors; 950 unit.accessors = unitHolder.accessors;
(...skipping 11 matching lines...) Expand all
956 Map<String, Element> elementMap = <String, Element>{}; 962 Map<String, Element> elementMap = <String, Element>{};
957 for (ClassElement cls in unit.types) { 963 for (ClassElement cls in unit.types) {
958 elementMap[cls.name] = cls; 964 elementMap[cls.name] = cls;
959 } 965 }
960 for (ClassElement cls in unit.enums) { 966 for (ClassElement cls in unit.enums) {
961 elementMap[cls.name] = cls; 967 elementMap[cls.name] = cls;
962 } 968 }
963 for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) { 969 for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) {
964 elementMap[typeAlias.name] = typeAlias; 970 elementMap[typeAlias.name] = typeAlias;
965 } 971 }
972 FunctionElement entryPoint = null;
973 for (FunctionElement function in unit.functions) {
974 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.
975 entryPoint = function;
976 break;
977 }
978 }
966 resummarizedElements[absoluteUri] = elementMap; 979 resummarizedElements[absoluteUri] = elementMap;
967 unitHolder = null; 980 unitHolder = null;
968 prelinkedUnit = null; 981 prelinkedUnit = null;
969 unlinkedUnit = null; 982 unlinkedUnit = null;
983 return entryPoint;
970 } 984 }
971 } 985 }
OLDNEW
« 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