Fix a bug in textDocument/definition for primary constructors
Change-Id: Id24cdfda1c84322b5fa77cca0c87df0784482ec6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506080 Commit-Queue: Samuel Rawlins <srawlins@google.com> Auto-Submit: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
8765d80177
commit
ec40ebcd23
@@ -65,9 +65,12 @@ class KeywordNavigationComputer {
|
||||
MethodDeclaration() => function.name,
|
||||
ConstructorDeclaration() =>
|
||||
// For named constructors, return the name.
|
||||
// For unnamed constructors, use the return type / class name.
|
||||
// TODO(scheglov): support primary constructors
|
||||
function.name ?? function.typeName!.beginToken,
|
||||
// For unnamed constructors, use the return type / class name, or the
|
||||
// `new` or `factory` keyword.
|
||||
function.name ??
|
||||
function.typeName?.beginToken ??
|
||||
function.newKeyword ??
|
||||
function.factoryKeyword,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1057,6 +1057,31 @@ class MyClass {
|
||||
await testContents(contents);
|
||||
}
|
||||
|
||||
Future<void> test_keywordNavigation_return_toConstructor_withFactory() async {
|
||||
var contents = '''
|
||||
class MyClass {
|
||||
[!factory!] () {
|
||||
ret^urn MyClass.n();
|
||||
}
|
||||
MyClass.n();
|
||||
}
|
||||
''';
|
||||
|
||||
await testContents(contents);
|
||||
}
|
||||
|
||||
Future<void> test_keywordNavigation_return_toConstructor_withNew() async {
|
||||
var contents = '''
|
||||
class MyClass {
|
||||
[!new!] () {
|
||||
ret^urn;
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
await testContents(contents);
|
||||
}
|
||||
|
||||
Future<void> test_keywordNavigation_return_toFunction() async {
|
||||
var contents = '''
|
||||
int [!foo!]() {
|
||||
|
||||
Reference in New Issue
Block a user