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 2420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 ChangeSet changeSet = new ChangeSet(); | 2431 ChangeSet changeSet = new ChangeSet(); |
2432 changeSet.addedSource(source); | 2432 changeSet.addedSource(source); |
2433 context.applyChanges(changeSet); | 2433 context.applyChanges(changeSet); |
2434 return source; | 2434 return source; |
2435 } | 2435 } |
2436 | 2436 |
2437 /** | 2437 /** |
2438 * Perform analysis tasks up to 512 times and assert that it was enough. | 2438 * Perform analysis tasks up to 512 times and assert that it was enough. |
2439 */ | 2439 */ |
2440 void _analyzeAll_assertFinished([int maxIterations = 512]) { | 2440 void _analyzeAll_assertFinished([int maxIterations = 512]) { |
| 2441 bool finishedAnalyzing = false; |
2441 for (int i = 0; i < maxIterations; i++) { | 2442 for (int i = 0; i < maxIterations; i++) { |
2442 List<ChangeNotice> notice = context.performAnalysisTask().changeNotices; | 2443 List<ChangeNotice> notice = context.performAnalysisTask().changeNotices; |
2443 if (notice == null) { | 2444 if (notice == null) { |
| 2445 finishedAnalyzing = true; |
2444 bool inconsistent = context.validateCacheConsistency(); | 2446 bool inconsistent = context.validateCacheConsistency(); |
2445 if (!inconsistent) { | 2447 if (!inconsistent) { |
2446 return; | 2448 return; |
2447 } | 2449 } |
2448 } | 2450 } |
2449 } | 2451 } |
2450 fail("performAnalysisTask failed to terminate after analyzing all sources"); | 2452 if (finishedAnalyzing) { |
| 2453 fail( |
| 2454 "performAnalysisTask failed to finish analyzing all sources after $max
Iterations iterations"); |
| 2455 } else { |
| 2456 fail( |
| 2457 "performAnalysisTask failed to terminate after analyzing all sources")
; |
| 2458 } |
2451 } | 2459 } |
2452 | 2460 |
2453 void _assertNoExceptions() { | 2461 void _assertNoExceptions() { |
2454 MapIterator<AnalysisTarget, CacheEntry> iterator = analysisCache.iterator(); | 2462 MapIterator<AnalysisTarget, CacheEntry> iterator = analysisCache.iterator(); |
2455 String exceptionsStr = ''; | 2463 String exceptionsStr = ''; |
2456 while (iterator.moveNext()) { | 2464 while (iterator.moveNext()) { |
2457 CaughtException exception = iterator.value.exception; | 2465 CaughtException exception = iterator.value.exception; |
2458 if (exception != null) { | 2466 if (exception != null) { |
2459 AnalysisTarget target = iterator.key; | 2467 AnalysisTarget target = iterator.key; |
2460 exceptionsStr += | 2468 exceptionsStr += |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2944 * Initialize the visitor. | 2952 * Initialize the visitor. |
2945 */ | 2953 */ |
2946 _ElementGatherer(); | 2954 _ElementGatherer(); |
2947 | 2955 |
2948 @override | 2956 @override |
2949 void visitElement(Element element) { | 2957 void visitElement(Element element) { |
2950 elements[element] = element; | 2958 elements[element] = element; |
2951 super.visitElement(element); | 2959 super.visitElement(element); |
2952 } | 2960 } |
2953 } | 2961 } |
OLD | NEW |