| 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 analyzer.src.summary.summary_sdk; | 5 library analyzer.src.summary.summary_sdk; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
| 9 import 'package:analyzer/src/context/cache.dart' show CacheEntry; | 9 import 'package:analyzer/src/context/cache.dart' show CacheEntry; |
| 10 import 'package:analyzer/src/context/context.dart'; | 10 import 'package:analyzer/src/context/context.dart'; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 final SummaryTypeProvider typeProvider = new SummaryTypeProvider(); | 40 final SummaryTypeProvider typeProvider = new SummaryTypeProvider(); |
| 41 | 41 |
| 42 SummaryResynthesizer resynthesizer; | 42 SummaryResynthesizer resynthesizer; |
| 43 | 43 |
| 44 SummarySdkAnalysisContext(this.bundle); | 44 SummarySdkAnalysisContext(this.bundle); |
| 45 | 45 |
| 46 @override | 46 @override |
| 47 bool aboutToComputeResult(CacheEntry entry, ResultDescriptor result) { | 47 bool aboutToComputeResult(CacheEntry entry, ResultDescriptor result) { |
| 48 if (resynthesizer == null) { | 48 if (resynthesizer == null) { |
| 49 resynthesizer = new SummaryResynthesizer(this, typeProvider, | 49 resynthesizer = new SummaryResynthesizer(this, typeProvider, |
| 50 _getPrelinkedSummary, _getUnlinkedSummary, sourceFactory); | 50 _getLinkedSummary, _getUnlinkedSummary, sourceFactory); |
| 51 _buildCoreLibrary(); | 51 _buildCoreLibrary(); |
| 52 _buildAsyncLibrary(); | 52 _buildAsyncLibrary(); |
| 53 } | 53 } |
| 54 if (result == TYPE_PROVIDER) { | 54 if (result == TYPE_PROVIDER) { |
| 55 entry.setValue(result, typeProvider, TargetedResult.EMPTY_LIST); | 55 entry.setValue(result, typeProvider, TargetedResult.EMPTY_LIST); |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 AnalysisTarget target = entry.target; | 58 AnalysisTarget target = entry.target; |
| 59 // print('SummarySdkAnalysisContext: $result of $target'); | 59 // print('SummarySdkAnalysisContext: $result of $target'); |
| 60 if (target is Source && target.isInSystemLibrary) { | 60 if (target is Source && target.isInSystemLibrary) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 LibraryElement libraryElement = resynthesizer.getLibraryElement(uri); | 73 LibraryElement libraryElement = resynthesizer.getLibraryElement(uri); |
| 74 entry.setValue(result, libraryElement, TargetedResult.EMPTY_LIST); | 74 entry.setValue(result, libraryElement, TargetedResult.EMPTY_LIST); |
| 75 return true; | 75 return true; |
| 76 } else if (result == READY_LIBRARY_ELEMENT2 || | 76 } else if (result == READY_LIBRARY_ELEMENT2 || |
| 77 result == READY_LIBRARY_ELEMENT5 || | 77 result == READY_LIBRARY_ELEMENT5 || |
| 78 result == READY_LIBRARY_ELEMENT6) { | 78 result == READY_LIBRARY_ELEMENT6) { |
| 79 entry.setValue(result, true, TargetedResult.EMPTY_LIST); | 79 entry.setValue(result, true, TargetedResult.EMPTY_LIST); |
| 80 return true; | 80 return true; |
| 81 } else if (result == SOURCE_KIND) { | 81 } else if (result == SOURCE_KIND) { |
| 82 String uri = target.uri.toString(); | 82 String uri = target.uri.toString(); |
| 83 if (bundle.prelinkedLibraryUris.contains(uri)) { | 83 if (bundle.linkedLibraryUris.contains(uri)) { |
| 84 entry.setValue(result, SourceKind.LIBRARY, TargetedResult.EMPTY_LIST); | 84 entry.setValue(result, SourceKind.LIBRARY, TargetedResult.EMPTY_LIST); |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 if (bundle.unlinkedUnitUris.contains(uri)) { | 87 if (bundle.unlinkedUnitUris.contains(uri)) { |
| 88 entry.setValue(result, SourceKind.PART, TargetedResult.EMPTY_LIST); | 88 entry.setValue(result, SourceKind.PART, TargetedResult.EMPTY_LIST); |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| 91 return false; | 91 return false; |
| 92 } else { | 92 } else { |
| 93 // throw new UnimplementedError('$result of $target'); | 93 // throw new UnimplementedError('$result of $target'); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 return false; | 96 return false; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void _buildAsyncLibrary() { | 99 void _buildAsyncLibrary() { |
| 100 LibraryElement library = resynthesizer.getLibraryElement('dart:async'); | 100 LibraryElement library = resynthesizer.getLibraryElement('dart:async'); |
| 101 typeProvider.initializeAsync(library); | 101 typeProvider.initializeAsync(library); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void _buildCoreLibrary() { | 104 void _buildCoreLibrary() { |
| 105 LibraryElement library = resynthesizer.getLibraryElement('dart:core'); | 105 LibraryElement library = resynthesizer.getLibraryElement('dart:core'); |
| 106 typeProvider.initializeCore(library); | 106 typeProvider.initializeCore(library); |
| 107 } | 107 } |
| 108 | 108 |
| 109 PrelinkedLibrary _getPrelinkedSummary(String uri) { | 109 LinkedLibrary _getLinkedSummary(String uri) { |
| 110 for (int i = 0; i < bundle.prelinkedLibraryUris.length; i++) { | 110 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { |
| 111 if (bundle.prelinkedLibraryUris[i] == uri) { | 111 if (bundle.linkedLibraryUris[i] == uri) { |
| 112 return bundle.prelinkedLibraries[i]; | 112 return bundle.linkedLibraries[i]; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 throw new StateError('Unable to find prelinked summary for $uri'); | 115 throw new StateError('Unable to find linked summary for $uri'); |
| 116 } | 116 } |
| 117 | 117 |
| 118 UnlinkedUnit _getUnlinkedSummary(String uri) { | 118 UnlinkedUnit _getUnlinkedSummary(String uri) { |
| 119 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { | 119 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { |
| 120 if (bundle.unlinkedUnitUris[i] == uri) { | 120 if (bundle.unlinkedUnitUris[i] == uri) { |
| 121 return bundle.unlinkedUnits[i]; | 121 return bundle.unlinkedUnits[i]; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 throw new StateError('Unable to find unlinked summary for $uri'); | 124 throw new StateError('Unable to find unlinked summary for $uri'); |
| 125 } | 125 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 * throw a [StateError] if there is no class with the given name. | 353 * throw a [StateError] if there is no class with the given name. |
| 354 */ | 354 */ |
| 355 InterfaceType _getType(LibraryElement library, String name) { | 355 InterfaceType _getType(LibraryElement library, String name) { |
| 356 Element element = library.getType(name); | 356 Element element = library.getType(name); |
| 357 if (element == null) { | 357 if (element == null) { |
| 358 throw new StateError("No definition of type $name"); | 358 throw new StateError("No definition of type $name"); |
| 359 } | 359 } |
| 360 return (element as ClassElement).type; | 360 return (element as ClassElement).type; |
| 361 } | 361 } |
| 362 } | 362 } |
| OLD | NEW |