Issue 50603. Fix element kind to EXTENSION in search.getElementDeclarations

Bug: https://github.com/dart-lang/sdk/issues/50603
Change-Id: I22b4d827bc9472544cf3c3aad3473de8050e2f6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274085
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-12-07 22:37:37 +00:00 committed by Commit Queue
parent efaad34a46
commit 356d15a3fc
2 changed files with 33 additions and 0 deletions

View file

@ -47,6 +47,8 @@ class SearchGetElementDeclarationsHandler extends LegacyHandler {
return protocol.ElementKind.ENUM;
case search.DeclarationKind.ENUM_CONSTANT:
return protocol.ElementKind.ENUM_CONSTANT;
case search.DeclarationKind.EXTENSION:
return protocol.ElementKind.EXTENSION;
case search.DeclarationKind.FIELD:
return protocol.ElementKind.FIELD;
case search.DeclarationKind.FUNCTION:

View file

@ -82,6 +82,37 @@ enum E {
assertHas('c', ElementKind.ENUM_CONSTANT);
}
Future<void> test_extension() async {
addTestFile(r'''
extension E on int {
int get foo01 => 0;
void set foo02(_) {}
void foo03() {}
}
''');
await _getDeclarations();
assertHas('E', ElementKind.EXTENSION);
{
var declaration = assertHas('foo01', ElementKind.GETTER);
expect(declaration.codeOffset, 23);
expect(declaration.codeLength, 19);
}
{
var declaration = assertHas('foo02', ElementKind.SETTER);
expect(declaration.codeOffset, 45);
expect(declaration.codeLength, 20);
}
{
var declaration = assertHas('foo03', ElementKind.METHOD);
expect(declaration.codeOffset, 68);
expect(declaration.codeLength, 15);
}
}
Future<void> test_maxResults() async {
newFile('$testPackageLibPath/a.dart', r'''
class A {}