Update _ContextTypeVisitor to support ConstructorName / ConstructorReference.

We need it to trigger constructor reference suggestions.

Change-Id: I2a04520c85393b25f6db7fdd1e478aad81398a96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216762
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-10-14 15:21:52 +00:00 committed by commit-bot@chromium.org
parent 7e717e3ff7
commit b6349445df
2 changed files with 34 additions and 0 deletions

View file

@ -651,6 +651,16 @@ class _ContextTypeVisitor extends SimpleAstVisitor<DartType> {
return null;
}
@override
DartType? visitConstructorName(ConstructorName node) {
return _visitParent(node);
}
@override
DartType? visitConstructorReference(ConstructorReference node) {
return _visitParent(node);
}
@override
DartType? visitDefaultFormalParameter(DefaultFormalParameter node) {
var separator = node.separator;

View file

@ -438,6 +438,30 @@ class C {
''', 'num');
}
Future<void> test_className_period() async {
await assertContextType('''
int x = List.^;
''', 'int');
}
Future<void> test_className_period_identifier() async {
await assertContextType('''
int x = List.^;
''', 'int');
}
Future<void> test_className_typeArguments_period() async {
await assertContextType('''
int x = List<double>.^;
''', 'int');
}
Future<void> test_className_typeArguments_period_identifier() async {
await assertContextType('''
int x = List<double>.foo^;
''', 'int');
}
Future<void> test_fieldDeclaration_int() async {
await assertContextType('''
class Foo {