| 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 summary_resynthesizer; | 5 library summary_resynthesizer; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 for (LinkedExportName exportName in exportNames) { | 1047 for (LinkedExportName exportName in exportNames) { |
| 1048 definedNames.putIfAbsent( | 1048 definedNames.putIfAbsent( |
| 1049 exportName.name, () => buildExportName(exportName)); | 1049 exportName.name, () => buildExportName(exportName)); |
| 1050 } | 1050 } |
| 1051 return new Namespace(definedNames); | 1051 return new Namespace(definedNames); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 /** | 1054 /** |
| 1055 * Resynthesize an [ImportElement]. | 1055 * Resynthesize an [ImportElement]. |
| 1056 */ | 1056 */ |
| 1057 ImportElement buildImport(_UnitResynthesizer definingUnitResynthesizer, | 1057 ImportElement buildImport( |
| 1058 UnlinkedImport serializedImport, int dependency) { | 1058 _UnitResynthesizer definingUnitResynthesizer, |
| 1059 UnlinkedImport serializedImport, |
| 1060 int dependency, |
| 1061 LibraryElement libraryBeingResynthesized) { |
| 1059 bool isSynthetic = serializedImport.isImplicit; | 1062 bool isSynthetic = serializedImport.isImplicit; |
| 1060 ImportElementImpl importElement = | 1063 ImportElementImpl importElement = |
| 1061 new ImportElementImpl(isSynthetic ? -1 : serializedImport.offset); | 1064 new ImportElementImpl(isSynthetic ? -1 : serializedImport.offset); |
| 1062 String absoluteUri = summaryResynthesizer.sourceFactory | 1065 if (dependency == 0) { |
| 1063 .resolveUri(librarySource, linkedLibrary.dependencies[dependency].uri) | 1066 importElement.importedLibrary = libraryBeingResynthesized; |
| 1064 .uri | 1067 } else { |
| 1065 .toString(); | 1068 String absoluteUri = summaryResynthesizer.sourceFactory |
| 1066 importElement.importedLibrary = new LibraryElementHandle( | 1069 .resolveUri(librarySource, linkedLibrary.dependencies[dependency].uri) |
| 1067 summaryResynthesizer, | 1070 .uri |
| 1068 new ElementLocationImpl.con3(<String>[absoluteUri])); | 1071 .toString(); |
| 1072 importElement.importedLibrary = new LibraryElementHandle( |
| 1073 summaryResynthesizer, |
| 1074 new ElementLocationImpl.con3(<String>[absoluteUri])); |
| 1075 } |
| 1069 if (isSynthetic) { | 1076 if (isSynthetic) { |
| 1070 importElement.synthetic = true; | 1077 importElement.synthetic = true; |
| 1071 } else { | 1078 } else { |
| 1072 importElement.uri = serializedImport.uri; | 1079 importElement.uri = serializedImport.uri; |
| 1073 importElement.uriOffset = serializedImport.uriOffset; | 1080 importElement.uriOffset = serializedImport.uriOffset; |
| 1074 importElement.uriEnd = serializedImport.uriEnd; | 1081 importElement.uriEnd = serializedImport.uriEnd; |
| 1075 importElement.deferred = serializedImport.isDeferred; | 1082 importElement.deferred = serializedImport.isDeferred; |
| 1076 definingUnitResynthesizer.buildAnnotations( | 1083 definingUnitResynthesizer.buildAnnotations( |
| 1077 importElement, serializedImport.annotations); | 1084 importElement, serializedImport.annotations); |
| 1078 } | 1085 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 i); | 1130 i); |
| 1124 partUnits.add(part); | 1131 partUnits.add(part); |
| 1125 } | 1132 } |
| 1126 library.parts = partUnits; | 1133 library.parts = partUnits; |
| 1127 // Create imports. | 1134 // Create imports. |
| 1128 List<ImportElement> imports = <ImportElement>[]; | 1135 List<ImportElement> imports = <ImportElement>[]; |
| 1129 for (int i = 0; i < unlinkedDefiningUnit.imports.length; i++) { | 1136 for (int i = 0; i < unlinkedDefiningUnit.imports.length; i++) { |
| 1130 imports.add(buildImport( | 1137 imports.add(buildImport( |
| 1131 definingUnitResynthesizer, | 1138 definingUnitResynthesizer, |
| 1132 unlinkedDefiningUnit.imports[i], | 1139 unlinkedDefiningUnit.imports[i], |
| 1133 linkedLibrary.importDependencies[i])); | 1140 linkedLibrary.importDependencies[i], |
| 1141 library)); |
| 1134 } | 1142 } |
| 1135 library.imports = imports; | 1143 library.imports = imports; |
| 1136 // Create exports. | 1144 // Create exports. |
| 1137 List<ExportElement> exports = <ExportElement>[]; | 1145 List<ExportElement> exports = <ExportElement>[]; |
| 1138 assert(unlinkedDefiningUnit.exports.length == | 1146 assert(unlinkedDefiningUnit.exports.length == |
| 1139 unlinkedDefiningUnit.publicNamespace.exports.length); | 1147 unlinkedDefiningUnit.publicNamespace.exports.length); |
| 1140 for (int i = 0; i < unlinkedDefiningUnit.exports.length; i++) { | 1148 for (int i = 0; i < unlinkedDefiningUnit.exports.length; i++) { |
| 1141 exports.add(buildExport( | 1149 exports.add(buildExport( |
| 1142 definingUnitResynthesizer, | 1150 definingUnitResynthesizer, |
| 1143 unlinkedDefiningUnit.publicNamespace.exports[i], | 1151 unlinkedDefiningUnit.publicNamespace.exports[i], |
| (...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2639 static String _getElementIdentifier(String name, ReferenceKind kind) { | 2647 static String _getElementIdentifier(String name, ReferenceKind kind) { |
| 2640 if (kind == ReferenceKind.topLevelPropertyAccessor || | 2648 if (kind == ReferenceKind.topLevelPropertyAccessor || |
| 2641 kind == ReferenceKind.propertyAccessor) { | 2649 kind == ReferenceKind.propertyAccessor) { |
| 2642 if (!name.endsWith('=')) { | 2650 if (!name.endsWith('=')) { |
| 2643 return name + '?'; | 2651 return name + '?'; |
| 2644 } | 2652 } |
| 2645 } | 2653 } |
| 2646 return name; | 2654 return name; |
| 2647 } | 2655 } |
| 2648 } | 2656 } |
| OLD | NEW |