Skip to content

Commit 630dcee

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[analyzer] Add tests for null-aware elements in hover info
Part of #56989 Change-Id: I94eddeb84705ee11d9976442feb7772c864c74b8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398061 Reviewed-by: Keerti Parthasarathy <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 3a67a7d commit 630dcee

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

pkg/analysis_server/test/analysis/get_hover_test.dart

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,70 @@ void f() {
15821582
expect(hover.staticType, 'int? Function(double?)');
15831583
}
15841584

1585+
Future<void> test_nullAwareElement_inList() async {
1586+
newFile(testFilePath, '''
1587+
void f(int? x) {
1588+
[?x];
1589+
}
1590+
''');
1591+
var hover = await prepareHover('x];');
1592+
expect(hover.containingLibraryName, isNull);
1593+
expect(hover.containingLibraryPath, isNull);
1594+
expect(hover.containingClassDescription, isNull);
1595+
expect(hover.dartdoc, isNull);
1596+
expect(hover.elementDescription, 'int? x');
1597+
expect(hover.elementKind, 'parameter');
1598+
expect(hover.staticType, 'int?');
1599+
}
1600+
1601+
Future<void> test_nullAwareElement_inSet() async {
1602+
newFile(testFilePath, '''
1603+
void f(int? x) {
1604+
{?x};
1605+
}
1606+
''');
1607+
var hover = await prepareHover('x};');
1608+
expect(hover.containingLibraryName, isNull);
1609+
expect(hover.containingLibraryPath, isNull);
1610+
expect(hover.containingClassDescription, isNull);
1611+
expect(hover.dartdoc, isNull);
1612+
expect(hover.elementDescription, 'int? x');
1613+
expect(hover.elementKind, 'parameter');
1614+
expect(hover.staticType, 'int?');
1615+
}
1616+
1617+
Future<void> test_nullAwareKey_inMap() async {
1618+
newFile(testFilePath, '''
1619+
void f(int? x) {
1620+
{?x: ""};
1621+
}
1622+
''');
1623+
var hover = await prepareHover('x: ');
1624+
expect(hover.containingLibraryName, isNull);
1625+
expect(hover.containingLibraryPath, isNull);
1626+
expect(hover.containingClassDescription, isNull);
1627+
expect(hover.dartdoc, isNull);
1628+
expect(hover.elementDescription, 'int? x');
1629+
expect(hover.elementKind, 'parameter');
1630+
expect(hover.staticType, 'int?');
1631+
}
1632+
1633+
Future<void> test_nullAwareValue_inMap() async {
1634+
newFile(testFilePath, '''
1635+
void f(int? x) {
1636+
{"": ?x};
1637+
}
1638+
''');
1639+
var hover = await prepareHover('x};');
1640+
expect(hover.containingLibraryName, isNull);
1641+
expect(hover.containingLibraryPath, isNull);
1642+
expect(hover.containingClassDescription, isNull);
1643+
expect(hover.dartdoc, isNull);
1644+
expect(hover.elementDescription, 'int? x');
1645+
expect(hover.elementKind, 'parameter');
1646+
expect(hover.staticType, 'int?');
1647+
}
1648+
15851649
Future<void> test_parameter_declaration_fieldFormal() async {
15861650
newFile(testFilePath, '''
15871651
class A {

0 commit comments

Comments
 (0)