mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Add call hierarchy tests for augmentations
Change-Id: I5078dc604f1c5368fde708cd95033d3b134874d2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352401 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Keerti Parthasarathy <keertip@google.com>
This commit is contained in:
parent
de6d8cb813
commit
3904a92c40
|
@ -7,6 +7,7 @@ import 'package:analysis_server/src/services/search/search_engine.dart';
|
|||
import 'package:analysis_server/src/services/search/search_engine_internal.dart';
|
||||
import 'package:analyzer/source/source_range.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:matcher/expect.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
@ -172,6 +173,37 @@ class Foo {
|
|||
));
|
||||
}
|
||||
|
||||
Future<void> test_constructorCall_to_augmentation() async {
|
||||
final code = TestCode.parse('''
|
||||
import augment 'other.dart';
|
||||
|
||||
class Foo {}
|
||||
|
||||
void f() {
|
||||
Foo.na^med();
|
||||
}
|
||||
''');
|
||||
|
||||
final otherCode = TestCode.parse('''
|
||||
library augment 'test.dart';
|
||||
augment class Foo {
|
||||
[!Foo.named(){}!]
|
||||
}
|
||||
''');
|
||||
|
||||
newFile(otherFile, otherCode.code);
|
||||
await expectTarget(
|
||||
code,
|
||||
_isItem(
|
||||
CallHierarchyKind.constructor,
|
||||
'Foo.named',
|
||||
otherFile,
|
||||
containerName: 'Foo',
|
||||
nameRange: rangeAtSearch('named', otherCode),
|
||||
codeRange: otherCode.range.sourceRange,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> test_extension_method() async {
|
||||
final code = TestCode.parse('''
|
||||
extension StringExtension on String {
|
||||
|
@ -455,6 +487,38 @@ class Foo {
|
|||
));
|
||||
}
|
||||
|
||||
Future<void> test_methodCall_to_augmentation() async {
|
||||
final code = TestCode.parse('''
|
||||
import augment 'other.dart';
|
||||
|
||||
class Foo {}
|
||||
|
||||
void f() {
|
||||
Foo().myMet^hod();
|
||||
}
|
||||
''');
|
||||
|
||||
final otherCode = TestCode.parse('''
|
||||
library augment 'test.dart';
|
||||
|
||||
augment class Foo {
|
||||
[!void myMethod() {}!]
|
||||
}
|
||||
''');
|
||||
|
||||
newFile(otherFile, otherCode.code);
|
||||
await expectTarget(
|
||||
code,
|
||||
_isItem(
|
||||
CallHierarchyKind.method,
|
||||
'myMethod',
|
||||
otherFile,
|
||||
containerName: 'Foo',
|
||||
nameRange: rangeAtSearch('myMethod', otherCode),
|
||||
codeRange: otherCode.range.sourceRange,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> test_mixin_method() async {
|
||||
final code = TestCode.parse('''
|
||||
mixin Bar {
|
||||
|
@ -1015,6 +1079,39 @@ import 'test.dart';
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> test_method_from_augmentation() async {
|
||||
final code = TestCode.parse('''
|
||||
import augment 'other.dart';
|
||||
|
||||
class Foo {
|
||||
void myMet^hod() {}
|
||||
}
|
||||
''');
|
||||
|
||||
final otherCode = TestCode.parse('''
|
||||
library augment 'test.dart';
|
||||
|
||||
augment class Foo {
|
||||
[!void f() {
|
||||
myMethod();
|
||||
}!]
|
||||
}
|
||||
''');
|
||||
|
||||
newFile(otherFile, otherCode.code);
|
||||
final calls = await findIncomingCalls(code);
|
||||
expect(calls, [
|
||||
_isResult(
|
||||
CallHierarchyKind.method,
|
||||
'f',
|
||||
otherFile,
|
||||
containerName: 'Foo',
|
||||
nameRange: rangeAtSearch('f() {', otherCode, 'f'),
|
||||
codeRange: otherCode.range.sourceRange,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> test_mixin_method() async {
|
||||
final code = TestCode.parse('''
|
||||
mixin Bar {
|
||||
|
@ -1209,6 +1306,40 @@ class A {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> test_constructor_from_augmentation() async {
|
||||
final code = TestCode.parse('''
|
||||
import augment 'other.dart';
|
||||
|
||||
class Foo {}
|
||||
|
||||
void ba^r() {
|
||||
Foo.named();
|
||||
}
|
||||
''');
|
||||
|
||||
final otherCode = TestCode.parse('''
|
||||
library augment 'test.dart';
|
||||
|
||||
augment class Foo {
|
||||
[!Foo.named() {
|
||||
}!]
|
||||
}
|
||||
''');
|
||||
|
||||
newFile(otherFile, otherCode.code);
|
||||
final calls = await findOutgoingCalls(code);
|
||||
expect(calls, [
|
||||
_isResult(
|
||||
CallHierarchyKind.constructor,
|
||||
'Foo.named',
|
||||
otherFile,
|
||||
containerName: 'Foo',
|
||||
nameRange: rangeAtSearch('named() {', otherCode, 'named'),
|
||||
codeRange: otherCode.range.sourceRange,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> test_extension_method() async {
|
||||
final code = TestCode.parse('''
|
||||
// ignore_for_file: unused_local_variable
|
||||
|
@ -1428,6 +1559,43 @@ class Foo {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> test_method_from_augmentation() async {
|
||||
final code = TestCode.parse('''
|
||||
import augment 'other.dart';
|
||||
|
||||
class Foo {}
|
||||
|
||||
void ba^r() {
|
||||
Foo().myMethod();
|
||||
}
|
||||
''');
|
||||
|
||||
final otherCode = TestCode.parse('''
|
||||
library augment 'test.dart';
|
||||
|
||||
augment class Foo {
|
||||
[!void myMethod() {
|
||||
}!]
|
||||
}
|
||||
''');
|
||||
|
||||
newFile(otherFile, otherCode.code);
|
||||
final calls = await findOutgoingCalls(code);
|
||||
expect(
|
||||
calls,
|
||||
contains(
|
||||
_isResult(
|
||||
CallHierarchyKind.method,
|
||||
'myMethod',
|
||||
otherFile,
|
||||
containerName: 'Foo',
|
||||
nameRange: rangeAtSearch('myMethod() {', otherCode, 'myMethod'),
|
||||
codeRange: otherCode.range.sourceRange,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> test_mixin_method() async {
|
||||
final code = TestCode.parse('''
|
||||
// ignore_for_file: unused_local_variable
|
||||
|
|
Loading…
Reference in a new issue