| 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 engine.declaration_resolver_test; | 5 library engine.declaration_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/src/dart/ast/ast.dart'; | 9 import 'package:analyzer/src/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/src/dart/ast/utilities.dart'; | 10 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 '''; | 295 '''; |
| 296 CompilationUnit unit = resolveSource(code); | 296 CompilationUnit unit = resolveSource(code); |
| 297 FunctionElement setterElement = | 297 FunctionElement setterElement = |
| 298 _findSimpleIdentifier(unit, code, 'zzz(x)').staticElement; | 298 _findSimpleIdentifier(unit, code, 'zzz(x)').staticElement; |
| 299 // re-resolve | 299 // re-resolve |
| 300 CompilationUnit unit2 = _cloneResolveUnit(unit); | 300 CompilationUnit unit2 = _cloneResolveUnit(unit); |
| 301 SimpleIdentifier setterName = _findSimpleIdentifier(unit2, code, 'zzz(x)'); | 301 SimpleIdentifier setterName = _findSimpleIdentifier(unit2, code, 'zzz(x)'); |
| 302 expect(setterName.staticElement, same(setterElement)); | 302 expect(setterName.staticElement, same(setterElement)); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void test_visitFunctionExpression() { |
| 306 String code = r''' |
| 307 main(List<String> items) { |
| 308 items.forEach((item) {}); |
| 309 } |
| 310 '''; |
| 311 CompilationUnit unit = resolveSource(code); |
| 312 // re-resolve |
| 313 _cloneResolveUnit(unit); |
| 314 // no other validations than built into DeclarationResolver |
| 315 } |
| 316 |
| 305 void test_visitMethodDeclaration_getter_duplicate() { | 317 void test_visitMethodDeclaration_getter_duplicate() { |
| 306 String code = r''' | 318 String code = r''' |
| 307 class C { | 319 class C { |
| 308 int get zzz => 1; | 320 int get zzz => 1; |
| 309 String get zzz => null; | 321 String get zzz => null; |
| 310 } | 322 } |
| 311 '''; | 323 '''; |
| 312 CompilationUnit unit = resolveSource(code); | 324 CompilationUnit unit = resolveSource(code); |
| 313 PropertyAccessorElement firstElement = | 325 PropertyAccessorElement firstElement = |
| 314 _findSimpleIdentifier(unit, code, 'zzz => 1').staticElement; | 326 _findSimpleIdentifier(unit, code, 'zzz => 1').staticElement; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 expect(element.type.toString(), "<T>(T, T) → T"); | 447 expect(element.type.toString(), "<T>(T, T) → T"); |
| 436 expect(t.element, same(tElement)); | 448 expect(t.element, same(tElement)); |
| 437 | 449 |
| 438 // re-resolve | 450 // re-resolve |
| 439 CompilationUnit unit2 = _cloneResolveUnit(unit); | 451 CompilationUnit unit2 = _cloneResolveUnit(unit); |
| 440 node = _findSimpleIdentifier(unit2, code, 'max').parent; | 452 node = _findSimpleIdentifier(unit2, code, 'max').parent; |
| 441 t = node.typeParameters.typeParameters[0]; | 453 t = node.typeParameters.typeParameters[0]; |
| 442 expect(t.element, same(tElement)); | 454 expect(t.element, same(tElement)); |
| 443 } | 455 } |
| 444 } | 456 } |
| OLD | NEW |