| 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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 /** | 1190 /** |
| 1191 * Resynthesize an [ImportElement]. | 1191 * Resynthesize an [ImportElement]. |
| 1192 */ | 1192 */ |
| 1193 ImportElement buildImport( | 1193 ImportElement buildImport( |
| 1194 _UnitResynthesizer definingUnitResynthesizer, | 1194 _UnitResynthesizer definingUnitResynthesizer, |
| 1195 UnlinkedImport serializedImport, | 1195 UnlinkedImport serializedImport, |
| 1196 int dependency, | 1196 int dependency, |
| 1197 LibraryElement libraryBeingResynthesized) { | 1197 LibraryElement libraryBeingResynthesized) { |
| 1198 bool isSynthetic = serializedImport.isImplicit; | 1198 ImportElementImpl importElement = new ImportElementImpl.forSerialized( |
| 1199 ImportElementImpl importElement = | 1199 serializedImport, dependency, library); |
| 1200 new ImportElementImpl(isSynthetic ? -1 : serializedImport.offset); | |
| 1201 if (dependency == 0) { | |
| 1202 importElement.importedLibrary = libraryBeingResynthesized; | |
| 1203 } else { | |
| 1204 String absoluteUri = summaryResynthesizer.sourceFactory | |
| 1205 .resolveUri(librarySource, linkedLibrary.dependencies[dependency].uri) | |
| 1206 .uri | |
| 1207 .toString(); | |
| 1208 importElement.importedLibrary = new LibraryElementHandle( | |
| 1209 summaryResynthesizer, | |
| 1210 new ElementLocationImpl.con3(<String>[absoluteUri])); | |
| 1211 } | |
| 1212 if (isSynthetic) { | |
| 1213 importElement.synthetic = true; | |
| 1214 } else { | |
| 1215 importElement.uri = serializedImport.uri; | |
| 1216 importElement.uriOffset = serializedImport.uriOffset; | |
| 1217 importElement.uriEnd = serializedImport.uriEnd; | |
| 1218 importElement.deferred = serializedImport.isDeferred; | |
| 1219 definingUnitResynthesizer.buildAnnotations( | |
| 1220 importElement, serializedImport.annotations); | |
| 1221 } | |
| 1222 importElement.prefixOffset = serializedImport.prefixOffset; | |
| 1223 if (serializedImport.prefixReference != 0) { | |
| 1224 UnlinkedReference serializedPrefix = | |
| 1225 unlinkedUnits[0].references[serializedImport.prefixReference]; | |
| 1226 importElement.prefix = new PrefixElementImpl( | |
| 1227 serializedPrefix.name, serializedImport.prefixOffset); | |
| 1228 } | |
| 1229 importElement.combinators = | 1200 importElement.combinators = |
| 1230 serializedImport.combinators.map(buildCombinator).toList(); | 1201 serializedImport.combinators.map(buildCombinator).toList(); |
| 1231 return importElement; | 1202 return importElement; |
| 1232 } | 1203 } |
| 1233 | 1204 |
| 1234 /** | 1205 /** |
| 1235 * Main entry point. Resynthesize the [LibraryElement] and return it. | 1206 * Main entry point. Resynthesize the [LibraryElement] and return it. |
| 1236 */ | 1207 */ |
| 1237 LibraryElement buildLibrary() { | 1208 LibraryElement buildLibrary() { |
| 1238 // Create LibraryElementImpl. | 1209 // Create LibraryElementImpl. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 _LibraryResynthesizerContext(this.resynthesizer); | 1368 _LibraryResynthesizerContext(this.resynthesizer); |
| 1398 | 1369 |
| 1399 @override | 1370 @override |
| 1400 Namespace buildExportNamespace() { | 1371 Namespace buildExportNamespace() { |
| 1401 LibraryElementImpl library = resynthesizer.library; | 1372 LibraryElementImpl library = resynthesizer.library; |
| 1402 return resynthesizer.buildExportNamespace( | 1373 return resynthesizer.buildExportNamespace( |
| 1403 library.publicNamespace, resynthesizer.linkedLibrary.exportNames); | 1374 library.publicNamespace, resynthesizer.linkedLibrary.exportNames); |
| 1404 } | 1375 } |
| 1405 | 1376 |
| 1406 @override | 1377 @override |
| 1378 LibraryElement buildImportedLibrary(int dependency) { |
| 1379 String absoluteUri = resynthesizer.summaryResynthesizer.sourceFactory |
| 1380 .resolveUri(resynthesizer.librarySource, |
| 1381 resynthesizer.linkedLibrary.dependencies[dependency].uri) |
| 1382 .uri |
| 1383 .toString(); |
| 1384 return new LibraryElementHandle(resynthesizer.summaryResynthesizer, |
| 1385 new ElementLocationImpl.con3(<String>[absoluteUri])); |
| 1386 } |
| 1387 |
| 1388 @override |
| 1407 Namespace buildPublicNamespace() { | 1389 Namespace buildPublicNamespace() { |
| 1408 LibraryElementImpl library = resynthesizer.library; | 1390 LibraryElementImpl library = resynthesizer.library; |
| 1409 return new NamespaceBuilder().createPublicNamespaceForLibrary(library); | 1391 return new NamespaceBuilder().createPublicNamespaceForLibrary(library); |
| 1410 } | 1392 } |
| 1411 | 1393 |
| 1412 @override | 1394 @override |
| 1413 FunctionElement findEntryPoint() { | 1395 FunctionElement findEntryPoint() { |
| 1414 LibraryElementImpl library = resynthesizer.library; | 1396 LibraryElementImpl library = resynthesizer.library; |
| 1415 Element entryPoint = | 1397 Element entryPoint = |
| 1416 library.exportNamespace.get(FunctionElement.MAIN_FUNCTION_NAME); | 1398 library.exportNamespace.get(FunctionElement.MAIN_FUNCTION_NAME); |
| (...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3062 static String _getElementIdentifier(String name, ReferenceKind kind) { | 3044 static String _getElementIdentifier(String name, ReferenceKind kind) { |
| 3063 if (kind == ReferenceKind.topLevelPropertyAccessor || | 3045 if (kind == ReferenceKind.topLevelPropertyAccessor || |
| 3064 kind == ReferenceKind.propertyAccessor) { | 3046 kind == ReferenceKind.propertyAccessor) { |
| 3065 if (!name.endsWith('=')) { | 3047 if (!name.endsWith('=')) { |
| 3066 return name + '?'; | 3048 return name + '?'; |
| 3067 } | 3049 } |
| 3068 } | 3050 } |
| 3069 return name; | 3051 return name; |
| 3070 } | 3052 } |
| 3071 } | 3053 } |
| OLD | NEW |