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.context.context; | 5 library analyzer.src.context.context; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 /** | 187 /** |
188 * The listeners that are to be notified when various analysis results are | 188 * The listeners that are to be notified when various analysis results are |
189 * produced in this context. | 189 * produced in this context. |
190 */ | 190 */ |
191 List<AnalysisListener> _listeners = new List<AnalysisListener>(); | 191 List<AnalysisListener> _listeners = new List<AnalysisListener>(); |
192 | 192 |
193 @override | 193 @override |
194 ResultProvider resultProvider; | 194 ResultProvider resultProvider; |
195 | 195 |
196 /** | 196 /** |
| 197 * The map of [InvalidatedResult] controllers. |
| 198 */ |
| 199 final Map<ResultDescriptor, StreamController<InvalidatedResult>> |
| 200 _resultInvalidatedControllers = |
| 201 <ResultDescriptor, StreamController<InvalidatedResult>>{}; |
| 202 |
| 203 /** |
197 * The most recently incrementally resolved source, or `null` when it was | 204 * The most recently incrementally resolved source, or `null` when it was |
198 * already validated, or the most recent change was not incrementally resolved
. | 205 * already validated, or the most recent change was not incrementally resolved
. |
199 */ | 206 */ |
200 Source incrementalResolutionValidation_lastUnitSource; | 207 Source incrementalResolutionValidation_lastUnitSource; |
201 | 208 |
202 /** | 209 /** |
203 * The most recently incrementally resolved library source, or `null` when it | 210 * The most recently incrementally resolved library source, or `null` when it |
204 * was already validated, or the most recent change was not incrementally | 211 * was already validated, or the most recent change was not incrementally |
205 * resolved. | 212 * resolved. |
206 */ | 213 */ |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 * Create an analysis cache based on the given source [factory]. | 682 * Create an analysis cache based on the given source [factory]. |
676 */ | 683 */ |
677 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 684 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
678 if (factory == null) { | 685 if (factory == null) { |
679 return new AnalysisCache(<CachePartition>[_privatePartition]); | 686 return new AnalysisCache(<CachePartition>[_privatePartition]); |
680 } | 687 } |
681 DartSdk sdk = factory.dartSdk; | 688 DartSdk sdk = factory.dartSdk; |
682 if (sdk == null) { | 689 if (sdk == null) { |
683 return new AnalysisCache(<CachePartition>[_privatePartition]); | 690 return new AnalysisCache(<CachePartition>[_privatePartition]); |
684 } | 691 } |
685 return new AnalysisCache(<CachePartition>[ | 692 AnalysisCache cache = new AnalysisCache(<CachePartition>[ |
686 AnalysisEngine.instance.partitionManager.forSdk(sdk), | 693 AnalysisEngine.instance.partitionManager.forSdk(sdk), |
687 _privatePartition | 694 _privatePartition |
688 ]); | 695 ]); |
| 696 cache.onResultInvalidated.listen((InvalidatedResult event) { |
| 697 _resultInvalidatedControllers[event.descriptor]?.add(event); |
| 698 }); |
| 699 return cache; |
689 } | 700 } |
690 | 701 |
691 /** | 702 /** |
692 * Create a minimalistic mock dart:async library | 703 * Create a minimalistic mock dart:async library |
693 * to stand in for a real one if one does not exist | 704 * to stand in for a real one if one does not exist |
694 * facilitating creation a type provider without dart:async. | 705 * facilitating creation a type provider without dart:async. |
695 */ | 706 */ |
696 LibraryElement createMockAsyncLib(LibraryElement coreLibrary) { | 707 LibraryElement createMockAsyncLib(LibraryElement coreLibrary) { |
697 InterfaceType objType = coreLibrary.getType('Object').type; | 708 InterfaceType objType = coreLibrary.getType('Object').type; |
698 | 709 |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 !_referencesDartHtml(librarySource) && | 1108 !_referencesDartHtml(librarySource) && |
1098 entry.getValue(IS_LAUNCHABLE); | 1109 entry.getValue(IS_LAUNCHABLE); |
1099 } | 1110 } |
1100 | 1111 |
1101 @override | 1112 @override |
1102 Stream<ComputedResult> onResultComputed(ResultDescriptor descriptor) { | 1113 Stream<ComputedResult> onResultComputed(ResultDescriptor descriptor) { |
1103 return driver.onResultComputed(descriptor); | 1114 return driver.onResultComputed(descriptor); |
1104 } | 1115 } |
1105 | 1116 |
1106 @override | 1117 @override |
| 1118 Stream<InvalidatedResult> onResultInvalidated(ResultDescriptor descriptor) { |
| 1119 return _resultInvalidatedControllers.putIfAbsent(descriptor, () { |
| 1120 return new StreamController<InvalidatedResult>.broadcast(sync: true); |
| 1121 }).stream; |
| 1122 } |
| 1123 |
| 1124 @override |
1107 CompilationUnit parseCompilationUnit(Source source) { | 1125 CompilationUnit parseCompilationUnit(Source source) { |
1108 if (!AnalysisEngine.isDartFileName(source.shortName)) { | 1126 if (!AnalysisEngine.isDartFileName(source.shortName)) { |
1109 return null; | 1127 return null; |
1110 } | 1128 } |
1111 try { | 1129 try { |
1112 getContents(source); | 1130 getContents(source); |
1113 } catch (exception, stackTrace) { | 1131 } catch (exception, stackTrace) { |
1114 throw new AnalysisException('Could not get contents of $source', | 1132 throw new AnalysisException('Could not get contents of $source', |
1115 new CaughtException(exception, stackTrace)); | 1133 new CaughtException(exception, stackTrace)); |
1116 } | 1134 } |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 } | 2164 } |
2147 DartSdk sdk = factory.dartSdk; | 2165 DartSdk sdk = factory.dartSdk; |
2148 if (sdk == null) { | 2166 if (sdk == null) { |
2149 throw new IllegalArgumentException( | 2167 throw new IllegalArgumentException( |
2150 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2168 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
2151 } | 2169 } |
2152 return new AnalysisCache( | 2170 return new AnalysisCache( |
2153 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2171 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
2154 } | 2172 } |
2155 } | 2173 } |
OLD | NEW |