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/instrumentation/instrumentation.dart'; | 10 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 11 import 'package:analyzer/plugin/task.dart'; |
11 import 'package:analyzer/src/cancelable_future.dart'; | 12 import 'package:analyzer/src/cancelable_future.dart'; |
12 import 'package:analyzer/src/context/cache.dart'; | 13 import 'package:analyzer/src/context/cache.dart'; |
13 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
14 import 'package:analyzer/src/generated/constant.dart'; | 15 import 'package:analyzer/src/generated/constant.dart'; |
15 import 'package:analyzer/src/generated/element.dart'; | 16 import 'package:analyzer/src/generated/element.dart'; |
16 import 'package:analyzer/src/generated/engine.dart' | 17 import 'package:analyzer/src/generated/engine.dart' |
17 hide | 18 hide |
18 AnalysisCache, | 19 AnalysisCache, |
19 CachePartition, | 20 CachePartition, |
20 SdkCachePartition, | 21 SdkCachePartition, |
21 UniversalCachePartition, | 22 UniversalCachePartition, |
22 WorkManager; | 23 WorkManager; |
23 import 'package:analyzer/src/generated/error.dart'; | 24 import 'package:analyzer/src/generated/error.dart'; |
24 import 'package:analyzer/src/generated/html.dart' as ht show HtmlUnit; | 25 import 'package:analyzer/src/generated/html.dart' as ht show HtmlUnit; |
25 import 'package:analyzer/src/generated/incremental_resolver.dart'; | 26 import 'package:analyzer/src/generated/incremental_resolver.dart'; |
26 import 'package:analyzer/src/generated/java_core.dart'; | 27 import 'package:analyzer/src/generated/java_core.dart'; |
27 import 'package:analyzer/src/generated/java_engine.dart'; | 28 import 'package:analyzer/src/generated/java_engine.dart'; |
28 import 'package:analyzer/src/generated/resolver.dart'; | 29 import 'package:analyzer/src/generated/resolver.dart'; |
29 import 'package:analyzer/src/generated/scanner.dart'; | 30 import 'package:analyzer/src/generated/scanner.dart'; |
30 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 31 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
31 import 'package:analyzer/src/generated/source.dart'; | 32 import 'package:analyzer/src/generated/source.dart'; |
32 import 'package:analyzer/src/generated/utilities_collection.dart'; | 33 import 'package:analyzer/src/generated/utilities_collection.dart'; |
33 import 'package:analyzer/src/task/dart.dart'; | 34 import 'package:analyzer/src/task/dart.dart'; |
34 import 'package:analyzer/src/task/dart_work_manager.dart'; | 35 import 'package:analyzer/src/task/dart_work_manager.dart'; |
35 import 'package:analyzer/src/task/driver.dart'; | 36 import 'package:analyzer/src/task/driver.dart'; |
36 import 'package:analyzer/src/task/html.dart'; | |
37 import 'package:analyzer/src/task/html_work_manager.dart'; | |
38 import 'package:analyzer/src/task/incremental_element_builder.dart'; | 37 import 'package:analyzer/src/task/incremental_element_builder.dart'; |
39 import 'package:analyzer/src/task/manager.dart'; | 38 import 'package:analyzer/src/task/manager.dart'; |
40 import 'package:analyzer/task/dart.dart'; | 39 import 'package:analyzer/task/dart.dart'; |
41 import 'package:analyzer/task/general.dart'; | 40 import 'package:analyzer/task/general.dart'; |
42 import 'package:analyzer/task/html.dart'; | 41 import 'package:analyzer/task/html.dart'; |
43 import 'package:analyzer/task/model.dart'; | 42 import 'package:analyzer/task/model.dart'; |
44 import 'package:html/dom.dart' show Document; | 43 import 'package:html/dom.dart' show Document; |
45 | 44 |
46 /** | 45 /** |
47 * Type of callback functions used by PendingFuture. Functions of this type | 46 * Type of callback functions used by PendingFuture. Functions of this type |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 * are stored. | 114 * are stored. |
116 */ | 115 */ |
117 AnalysisCache _cache; | 116 AnalysisCache _cache; |
118 | 117 |
119 /** | 118 /** |
120 * The task manager used to manage the tasks used to analyze code. | 119 * The task manager used to manage the tasks used to analyze code. |
121 */ | 120 */ |
122 TaskManager _taskManager; | 121 TaskManager _taskManager; |
123 | 122 |
124 /** | 123 /** |
| 124 * A list of all [WorkManager]s used by this context. |
| 125 */ |
| 126 final List<WorkManager> workManagers = <WorkManager>[]; |
| 127 |
| 128 /** |
125 * The [DartWorkManager] instance that performs Dart specific scheduling. | 129 * The [DartWorkManager] instance that performs Dart specific scheduling. |
126 */ | 130 */ |
127 DartWorkManager dartWorkManager; | 131 DartWorkManager dartWorkManager; |
128 | 132 |
129 /** | 133 /** |
130 * The work manager that performs HTML specific scheduling. | |
131 */ | |
132 HtmlWorkManager htmlWorkManager; | |
133 | |
134 /** | |
135 * The analysis driver used to perform analysis. | 134 * The analysis driver used to perform analysis. |
136 */ | 135 */ |
137 AnalysisDriver driver; | 136 AnalysisDriver driver; |
138 | 137 |
139 /** | 138 /** |
140 * A list containing sources for which data should not be flushed. | 139 * A list containing sources for which data should not be flushed. |
141 */ | 140 */ |
142 List<Source> _priorityOrder = <Source>[]; | 141 List<Source> _priorityOrder = <Source>[]; |
143 | 142 |
144 /** | 143 /** |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 */ | 211 */ |
213 LibraryResolverFactory libraryResolverFactory; | 212 LibraryResolverFactory libraryResolverFactory; |
214 | 213 |
215 /** | 214 /** |
216 * Initialize a newly created analysis context. | 215 * Initialize a newly created analysis context. |
217 */ | 216 */ |
218 AnalysisContextImpl() { | 217 AnalysisContextImpl() { |
219 _privatePartition = new UniversalCachePartition(this); | 218 _privatePartition = new UniversalCachePartition(this); |
220 _cache = createCacheFromSourceFactory(null); | 219 _cache = createCacheFromSourceFactory(null); |
221 _taskManager = AnalysisEngine.instance.taskManager; | 220 _taskManager = AnalysisEngine.instance.taskManager; |
222 // TODO(scheglov) Get WorkManager(Factory)(s) from plugins. | 221 for (WorkManagerFactory factory |
223 dartWorkManager = new DartWorkManager(this); | 222 in AnalysisEngine.instance.enginePlugin.workManagerFactories) { |
224 htmlWorkManager = new HtmlWorkManager(this); | 223 WorkManager workManager = factory(this); |
225 driver = new AnalysisDriver( | 224 if (workManager != null) { |
226 _taskManager, <WorkManager>[dartWorkManager, htmlWorkManager], this); | 225 workManagers.add(workManager); |
| 226 if (workManager is DartWorkManager) { |
| 227 dartWorkManager = workManager; |
| 228 } |
| 229 } |
| 230 } |
| 231 driver = new AnalysisDriver(_taskManager, workManagers, this); |
227 _onSourcesChangedController = | 232 _onSourcesChangedController = |
228 new StreamController<SourcesChangedEvent>.broadcast(); | 233 new StreamController<SourcesChangedEvent>.broadcast(); |
229 _implicitAnalysisEventsController = | 234 _implicitAnalysisEventsController = |
230 new StreamController<ImplicitAnalysisEvent>.broadcast(); | 235 new StreamController<ImplicitAnalysisEvent>.broadcast(); |
231 } | 236 } |
232 | 237 |
233 @override | 238 @override |
234 AnalysisCache get analysisCache => _cache; | 239 AnalysisCache get analysisCache => _cache; |
235 | 240 |
236 @override | 241 @override |
(...skipping 24 matching lines...) Expand all Loading... |
261 this._options.dart2jsHint = options.dart2jsHint; | 266 this._options.dart2jsHint = options.dart2jsHint; |
262 this._options.enableStrictCallChecks = options.enableStrictCallChecks; | 267 this._options.enableStrictCallChecks = options.enableStrictCallChecks; |
263 this._options.enableSuperMixins = options.enableSuperMixins; | 268 this._options.enableSuperMixins = options.enableSuperMixins; |
264 this._options.hint = options.hint; | 269 this._options.hint = options.hint; |
265 this._options.incremental = options.incremental; | 270 this._options.incremental = options.incremental; |
266 this._options.incrementalApi = options.incrementalApi; | 271 this._options.incrementalApi = options.incrementalApi; |
267 this._options.incrementalValidation = options.incrementalValidation; | 272 this._options.incrementalValidation = options.incrementalValidation; |
268 this._options.lint = options.lint; | 273 this._options.lint = options.lint; |
269 this._options.preserveComments = options.preserveComments; | 274 this._options.preserveComments = options.preserveComments; |
270 if (needsRecompute) { | 275 if (needsRecompute) { |
271 dartWorkManager.onAnalysisOptionsChanged(); | 276 for (WorkManager workManager in workManagers) { |
272 htmlWorkManager.onAnalysisOptionsChanged(); | 277 workManager.onAnalysisOptionsChanged(); |
| 278 } |
273 } | 279 } |
274 } | 280 } |
275 | 281 |
276 @override | 282 @override |
277 void set analysisPriorityOrder(List<Source> sources) { | 283 void set analysisPriorityOrder(List<Source> sources) { |
278 if (sources == null || sources.isEmpty) { | 284 if (sources == null || sources.isEmpty) { |
279 _priorityOrder = Source.EMPTY_LIST; | 285 _priorityOrder = Source.EMPTY_LIST; |
280 } else { | 286 } else { |
281 while (sources.remove(null)) { | 287 while (sources.remove(null)) { |
282 // Nothing else to do. | 288 // Nothing else to do. |
283 } | 289 } |
284 if (sources.isEmpty) { | 290 if (sources.isEmpty) { |
285 _priorityOrder = Source.EMPTY_LIST; | 291 _priorityOrder = Source.EMPTY_LIST; |
286 } else { | 292 } else { |
287 _priorityOrder = sources; | 293 _priorityOrder = sources; |
288 } | 294 } |
289 } | 295 } |
290 dartWorkManager.applyPriorityTargets(_priorityOrder); | 296 for (WorkManager workManager in workManagers) { |
291 htmlWorkManager.applyPriorityTargets(_priorityOrder); | 297 workManager.applyPriorityTargets(_priorityOrder); |
| 298 } |
292 } | 299 } |
293 | 300 |
294 @override | 301 @override |
295 set contentCache(ContentCache value) { | 302 set contentCache(ContentCache value) { |
296 _contentCache = value; | 303 _contentCache = value; |
297 } | 304 } |
298 | 305 |
299 @override | 306 @override |
300 DeclaredVariables get declaredVariables => _declaredVariables; | 307 DeclaredVariables get declaredVariables => _declaredVariables; |
301 | 308 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 @override | 360 @override |
354 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); | 361 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); |
355 | 362 |
356 @override | 363 @override |
357 Stream<SourcesChangedEvent> get onSourcesChanged => | 364 Stream<SourcesChangedEvent> get onSourcesChanged => |
358 _onSourcesChangedController.stream; | 365 _onSourcesChangedController.stream; |
359 | 366 |
360 /** | 367 /** |
361 * Make _pendingFutureSources available to unit tests. | 368 * Make _pendingFutureSources available to unit tests. |
362 */ | 369 */ |
363 HashMap<AnalysisTarget, List<PendingFuture>> get pendingFutureSources_forTesti
ng => | 370 HashMap<AnalysisTarget, |
| 371 List<PendingFuture>> get pendingFutureSources_forTesting => |
364 _pendingFutureTargets; | 372 _pendingFutureTargets; |
365 | 373 |
366 @override | 374 @override |
367 List<Source> get prioritySources => _priorityOrder; | 375 List<Source> get prioritySources => _priorityOrder; |
368 | 376 |
369 @override | 377 @override |
370 List<AnalysisTarget> get priorityTargets => prioritySources; | 378 List<AnalysisTarget> get priorityTargets => prioritySources; |
371 | 379 |
372 @override | 380 @override |
373 CachePartition get privateAnalysisCachePartition => _privatePartition; | 381 CachePartition get privateAnalysisCachePartition => _privatePartition; |
374 | 382 |
375 @override | 383 @override |
376 SourceFactory get sourceFactory => _sourceFactory; | 384 SourceFactory get sourceFactory => _sourceFactory; |
377 | 385 |
378 @override | 386 @override |
379 void set sourceFactory(SourceFactory factory) { | 387 void set sourceFactory(SourceFactory factory) { |
380 if (identical(_sourceFactory, factory)) { | 388 if (identical(_sourceFactory, factory)) { |
381 return; | 389 return; |
382 } else if (factory.context != null) { | 390 } else if (factory.context != null) { |
383 throw new IllegalStateException( | 391 throw new IllegalStateException( |
384 "Source factories cannot be shared between contexts"); | 392 "Source factories cannot be shared between contexts"); |
385 } | 393 } |
386 if (_sourceFactory != null) { | 394 if (_sourceFactory != null) { |
387 _sourceFactory.context = null; | 395 _sourceFactory.context = null; |
388 } | 396 } |
389 factory.context = this; | 397 factory.context = this; |
390 _sourceFactory = factory; | 398 _sourceFactory = factory; |
391 _cache = createCacheFromSourceFactory(factory); | 399 _cache = createCacheFromSourceFactory(factory); |
392 dartWorkManager.onSourceFactoryChanged(); | 400 for (WorkManager workManager in workManagers) { |
393 htmlWorkManager.onSourceFactoryChanged(); | 401 workManager.onSourceFactoryChanged(); |
| 402 } |
394 } | 403 } |
395 | 404 |
396 @override | 405 @override |
397 List<Source> get sources { | 406 List<Source> get sources { |
398 return _cache.sources.toList(); | 407 return _cache.sources.toList(); |
399 } | 408 } |
400 | 409 |
401 /** | 410 /** |
402 * Return a list of the sources that would be processed by | 411 * Return a list of the sources that would be processed by |
403 * [performAnalysisTask]. This method duplicates, and must therefore be kept | 412 * [performAnalysisTask]. This method duplicates, and must therefore be kept |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 .forEach((Source source, ChangeSet_ContentChange change) { | 533 .forEach((Source source, ChangeSet_ContentChange change) { |
525 _contentRangeChanged(source, change.contents, change.offset, | 534 _contentRangeChanged(source, change.contents, change.offset, |
526 change.oldLength, change.newLength); | 535 change.oldLength, change.newLength); |
527 }); | 536 }); |
528 for (Source source in changeSet.deletedSources) { | 537 for (Source source in changeSet.deletedSources) { |
529 _sourceDeleted(source); | 538 _sourceDeleted(source); |
530 } | 539 } |
531 for (Source source in removedSources) { | 540 for (Source source in removedSources) { |
532 _sourceRemoved(source); | 541 _sourceRemoved(source); |
533 } | 542 } |
534 dartWorkManager.applyChange( | 543 for (WorkManager workManager in workManagers) { |
535 changeSet.addedSources, changeSet.changedSources, removedSources); | 544 workManager.applyChange( |
536 htmlWorkManager.applyChange( | 545 changeSet.addedSources, changeSet.changedSources, removedSources); |
537 changeSet.addedSources, changeSet.changedSources, removedSources); | 546 } |
538 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); | 547 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); |
539 } | 548 } |
540 | 549 |
541 @override | 550 @override |
542 String computeDocumentationComment(Element element) { | 551 String computeDocumentationComment(Element element) { |
543 if (element == null) { | 552 if (element == null) { |
544 return null; | 553 return null; |
545 } | 554 } |
546 Source source = element.source; | 555 Source source = element.source; |
547 if (source == null) { | 556 if (source == null) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 } | 637 } |
629 | 638 |
630 @override | 639 @override |
631 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( | 640 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
632 Source unitSource, Source librarySource) { | 641 Source unitSource, Source librarySource) { |
633 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 642 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
634 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 643 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
635 return new CancelableFuture.error(new AnalysisNotScheduledError()); | 644 return new CancelableFuture.error(new AnalysisNotScheduledError()); |
636 } | 645 } |
637 var unitTarget = new LibrarySpecificUnit(librarySource, unitSource); | 646 var unitTarget = new LibrarySpecificUnit(librarySource, unitSource); |
638 return new _AnalysisFutureHelper<CompilationUnit>(this).computeAsync( | 647 return new _AnalysisFutureHelper<CompilationUnit>(this) |
639 unitTarget, (CacheEntry entry) { | 648 .computeAsync(unitTarget, (CacheEntry entry) { |
640 CacheState state = entry.getState(RESOLVED_UNIT); | 649 CacheState state = entry.getState(RESOLVED_UNIT); |
641 if (state == CacheState.ERROR) { | 650 if (state == CacheState.ERROR) { |
642 throw entry.exception; | 651 throw entry.exception; |
643 } else if (state == CacheState.INVALID) { | 652 } else if (state == CacheState.INVALID) { |
644 return null; | 653 return null; |
645 } | 654 } |
646 return entry.getValue(RESOLVED_UNIT); | 655 return entry.getValue(RESOLVED_UNIT); |
647 }, () { | 656 }, () { |
648 dartWorkManager.addPriorityResult(unitTarget, RESOLVED_UNIT); | 657 dartWorkManager.addPriorityResult(unitTarget, RESOLVED_UNIT); |
649 }); | 658 }); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 } catch (exception) { | 803 } catch (exception) { |
795 // If the location cannot be decoded for some reason then the underlying | 804 // If the location cannot be decoded for some reason then the underlying |
796 // cause should have been logged already and we can fall though to return | 805 // cause should have been logged already and we can fall though to return |
797 // null. | 806 // null. |
798 } | 807 } |
799 return null; | 808 return null; |
800 } | 809 } |
801 | 810 |
802 @override | 811 @override |
803 AnalysisErrorInfo getErrors(Source source) { | 812 AnalysisErrorInfo getErrors(Source source) { |
804 String name = source.shortName; | 813 List<AnalysisError> allErrors = <AnalysisError>[]; |
805 if (AnalysisEngine.isDartFileName(name) || source is DartScript) { | 814 for (WorkManager workManager in workManagers) { |
806 return dartWorkManager.getErrors(source); | 815 List<AnalysisError> errors = workManager.getErrors(source); |
807 } else if (AnalysisEngine.isHtmlFileName(name)) { | 816 allErrors.addAll(errors); |
808 return htmlWorkManager.getErrors(source); | |
809 } | 817 } |
810 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); | 818 LineInfo lineInfo = getLineInfo(source); |
| 819 return new AnalysisErrorInfoImpl(allErrors, lineInfo); |
811 } | 820 } |
812 | 821 |
813 @override | 822 @override |
814 @deprecated | 823 @deprecated |
815 HtmlElement getHtmlElement(Source source) { | 824 HtmlElement getHtmlElement(Source source) { |
816 // TODO(brianwilkerson) Remove this method after switching to the new task | 825 // TODO(brianwilkerson) Remove this method after switching to the new task |
817 // model. | 826 // model. |
818 throw new UnimplementedError('Not supported in the new task model'); | 827 throw new UnimplementedError('Not supported in the new task model'); |
819 } | 828 } |
820 | 829 |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 return Source.EMPTY_LIST; | 1532 return Source.EMPTY_LIST; |
1524 } | 1533 } |
1525 return sources; | 1534 return sources; |
1526 } | 1535 } |
1527 | 1536 |
1528 /** | 1537 /** |
1529 * Look at the given [source] to see whether a task needs to be performed | 1538 * Look at the given [source] to see whether a task needs to be performed |
1530 * related to it. If so, add the source to the set of sources that need to be | 1539 * related to it. If so, add the source to the set of sources that need to be |
1531 * processed. This method is intended to be used for testing purposes only. | 1540 * processed. This method is intended to be used for testing purposes only. |
1532 */ | 1541 */ |
1533 void _getSourcesNeedingProcessing(Source source, CacheEntry entry, | 1542 void _getSourcesNeedingProcessing( |
1534 bool isPriority, bool hintsEnabled, bool lintsEnabled, | 1543 Source source, |
| 1544 CacheEntry entry, |
| 1545 bool isPriority, |
| 1546 bool hintsEnabled, |
| 1547 bool lintsEnabled, |
1535 HashSet<Source> sources) { | 1548 HashSet<Source> sources) { |
1536 CacheState state = entry.getState(CONTENT); | 1549 CacheState state = entry.getState(CONTENT); |
1537 if (state == CacheState.INVALID || | 1550 if (state == CacheState.INVALID || |
1538 (isPriority && state == CacheState.FLUSHED)) { | 1551 (isPriority && state == CacheState.FLUSHED)) { |
1539 sources.add(source); | 1552 sources.add(source); |
1540 return; | 1553 return; |
1541 } else if (state == CacheState.ERROR) { | 1554 } else if (state == CacheState.ERROR) { |
1542 return; | 1555 return; |
1543 } | 1556 } |
1544 state = entry.getState(SOURCE_KIND); | 1557 state = entry.getState(SOURCE_KIND); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 // 'dartDelta: add=${dartDelta.addedNames} remove=${dartDelta.r
emovedNames}'); | 1769 // 'dartDelta: add=${dartDelta.addedNames} remove=${dartDelta.r
emovedNames}'); |
1757 delta = dartDelta; | 1770 delta = dartDelta; |
1758 entry.setState(CONTENT, CacheState.INVALID, delta: delta); | 1771 entry.setState(CONTENT, CacheState.INVALID, delta: delta); |
1759 return; | 1772 return; |
1760 } | 1773 } |
1761 } | 1774 } |
1762 } | 1775 } |
1763 } | 1776 } |
1764 entry.setState(CONTENT, CacheState.INVALID); | 1777 entry.setState(CONTENT, CacheState.INVALID); |
1765 } | 1778 } |
1766 dartWorkManager.applyChange( | 1779 for (WorkManager workManager in workManagers) { |
1767 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); | 1780 workManager.applyChange( |
1768 htmlWorkManager.applyChange( | 1781 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); |
1769 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); | 1782 } |
1770 } | 1783 } |
1771 | 1784 |
1772 /** | 1785 /** |
1773 * Record that the give [source] has been deleted. | 1786 * Record that the give [source] has been deleted. |
1774 */ | 1787 */ |
1775 void _sourceDeleted(Source source) { | 1788 void _sourceDeleted(Source source) { |
1776 // TODO(brianwilkerson) Implement or remove this. | 1789 // TODO(brianwilkerson) Implement or remove this. |
1777 // SourceEntry sourceEntry = _cache.get(source); | 1790 // SourceEntry sourceEntry = _cache.get(source); |
1778 // if (sourceEntry is HtmlEntry) { | 1791 // if (sourceEntry is HtmlEntry) { |
1779 // HtmlEntry htmlEntry = sourceEntry; | 1792 // HtmlEntry htmlEntry = sourceEntry; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 } | 1852 } |
1840 // prepare the existing unit | 1853 // prepare the existing unit |
1841 CompilationUnit oldUnit = | 1854 CompilationUnit oldUnit = |
1842 getResolvedCompilationUnit2(unitSource, librarySource); | 1855 getResolvedCompilationUnit2(unitSource, librarySource); |
1843 if (oldUnit == null) { | 1856 if (oldUnit == null) { |
1844 return false; | 1857 return false; |
1845 } | 1858 } |
1846 // do resolution | 1859 // do resolution |
1847 Stopwatch perfCounter = new Stopwatch()..start(); | 1860 Stopwatch perfCounter = new Stopwatch()..start(); |
1848 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( | 1861 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( |
1849 typeProvider, unitSource, null, sourceEntry, unitEntry, oldUnit, | 1862 typeProvider, |
1850 analysisOptions.incrementalApi, analysisOptions); | 1863 unitSource, |
| 1864 null, |
| 1865 sourceEntry, |
| 1866 unitEntry, |
| 1867 oldUnit, |
| 1868 analysisOptions.incrementalApi, |
| 1869 analysisOptions); |
1851 bool success = resolver.resolve(newCode); | 1870 bool success = resolver.resolve(newCode); |
1852 AnalysisEngine.instance.instrumentationService.logPerformance( | 1871 AnalysisEngine.instance.instrumentationService.logPerformance( |
1853 AnalysisPerformanceKind.INCREMENTAL, perfCounter, | 1872 AnalysisPerformanceKind.INCREMENTAL, |
| 1873 perfCounter, |
1854 'success=$success,context_id=$_id,code_length=${newCode.length}'); | 1874 'success=$success,context_id=$_id,code_length=${newCode.length}'); |
1855 if (!success) { | 1875 if (!success) { |
1856 return false; | 1876 return false; |
1857 } | 1877 } |
1858 // if validation, remember the result, but throw it away | 1878 // if validation, remember the result, but throw it away |
1859 if (analysisOptions.incrementalValidation) { | 1879 if (analysisOptions.incrementalValidation) { |
1860 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; | 1880 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; |
1861 incrementalResolutionValidation_lastLibrarySource = | 1881 incrementalResolutionValidation_lastLibrarySource = |
1862 oldUnit.element.library.source; | 1882 oldUnit.element.library.source; |
1863 incrementalResolutionValidation_lastUnit = oldUnit; | 1883 incrementalResolutionValidation_lastUnit = oldUnit; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 new PendingFuture<T>(_context, target, computeValue); | 2077 new PendingFuture<T>(_context, target, computeValue); |
2058 if (!pendingFuture.evaluate(entry)) { | 2078 if (!pendingFuture.evaluate(entry)) { |
2059 _context._pendingFutureTargets | 2079 _context._pendingFutureTargets |
2060 .putIfAbsent(target, () => <PendingFuture>[]) | 2080 .putIfAbsent(target, () => <PendingFuture>[]) |
2061 .add(pendingFuture); | 2081 .add(pendingFuture); |
2062 scheduleComputation(); | 2082 scheduleComputation(); |
2063 } | 2083 } |
2064 return pendingFuture.future; | 2084 return pendingFuture.future; |
2065 } | 2085 } |
2066 } | 2086 } |
OLD | NEW |