mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Augment. Add all library files, fixes search for constructor added by augmentation.
Change-Id: Idb6d489f454a028e7fa971d5b9f46550b5861940 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352683 Reviewed-by: Keerti Parthasarathy <keertip@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
9a9f23fd35
commit
ea8efc6fc1
3 changed files with 44 additions and 5 deletions
|
@ -939,8 +939,7 @@ void f() {
|
||||||
}
|
}
|
||||||
''');
|
''');
|
||||||
await findElementReferences(search: 'fff(p) {}', false);
|
await findElementReferences(search: 'fff(p) {}', false);
|
||||||
expect(results, hasLength(1));
|
expect(results, isEmpty);
|
||||||
assertHasResult(SearchResultKind.INVOCATION, 'fff(10);');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> test_parameter() async {
|
Future<void> test_parameter() async {
|
||||||
|
|
|
@ -565,9 +565,14 @@ class Search {
|
||||||
} else {
|
} else {
|
||||||
files = await _driver.getFilesReferencingName(name);
|
files = await _driver.getFilesReferencingName(name);
|
||||||
}
|
}
|
||||||
if (searchedFiles.add(elementFile.path, this)) {
|
// Add all files of the library.
|
||||||
if (!files.contains(elementFile)) {
|
if (elementFile.kind.library case var library?) {
|
||||||
files.add(elementFile);
|
for (var file in library.files) {
|
||||||
|
if (searchedFiles.add(file.path, this)) {
|
||||||
|
if (!files.contains(file)) {
|
||||||
|
files.add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -817,6 +817,41 @@ self::@class::C::@method::main
|
||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_searchReferences_class_constructor_declaredInAugmentation() async {
|
||||||
|
newFile('$testPackageLibPath/a.dart', r'''
|
||||||
|
library augment 'test.dart';
|
||||||
|
|
||||||
|
augment class A {
|
||||||
|
A.named();
|
||||||
|
}
|
||||||
|
''');
|
||||||
|
|
||||||
|
await resolveTestCode('''
|
||||||
|
import augment 'a.dart';
|
||||||
|
|
||||||
|
class A {
|
||||||
|
void foo() {
|
||||||
|
A.named();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void f() {
|
||||||
|
A.named();
|
||||||
|
}
|
||||||
|
''');
|
||||||
|
|
||||||
|
final A = findElement.class_('A');
|
||||||
|
final element = A.augmented!.constructors.single;
|
||||||
|
expect(element.name, 'named');
|
||||||
|
|
||||||
|
await assertElementReferencesText(element, r'''
|
||||||
|
self::@class::A::@method::foo
|
||||||
|
56 5:6 |.named| INVOCATION qualified
|
||||||
|
self::@function::f
|
||||||
|
87 10:4 |.named| INVOCATION qualified
|
||||||
|
''');
|
||||||
|
}
|
||||||
|
|
||||||
test_searchReferences_class_getter_in_objectPattern() async {
|
test_searchReferences_class_getter_in_objectPattern() async {
|
||||||
await resolveTestCode('''
|
await resolveTestCode('''
|
||||||
void f(Object? x) {
|
void f(Object? x) {
|
||||||
|
|
Loading…
Reference in a new issue