mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:00:09 +00:00
Test that class references are indexed / searched / renamed in record type annotations.
Change-Id: I29d9645c2509829e9dd8ba44ded7b38bbab217e1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257424 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
35d19a460c
commit
6484fa91ab
|
@ -52,6 +52,7 @@ class AbstractContextTest with ResourceProviderMixin {
|
|||
EnableString.enhanced_enums,
|
||||
EnableString.macros,
|
||||
EnableString.named_arguments_anywhere,
|
||||
EnableString.records,
|
||||
EnableString.super_parameters,
|
||||
];
|
||||
|
||||
|
|
|
@ -519,6 +519,44 @@ class _NewPageState extends State<NewPage> {
|
|||
''');
|
||||
}
|
||||
|
||||
Future<void>
|
||||
test_createChange_ClassElement_inRecordTypeAnnotation_named() async {
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
void f(({int foo, Test bar}) r) {}
|
||||
''');
|
||||
// configure refactoring
|
||||
createRenameRefactoringAtString('Test {}');
|
||||
expect(refactoring.refactoringName, 'Rename Class');
|
||||
expect(refactoring.elementKindName, 'class');
|
||||
expect(refactoring.oldName, 'Test');
|
||||
refactoring.newName = 'NewName';
|
||||
// validate change
|
||||
return assertSuccessfulRefactoring('''
|
||||
class NewName {}
|
||||
void f(({int foo, NewName bar}) r) {}
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void>
|
||||
test_createChange_ClassElement_inRecordTypeAnnotation_positional() async {
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
void f((int, Test) r) {}
|
||||
''');
|
||||
// configure refactoring
|
||||
createRenameRefactoringAtString('Test {}');
|
||||
expect(refactoring.refactoringName, 'Rename Class');
|
||||
expect(refactoring.elementKindName, 'class');
|
||||
expect(refactoring.oldName, 'Test');
|
||||
refactoring.newName = 'NewName';
|
||||
// validate change
|
||||
return assertSuccessfulRefactoring('''
|
||||
class NewName {}
|
||||
void f((int, NewName) r) {}
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_createChange_ClassElement_invocation() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
await indexTestUnit('''
|
||||
|
|
|
@ -663,6 +663,24 @@ void f() {}
|
|||
..isReferencedAt('A>()', false);
|
||||
}
|
||||
|
||||
test_isReferencedBy_ClassElement_inRecordTypeAnnotation_named() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
|
||||
void f(({int foo, A bar}) r) {}
|
||||
''');
|
||||
assertThat(findElement.class_('A')).isReferencedAt('A bar', false);
|
||||
}
|
||||
|
||||
test_isReferencedBy_ClassElement_inRecordTypeAnnotation_positional() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
|
||||
void f((int, A) r) {}
|
||||
''');
|
||||
assertThat(findElement.class_('A')).isReferencedAt('A)', false);
|
||||
}
|
||||
|
||||
test_isReferencedBy_ClassElement_inTypeAlias() async {
|
||||
await _indexTestUnit('''
|
||||
class A<T> {}
|
||||
|
|
|
@ -614,6 +614,40 @@ main(MyEnum p) {
|
|||
await _verifyReferences(element, expected);
|
||||
}
|
||||
|
||||
test_searchReferences_ClassElement_inRecordTypeAnnotation_named() async {
|
||||
await resolveTestCode('''
|
||||
class A {}
|
||||
|
||||
void f(({int foo, A bar}) r) {}
|
||||
''');
|
||||
var element = findElement.class_('A');
|
||||
var expected = [
|
||||
_expectId(
|
||||
findElement.parameter('r'),
|
||||
SearchResultKind.REFERENCE,
|
||||
'A bar',
|
||||
),
|
||||
];
|
||||
await _verifyReferences(element, expected);
|
||||
}
|
||||
|
||||
test_searchReferences_ClassElement_inRecordTypeAnnotation_positional() async {
|
||||
await resolveTestCode('''
|
||||
class A {}
|
||||
|
||||
void f((int, A) r) {}
|
||||
''');
|
||||
var element = findElement.class_('A');
|
||||
var expected = [
|
||||
_expectId(
|
||||
findElement.parameter('r'),
|
||||
SearchResultKind.REFERENCE,
|
||||
'A)',
|
||||
),
|
||||
];
|
||||
await _verifyReferences(element, expected);
|
||||
}
|
||||
|
||||
test_searchReferences_ClassElement_mixin() async {
|
||||
await resolveTestCode('''
|
||||
mixin A {}
|
||||
|
@ -2393,7 +2427,7 @@ class F {}
|
|||
}
|
||||
}
|
||||
|
||||
test_subtypes_class_discover() async {
|
||||
test_subTypes_class_discover() async {
|
||||
var aaaPackageRootPath = '$packagesRootPath/aaa';
|
||||
var bbbPackageRootPath = '$packagesRootPath/bbb';
|
||||
|
||||
|
@ -2463,7 +2497,7 @@ class A {
|
|||
expect(b.members, ['method1']);
|
||||
}
|
||||
|
||||
test_subTypes_class_discover() async {
|
||||
test_subTypes_class_discover2() async {
|
||||
var aaaPackageRootPath = '$packagesRootPath/aaa';
|
||||
var bbbPackageRootPath = '$packagesRootPath/bbb';
|
||||
var cccPackageRootPath = '$packagesRootPath/ccc';
|
||||
|
|
Loading…
Reference in a new issue