| 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/standard_ast_factory.dart'; | 10 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 String uri = unlinkedUnits[0].publicNamespace.parts[unit - 1]; | 1076 String uri = unlinkedUnits[0].publicNamespace.parts[unit - 1]; |
| 1077 Source partSource = | 1077 Source partSource = |
| 1078 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri); | 1078 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri); |
| 1079 partUri = partSource.uri.toString(); | 1079 partUri = partSource.uri.toString(); |
| 1080 } else { | 1080 } else { |
| 1081 partUri = referencedLibraryUri; | 1081 partUri = referencedLibraryUri; |
| 1082 } | 1082 } |
| 1083 return <String>[referencedLibraryUri, partUri, name]; | 1083 return <String>[referencedLibraryUri, partUri, name]; |
| 1084 } | 1084 } |
| 1085 LinkedDependency dependency = linkedLibrary.dependencies[dependencyIndex]; | 1085 LinkedDependency dependency = linkedLibrary.dependencies[dependencyIndex]; |
| 1086 Source referencedLibrarySource = summaryResynthesizer.sourceFactory | 1086 Source referencedLibrarySource = |
| 1087 .resolveUri(librarySource, dependency.uri); | 1087 summaryResynthesizer.sourceFactory.forUri(dependency.uri); |
| 1088 String referencedLibraryUri = referencedLibrarySource.uri.toString(); | 1088 String referencedLibraryUri = referencedLibrarySource.uri.toString(); |
| 1089 String partUri; | 1089 String partUri; |
| 1090 if (unit != 0) { | 1090 if (unit != 0) { |
| 1091 String uri = dependency.parts[unit - 1]; | 1091 partUri = dependency.parts[unit - 1]; |
| 1092 Source partSource = | |
| 1093 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri); | |
| 1094 partUri = partSource.uri.toString(); | |
| 1095 } else { | 1092 } else { |
| 1096 partUri = referencedLibraryUri; | 1093 partUri = referencedLibraryUri; |
| 1097 } | 1094 } |
| 1098 return <String>[referencedLibraryUri, partUri, name]; | 1095 return <String>[referencedLibraryUri, partUri, name]; |
| 1099 } | 1096 } |
| 1100 | 1097 |
| 1101 /** | 1098 /** |
| 1102 * Remember the absolute URI to the corresponding unit mapping. | 1099 * Remember the absolute URI to the corresponding unit mapping. |
| 1103 */ | 1100 */ |
| 1104 void rememberUriToUnit(_UnitResynthesizer unitResynthesized) { | 1101 void rememberUriToUnit(_UnitResynthesizer unitResynthesized) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1127 @override | 1124 @override |
| 1128 Namespace buildExportNamespace() { | 1125 Namespace buildExportNamespace() { |
| 1129 LibraryElementImpl library = resynthesizer.library; | 1126 LibraryElementImpl library = resynthesizer.library; |
| 1130 return resynthesizer.buildExportNamespace( | 1127 return resynthesizer.buildExportNamespace( |
| 1131 library.publicNamespace, resynthesizer.linkedLibrary.exportNames); | 1128 library.publicNamespace, resynthesizer.linkedLibrary.exportNames); |
| 1132 } | 1129 } |
| 1133 | 1130 |
| 1134 @override | 1131 @override |
| 1135 LibraryElement buildImportedLibrary(int dependency) { | 1132 LibraryElement buildImportedLibrary(int dependency) { |
| 1136 String depUri = resynthesizer.linkedLibrary.dependencies[dependency].uri; | 1133 String depUri = resynthesizer.linkedLibrary.dependencies[dependency].uri; |
| 1137 return _getLibraryByRelativeUri(depUri); | 1134 return _getLibraryByAbsoluteUri(depUri); |
| 1138 } | 1135 } |
| 1139 | 1136 |
| 1140 @override | 1137 @override |
| 1141 Namespace buildPublicNamespace() { | 1138 Namespace buildPublicNamespace() { |
| 1142 LibraryElementImpl library = resynthesizer.library; | 1139 LibraryElementImpl library = resynthesizer.library; |
| 1143 return new NamespaceBuilder().createPublicNamespaceForLibrary(library); | 1140 return new NamespaceBuilder().createPublicNamespaceForLibrary(library); |
| 1144 } | 1141 } |
| 1145 | 1142 |
| 1146 @override | 1143 @override |
| 1147 FunctionElement findEntryPoint() { | 1144 FunctionElement findEntryPoint() { |
| 1148 LibraryElementImpl library = resynthesizer.library; | 1145 LibraryElementImpl library = resynthesizer.library; |
| 1149 Element entryPoint = | 1146 Element entryPoint = |
| 1150 library.exportNamespace.get(FunctionElement.MAIN_FUNCTION_NAME); | 1147 library.exportNamespace.get(FunctionElement.MAIN_FUNCTION_NAME); |
| 1151 if (entryPoint is FunctionElement) { | 1148 if (entryPoint is FunctionElement) { |
| 1152 return entryPoint; | 1149 return entryPoint; |
| 1153 } | 1150 } |
| 1154 return null; | 1151 return null; |
| 1155 } | 1152 } |
| 1156 | 1153 |
| 1157 @override | 1154 @override |
| 1158 void patchTopLevelAccessors() { | 1155 void patchTopLevelAccessors() { |
| 1159 LibraryElementImpl library = resynthesizer.library; | 1156 LibraryElementImpl library = resynthesizer.library; |
| 1160 BuildLibraryElementUtils.patchTopLevelAccessors(library); | 1157 BuildLibraryElementUtils.patchTopLevelAccessors(library); |
| 1161 } | 1158 } |
| 1162 | 1159 |
| 1160 LibraryElementHandle _getLibraryByAbsoluteUri(String uriStr) { |
| 1161 Source source = |
| 1162 resynthesizer.summaryResynthesizer.sourceFactory.forUri(uriStr); |
| 1163 if (source == null) { |
| 1164 return null; |
| 1165 } |
| 1166 return new LibraryElementHandle(resynthesizer.summaryResynthesizer, |
| 1167 new ElementLocationImpl.con3(<String>[uriStr])); |
| 1168 } |
| 1169 |
| 1163 LibraryElementHandle _getLibraryByRelativeUri(String depUri) { | 1170 LibraryElementHandle _getLibraryByRelativeUri(String depUri) { |
| 1164 Source source = resynthesizer.summaryResynthesizer.sourceFactory | 1171 Source source = resynthesizer.summaryResynthesizer.sourceFactory |
| 1165 .resolveUri(resynthesizer.librarySource, depUri); | 1172 .resolveUri(resynthesizer.librarySource, depUri); |
| 1166 if (source == null) { | 1173 if (source == null) { |
| 1167 return null; | 1174 return null; |
| 1168 } | 1175 } |
| 1169 String absoluteUri = source.uri.toString(); | 1176 String absoluteUri = source.uri.toString(); |
| 1170 return new LibraryElementHandle(resynthesizer.summaryResynthesizer, | 1177 return new LibraryElementHandle(resynthesizer.summaryResynthesizer, |
| 1171 new ElementLocationImpl.con3(<String>[absoluteUri])); | 1178 new ElementLocationImpl.con3(<String>[absoluteUri])); |
| 1172 } | 1179 } |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 static String _getElementIdentifier(String name, ReferenceKind kind) { | 1943 static String _getElementIdentifier(String name, ReferenceKind kind) { |
| 1937 if (kind == ReferenceKind.topLevelPropertyAccessor || | 1944 if (kind == ReferenceKind.topLevelPropertyAccessor || |
| 1938 kind == ReferenceKind.propertyAccessor) { | 1945 kind == ReferenceKind.propertyAccessor) { |
| 1939 if (!name.endsWith('=')) { | 1946 if (!name.endsWith('=')) { |
| 1940 return name + '?'; | 1947 return name + '?'; |
| 1941 } | 1948 } |
| 1942 } | 1949 } |
| 1943 return name; | 1950 return name; |
| 1944 } | 1951 } |
| 1945 } | 1952 } |
| OLD | NEW |