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

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1576213002: Compute exportNamespace during resynthesizing. (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
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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 684 }
685 libraryElement.imports = imports; 685 libraryElement.imports = imports;
686 List<ExportElement> exports = <ExportElement>[]; 686 List<ExportElement> exports = <ExportElement>[];
687 assert(unlinkedDefiningUnit.exports.length == 687 assert(unlinkedDefiningUnit.exports.length ==
688 unlinkedDefiningUnit.publicNamespace.exports.length); 688 unlinkedDefiningUnit.publicNamespace.exports.length);
689 for (int i = 0; i < unlinkedDefiningUnit.exports.length; i++) { 689 for (int i = 0; i < unlinkedDefiningUnit.exports.length; i++) {
690 exports.add(buildExport(unlinkedDefiningUnit.publicNamespace.exports[i], 690 exports.add(buildExport(unlinkedDefiningUnit.publicNamespace.exports[i],
691 unlinkedDefiningUnit.exports[i])); 691 unlinkedDefiningUnit.exports[i]));
692 } 692 }
693 libraryElement.exports = exports; 693 libraryElement.exports = exports;
694 FunctionElement entryPoint = populateUnit(definingCompilationUnit, 0); 694 populateUnit(definingCompilationUnit, 0);
695 for (int i = 0; i < parts.length; i++) { 695 for (int i = 0; i < parts.length; i++) {
696 FunctionElement unitEntryPoint = populateUnit(parts[i], i + 1); 696 populateUnit(parts[i], i + 1);
697 if (entryPoint == null) {
698 entryPoint = unitEntryPoint;
699 }
700 } 697 }
701 // TODO(paulberry): also look for entry points in exports.
702 libraryElement.entryPoint = entryPoint;
703 if (isCoreLibrary) { 698 if (isCoreLibrary) {
704 ClassElement objectElement = libraryElement.getType('Object'); 699 ClassElement objectElement = libraryElement.getType('Object');
705 assert(objectElement != null); 700 assert(objectElement != null);
706 for (ClassElementImpl classElement in delayedObjectSubclasses) { 701 for (ClassElementImpl classElement in delayedObjectSubclasses) {
707 classElement.supertype = objectElement.type; 702 classElement.supertype = objectElement.type;
708 } 703 }
709 } 704 }
710 // Compute public namespace. 705 // Compute namespaces.
711 libraryElement.publicNamespace = 706 libraryElement.publicNamespace =
712 new NamespaceBuilder().createPublicNamespaceForLibrary(libraryElement); 707 new NamespaceBuilder().createPublicNamespaceForLibrary(libraryElement);
708 libraryElement.exportNamespace =
Paul Berry 2016/01/11 23:33:40 Please add: // TODO(paulberry): compute the expor
709 new NamespaceBuilder().createExportNamespaceForLibrary(libraryElement);
710 // Find the entry point.
711 libraryElement.entryPoint =
712 libraryElement.exportNamespace.definedNames.values.firstWhere(
713 (element) => element is FunctionElement && element.isEntryPoint,
714 orElse: () => null);
713 // Done. 715 // Done.
714 return libraryElement; 716 return libraryElement;
715 } 717 }
716 718
717 /** 719 /**
718 * Resynthesize a [ParameterElement]. 720 * Resynthesize a [ParameterElement].
719 */ 721 */
720 ParameterElement buildParameter(UnlinkedParam serializedParameter) { 722 ParameterElement buildParameter(UnlinkedParam serializedParameter) {
721 ParameterElementImpl parameterElement = new ParameterElementImpl( 723 ParameterElementImpl parameterElement = new ParameterElementImpl(
722 serializedParameter.name, serializedParameter.nameOffset); 724 serializedParameter.name, serializedParameter.nameOffset);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter, 956 void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter,
955 TypeParameterElementImpl typeParameterElement) { 957 TypeParameterElementImpl typeParameterElement) {
956 if (serializedTypeParameter.bound != null) { 958 if (serializedTypeParameter.bound != null) {
957 typeParameterElement.bound = buildType(serializedTypeParameter.bound); 959 typeParameterElement.bound = buildType(serializedTypeParameter.bound);
958 } 960 }
959 } 961 }
960 962
961 /** 963 /**
962 * Populate a [CompilationUnitElement] by deserializing all the elements 964 * Populate a [CompilationUnitElement] by deserializing all the elements
963 * contained in it. 965 * contained in it.
964 *
965 * If the compilation unit has an entry point, it is returned.
966 */ 966 */
967 FunctionElement populateUnit(CompilationUnitElementImpl unit, int unitNum) { 967 void populateUnit(CompilationUnitElementImpl unit, int unitNum) {
968 prelinkedUnit = prelinkedLibrary.units[unitNum]; 968 prelinkedUnit = prelinkedLibrary.units[unitNum];
969 unlinkedUnit = unlinkedUnits[unitNum]; 969 unlinkedUnit = unlinkedUnits[unitNum];
970 unitHolder = new ElementHolder(); 970 unitHolder = new ElementHolder();
971 unlinkedUnit.classes.forEach(buildClass); 971 unlinkedUnit.classes.forEach(buildClass);
972 unlinkedUnit.enums.forEach(buildEnum); 972 unlinkedUnit.enums.forEach(buildEnum);
973 unlinkedUnit.executables.forEach(buildExecutable); 973 unlinkedUnit.executables.forEach(buildExecutable);
974 unlinkedUnit.typedefs.forEach(buildTypedef); 974 unlinkedUnit.typedefs.forEach(buildTypedef);
975 unlinkedUnit.variables.forEach(buildVariable); 975 unlinkedUnit.variables.forEach(buildVariable);
976 String absoluteUri = unit.source.uri.toString(); 976 String absoluteUri = unit.source.uri.toString();
977 unit.accessors = unitHolder.accessors; 977 unit.accessors = unitHolder.accessors;
(...skipping 11 matching lines...) Expand all
989 Map<String, Element> elementMap = <String, Element>{}; 989 Map<String, Element> elementMap = <String, Element>{};
990 for (ClassElement cls in unit.types) { 990 for (ClassElement cls in unit.types) {
991 elementMap[cls.name] = cls; 991 elementMap[cls.name] = cls;
992 } 992 }
993 for (ClassElement cls in unit.enums) { 993 for (ClassElement cls in unit.enums) {
994 elementMap[cls.name] = cls; 994 elementMap[cls.name] = cls;
995 } 995 }
996 for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) { 996 for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) {
997 elementMap[typeAlias.name] = typeAlias; 997 elementMap[typeAlias.name] = typeAlias;
998 } 998 }
999 FunctionElement entryPoint = null;
1000 for (FunctionElement function in unit.functions) {
1001 if (function.isEntryPoint) {
1002 entryPoint = function;
1003 break;
1004 }
1005 }
1006 resummarizedElements[absoluteUri] = elementMap; 999 resummarizedElements[absoluteUri] = elementMap;
1007 unitHolder = null; 1000 unitHolder = null;
1008 prelinkedUnit = null; 1001 prelinkedUnit = null;
1009 unlinkedUnit = null; 1002 unlinkedUnit = null;
1010 return entryPoint;
1011 } 1003 }
1012 } 1004 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698