|
2 | 2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | 3 | // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
|
5 | | -// ignore_for_file: analyzer_use_new_elements |
6 | | - |
7 | | -import 'package:analyzer/dart/element/element.dart'; |
8 | | -import 'package:analyzer/src/dart/element/element.dart'; |
9 | 5 | import 'package:test/test.dart'; |
10 | 6 | import 'package:test_reflective_loader/test_reflective_loader.dart'; |
11 | 7 |
|
@@ -408,9 +404,8 @@ class C { |
408 | 404 | } |
409 | 405 | '''); |
410 | 406 | // Check metadata without asking any other properties. |
411 | | - var x = _elementOfDefiningUnit(library, ['@class', 'C', '@field', 'x']) |
412 | | - as FieldElement; |
413 | | - expect(x.metadata, hasLength(1)); |
| 407 | + var x = library.getClass2('C')!.getField2('x')!; |
| 408 | + expect(x.metadata2.annotations, hasLength(1)); |
414 | 409 | // Check details. |
415 | 410 | checkElementText(library, r''' |
416 | 411 | library |
@@ -10360,9 +10355,8 @@ const a = 0; |
10360 | 10355 | int x = 0; |
10361 | 10356 | '''); |
10362 | 10357 | // Check metadata without asking any other properties. |
10363 | | - var x = _elementOfDefiningUnit(library, ['@topLevelVariable', 'x']) |
10364 | | - as TopLevelVariableElement; |
10365 | | - expect(x.metadata, hasLength(1)); |
| 10358 | + var x = library.getTopLevelVariable('x')!; |
| 10359 | + expect(x.metadata2.annotations, hasLength(1)); |
10366 | 10360 | // Check details. |
10367 | 10361 | checkElementText(library, r''' |
10368 | 10362 | library |
@@ -12076,23 +12070,6 @@ library |
12076 | 12070 | firstFragment: <testLibraryFragment>::@class::C::@constructor::new |
12077 | 12071 | '''); |
12078 | 12072 | } |
12079 | | - |
12080 | | - // TODO(scheglov): This is duplicate. |
12081 | | - Element _elementOfDefiningUnit( |
12082 | | - LibraryElementImpl library, List<String> names) { |
12083 | | - var reference = library.definingCompilationUnit.reference!; |
12084 | | - for (var name in names) { |
12085 | | - reference = reference.getChild(name); |
12086 | | - } |
12087 | | - |
12088 | | - var element = reference.element; |
12089 | | - if (element != null) { |
12090 | | - return element; |
12091 | | - } |
12092 | | - |
12093 | | - var elementFactory = library.linkedData!.elementFactory; |
12094 | | - return elementFactory.elementOfReference(reference)!; |
12095 | | - } |
12096 | 12073 | } |
12097 | 12074 |
|
12098 | 12075 | @reflectiveTest |
|
0 commit comments