OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.test.src.context.context_test; | 5 library analyzer.test.src.context.context_test; |
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 2543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2554 ChangeSet changeSet = new ChangeSet(); | 2554 ChangeSet changeSet = new ChangeSet(); |
2555 changeSet.addedSource(source); | 2555 changeSet.addedSource(source); |
2556 context.applyChanges(changeSet); | 2556 context.applyChanges(changeSet); |
2557 return source; | 2557 return source; |
2558 } | 2558 } |
2559 | 2559 |
2560 /** | 2560 /** |
2561 * Perform analysis tasks up to 512 times and assert that it was enough. | 2561 * Perform analysis tasks up to 512 times and assert that it was enough. |
2562 */ | 2562 */ |
2563 void _analyzeAll_assertFinished([int maxIterations = 512]) { | 2563 void _analyzeAll_assertFinished([int maxIterations = 512]) { |
2564 bool finishedAnalyzing = false; | |
2565 for (int i = 0; i < maxIterations; i++) { | 2564 for (int i = 0; i < maxIterations; i++) { |
2566 List<ChangeNotice> notice = context.performAnalysisTask().changeNotices; | 2565 List<ChangeNotice> notice = context.performAnalysisTask().changeNotices; |
2567 if (notice == null) { | 2566 if (notice == null) { |
2568 finishedAnalyzing = true; | 2567 return; |
2569 bool inconsistent = context.validateCacheConsistency(); | |
2570 if (!inconsistent) { | |
2571 return; | |
2572 } | |
2573 } | 2568 } |
2574 } | 2569 } |
2575 if (finishedAnalyzing) { | 2570 fail("performAnalysisTask failed to terminate after analyzing all sources"); |
2576 fail( | |
2577 "performAnalysisTask failed to finish analyzing all sources after $max
Iterations iterations"); | |
2578 } else { | |
2579 fail( | |
2580 "performAnalysisTask failed to terminate after analyzing all sources")
; | |
2581 } | |
2582 } | 2571 } |
2583 | 2572 |
2584 void _assertNoExceptions() { | 2573 void _assertNoExceptions() { |
2585 MapIterator<AnalysisTarget, CacheEntry> iterator = analysisCache.iterator(); | 2574 MapIterator<AnalysisTarget, CacheEntry> iterator = analysisCache.iterator(); |
2586 String exceptionsStr = ''; | 2575 String exceptionsStr = ''; |
2587 while (iterator.moveNext()) { | 2576 while (iterator.moveNext()) { |
2588 CaughtException exception = iterator.value.exception; | 2577 CaughtException exception = iterator.value.exception; |
2589 if (exception != null) { | 2578 if (exception != null) { |
2590 AnalysisTarget target = iterator.key; | 2579 AnalysisTarget target = iterator.key; |
2591 exceptionsStr += | 2580 exceptionsStr += |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3832 * Initialize the visitor. | 3821 * Initialize the visitor. |
3833 */ | 3822 */ |
3834 _ElementGatherer(); | 3823 _ElementGatherer(); |
3835 | 3824 |
3836 @override | 3825 @override |
3837 void visitElement(Element element) { | 3826 void visitElement(Element element) { |
3838 elements[element] = element; | 3827 elements[element] = element; |
3839 super.visitElement(element); | 3828 super.visitElement(element); |
3840 } | 3829 } |
3841 } | 3830 } |
OLD | NEW |