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