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 5239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5250 */ | 5250 */ |
5251 void expectNoDifferences() { | 5251 void expectNoDifferences() { |
5252 if (overwrittenCount > 0) { | 5252 if (overwrittenCount > 0) { |
5253 fail('Found $overwrittenCount overwritten elements.$buffer'); | 5253 fail('Found $overwrittenCount overwritten elements.$buffer'); |
5254 } | 5254 } |
5255 } | 5255 } |
5256 | 5256 |
5257 @override | 5257 @override |
5258 void visitElement(Element element) { | 5258 void visitElement(Element element) { |
5259 Element previousElement = previousElements[element]; | 5259 Element previousElement = previousElements[element]; |
5260 if (!identical(previousElement, element)) { | 5260 bool expectIdentical = element is! LocalVariableElement; |
| 5261 bool ok = expectIdentical |
| 5262 ? identical(previousElement, element) |
| 5263 : previousElement == element; |
| 5264 if (!ok) { |
5261 if (overwrittenCount == 0) { | 5265 if (overwrittenCount == 0) { |
5262 buffer.writeln(); | 5266 buffer.writeln(); |
5263 } | 5267 } |
5264 overwrittenCount++; | 5268 overwrittenCount++; |
5265 buffer.writeln('Overwritten element:'); | 5269 buffer.writeln('Overwritten element:'); |
5266 Element currentElement = element; | 5270 Element currentElement = element; |
5267 while (currentElement != null) { | 5271 while (currentElement != null) { |
5268 buffer.write(' '); | 5272 buffer.write(' '); |
5269 buffer.writeln(currentElement.toString()); | 5273 buffer.writeln(currentElement.toString()); |
5270 currentElement = currentElement.enclosingElement; | 5274 currentElement = currentElement.enclosingElement; |
(...skipping 18 matching lines...) Expand all Loading... |
5289 * Initialize the visitor. | 5293 * Initialize the visitor. |
5290 */ | 5294 */ |
5291 _ElementGatherer(); | 5295 _ElementGatherer(); |
5292 | 5296 |
5293 @override | 5297 @override |
5294 void visitElement(Element element) { | 5298 void visitElement(Element element) { |
5295 elements[element] = element; | 5299 elements[element] = element; |
5296 super.visitElement(element); | 5300 super.visitElement(element); |
5297 } | 5301 } |
5298 } | 5302 } |
OLD | NEW |