| OLD | NEW |
| 1 import 'dart:io' as io; | 1 import 'dart:io' as io; |
| 2 | 2 |
| 3 import 'package:analyzer/dart/element/element.dart'; | 3 import 'package:analyzer/dart/element/element.dart'; |
| 4 import 'package:analyzer/src/context/cache.dart'; | 4 import 'package:analyzer/src/context/cache.dart'; |
| 5 import 'package:analyzer/src/context/context.dart'; | 5 import 'package:analyzer/src/context/context.dart'; |
| 6 import 'package:analyzer/src/dart/element/element.dart'; | 6 import 'package:analyzer/src/dart/element/element.dart'; |
| 7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/generated/java_io.dart'; | 8 import 'package:analyzer/src/generated/java_io.dart'; |
| 9 import 'package:analyzer/src/generated/resolver.dart'; | 9 import 'package:analyzer/src/generated/resolver.dart'; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 entry.setValue(result, SourceKind.LIBRARY, TargetedResult.EMPTY_LIST); | 179 entry.setValue(result, SourceKind.LIBRARY, TargetedResult.EMPTY_LIST); |
| 180 return true; | 180 return true; |
| 181 } | 181 } |
| 182 if (_dataStore.unlinkedMap.containsKey(uriString)) { | 182 if (_dataStore.unlinkedMap.containsKey(uriString)) { |
| 183 entry.setValue(result, SourceKind.PART, TargetedResult.EMPTY_LIST); | 183 entry.setValue(result, SourceKind.PART, TargetedResult.EMPTY_LIST); |
| 184 return true; | 184 return true; |
| 185 } | 185 } |
| 186 return false; | 186 return false; |
| 187 } else if (result == CONTAINING_LIBRARIES) { | 187 } else if (result == CONTAINING_LIBRARIES) { |
| 188 List<String> libraryUriStrings = | 188 List<String> libraryUriStrings = |
| 189 _dataStore._getContainingLibraryUris(uriString); | 189 _dataStore.getContainingLibraryUris(uriString); |
| 190 if (libraryUriStrings != null) { | 190 if (libraryUriStrings != null) { |
| 191 List<Source> librarySources = libraryUriStrings | 191 List<Source> librarySources = libraryUriStrings |
| 192 .map((libraryUriString) => | 192 .map((libraryUriString) => |
| 193 context.sourceFactory.resolveUri(target, libraryUriString)) | 193 context.sourceFactory.resolveUri(target, libraryUriString)) |
| 194 .toList(growable: false); | 194 .toList(growable: false); |
| 195 entry.setValue(result, librarySources, TargetedResult.EMPTY_LIST); | 195 entry.setValue(result, librarySources, TargetedResult.EMPTY_LIST); |
| 196 return true; | 196 return true; |
| 197 } | 197 } |
| 198 return false; | 198 return false; |
| 199 } | 199 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 String uri = bundle.unlinkedUnitUris[i]; | 301 String uri = bundle.unlinkedUnitUris[i]; |
| 302 uriToSummaryPath[uri] = path; | 302 uriToSummaryPath[uri] = path; |
| 303 unlinkedMap[uri] = bundle.unlinkedUnits[i]; | 303 unlinkedMap[uri] = bundle.unlinkedUnits[i]; |
| 304 } | 304 } |
| 305 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { | 305 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { |
| 306 String uri = bundle.linkedLibraryUris[i]; | 306 String uri = bundle.linkedLibraryUris[i]; |
| 307 linkedMap[uri] = bundle.linkedLibraries[i]; | 307 linkedMap[uri] = bundle.linkedLibraries[i]; |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 void _fillMaps(String path) { | |
| 312 io.File file = new io.File(path); | |
| 313 List<int> buffer = file.readAsBytesSync(); | |
| 314 PackageBundle bundle = new PackageBundle.fromBuffer(buffer); | |
| 315 addBundle(path, bundle); | |
| 316 } | |
| 317 | |
| 318 /** | 311 /** |
| 319 * Return a list of absolute URIs of the libraries that contain the unit with | 312 * Return a list of absolute URIs of the libraries that contain the unit with |
| 320 * the given [unitUriString], or `null` if no such library is in the store. | 313 * the given [unitUriString], or `null` if no such library is in the store. |
| 321 */ | 314 */ |
| 322 List<String> _getContainingLibraryUris(String unitUriString) { | 315 List<String> getContainingLibraryUris(String unitUriString) { |
| 323 // The unit is the defining unit of a library. | 316 // The unit is the defining unit of a library. |
| 324 if (linkedMap.containsKey(unitUriString)) { | 317 if (linkedMap.containsKey(unitUriString)) { |
| 325 return <String>[unitUriString]; | 318 return <String>[unitUriString]; |
| 326 } | 319 } |
| 327 // Check every unlinked unit whether it uses [unitUri] as a part. | 320 // Check every unlinked unit whether it uses [unitUri] as a part. |
| 328 List<String> libraryUriStrings = <String>[]; | 321 List<String> libraryUriStrings = <String>[]; |
| 329 unlinkedMap.forEach((unlinkedUnitUriString, unlinkedUnit) { | 322 unlinkedMap.forEach((unlinkedUnitUriString, unlinkedUnit) { |
| 330 Uri libraryUri = FastUri.parse(unlinkedUnitUriString); | 323 Uri libraryUri = FastUri.parse(unlinkedUnitUriString); |
| 331 for (String partUriString in unlinkedUnit.publicNamespace.parts) { | 324 for (String partUriString in unlinkedUnit.publicNamespace.parts) { |
| 332 Uri partUri = FastUri.parse(partUriString); | 325 Uri partUri = FastUri.parse(partUriString); |
| 333 String partAbsoluteUriString = | 326 String partAbsoluteUriString = |
| 334 resolveRelativeUri(libraryUri, partUri).toString(); | 327 resolveRelativeUri(libraryUri, partUri).toString(); |
| 335 if (partAbsoluteUriString == unitUriString) { | 328 if (partAbsoluteUriString == unitUriString) { |
| 336 libraryUriStrings.add(unlinkedUnitUriString); | 329 libraryUriStrings.add(unlinkedUnitUriString); |
| 337 } | 330 } |
| 338 } | 331 } |
| 339 }); | 332 }); |
| 340 return libraryUriStrings.isNotEmpty ? libraryUriStrings : null; | 333 return libraryUriStrings.isNotEmpty ? libraryUriStrings : null; |
| 341 } | 334 } |
| 335 |
| 336 void _fillMaps(String path) { |
| 337 io.File file = new io.File(path); |
| 338 List<int> buffer = file.readAsBytesSync(); |
| 339 PackageBundle bundle = new PackageBundle.fromBuffer(buffer); |
| 340 addBundle(path, bundle); |
| 341 } |
| 342 } | 342 } |
| 343 | 343 |
| 344 /** | 344 /** |
| 345 * A concrete resynthesizer that serves summaries from given file paths. | 345 * A concrete resynthesizer that serves summaries from given file paths. |
| 346 */ | 346 */ |
| 347 class _FileBasedSummaryResynthesizer extends SummaryResynthesizer { | 347 class _FileBasedSummaryResynthesizer extends SummaryResynthesizer { |
| 348 final SummaryDataStore _dataStore; | 348 final SummaryDataStore _dataStore; |
| 349 | 349 |
| 350 _FileBasedSummaryResynthesizer( | 350 _FileBasedSummaryResynthesizer( |
| 351 SummaryResynthesizer parent, | 351 SummaryResynthesizer parent, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 379 * also provides [summaryPath]. | 379 * also provides [summaryPath]. |
| 380 */ | 380 */ |
| 381 class _InSummaryFallbackSource extends FileBasedSource | 381 class _InSummaryFallbackSource extends FileBasedSource |
| 382 implements InSummarySource { | 382 implements InSummarySource { |
| 383 @override | 383 @override |
| 384 final String summaryPath; | 384 final String summaryPath; |
| 385 | 385 |
| 386 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath) | 386 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath) |
| 387 : super(file, uri); | 387 : super(file, uri); |
| 388 } | 388 } |
| OLD | NEW |