@@ -81,6 +81,25 @@ class HoverTest extends AbstractLspAnalysisServerTest {
81
81
expect (markup.value, matcher);
82
82
}
83
83
84
+ Future <void > assertNullHover (
85
+ String content, {
86
+ bool waitForAnalysis = false ,
87
+ bool withOpenFile = true ,
88
+ }) async {
89
+ var code = TestCode .parse (content);
90
+
91
+ var initialAnalysis = waitForAnalysis ? waitForAnalysisComplete () : null ;
92
+ await initialize ();
93
+ if (withOpenFile) {
94
+ await openFile (mainFileUri, code.code);
95
+ } else {
96
+ newFile (mainFilePath, code.code);
97
+ }
98
+ await initialAnalysis;
99
+ var hover = await getHover (mainFileUri, code.position.position);
100
+ expect (hover, isNull);
101
+ }
102
+
84
103
Future <void > assertPlainTextContents (String content, Matcher matcher) async {
85
104
setHoverContentFormat ([MarkupKind .PlainText ]);
86
105
var code = TestCode .parse (content);
@@ -181,6 +200,23 @@ List<MyEnum> get values
181
200
```
182
201
Type: `List<MyEnum>`
183
202
203
+ *package:test/main.dart*''' ;
204
+ await assertStringContents (content, equals (expected));
205
+ }
206
+
207
+ Future <void > test_field_underscore () async {
208
+ var content = '''
209
+ class A {
210
+ int _ = 1;
211
+ int f() => [!^_!];
212
+ }
213
+ ''' ;
214
+ var expected = '''
215
+ ```dart
216
+ int _
217
+ ```
218
+ Type: `int`
219
+
184
220
*package:test/main.dart*''' ;
185
221
await assertStringContents (content, equals (expected));
186
222
}
@@ -240,6 +276,20 @@ Type: `String`''';
240
276
);
241
277
}
242
278
279
+ Future <void > test_localVariable_wildcard () async {
280
+ var content = '''
281
+ f() {
282
+ int [!^_!] = 0;
283
+ }
284
+ ''' ;
285
+ var expected = '''
286
+ ```dart
287
+ int _
288
+ ```
289
+ Type: `int`''' ;
290
+ await assertStringContents (content, equals (expected));
291
+ }
292
+
243
293
Future <void > test_markdown_isFormattedForDisplay () async {
244
294
var content = '''
245
295
/// This is a string.
@@ -306,6 +356,23 @@ print();
306
356
contains ('This is a method.' ),
307
357
);
308
358
359
+ Future <void > test_method_underscore () async {
360
+ var content = '''
361
+ class A {
362
+ int _() => 1;
363
+ int f() => [!^_!]();
364
+ }
365
+ ''' ;
366
+ var expected = '''
367
+ ```dart
368
+ int _()
369
+ ```
370
+ Type: `int Function()`
371
+
372
+ *package:test/main.dart*''' ;
373
+ await assertStringContents (content, equals (expected));
374
+ }
375
+
309
376
Future <void > test_noElement () async {
310
377
var code = TestCode .parse ('''
311
378
String? abc;
@@ -346,6 +413,18 @@ Type: `String?`
346
413
await assertStringContents (content, equals (expectedHoverContent));
347
414
}
348
415
416
+ Future <void > test_parameter_wildcard () async {
417
+ var content = '''
418
+ f(int [!^_!]) { }
419
+ ''' ;
420
+ var expected = '''
421
+ ```dart
422
+ int _
423
+ ```
424
+ Type: `int`''' ;
425
+ await assertStringContents (content, equals (expected));
426
+ }
427
+
349
428
Future <void > test_pattern_assignment_left () => assertStringContents (
350
429
'''
351
430
void f(String a, String b) {
@@ -807,6 +886,50 @@ This is a string.''';
807
886
await assertStringContents (content, equals (expected));
808
887
}
809
888
889
+ Future <void > test_topLevelFunction_underscore () async {
890
+ var content = '''
891
+ int _() => 1;
892
+ int f() => [!^_!]();
893
+ ''' ;
894
+ var expected = '''
895
+ ```dart
896
+ int _()
897
+ ```
898
+ Type: `int Function()`
899
+
900
+ *package:test/main.dart*''' ;
901
+ await assertStringContents (content, equals (expected));
902
+ }
903
+
904
+ Future <void > test_topLevelVariable_underscore () async {
905
+ var content = '''
906
+ int _ = 1;
907
+ int f() => [!^_!];
908
+ ''' ;
909
+ var expected = '''
910
+ ```dart
911
+ int _
912
+ ```
913
+ Type: `int`
914
+
915
+ *package:test/main.dart*''' ;
916
+ await assertStringContents (content, equals (expected));
917
+ }
918
+
919
+ Future <void > test_typeParameter () async {
920
+ var content = '''
921
+ class C<[!^T!]> {}
922
+ ''' ;
923
+ await assertNullHover (content);
924
+ }
925
+
926
+ Future <void > test_typeParameter_wildcard () async {
927
+ var content = '''
928
+ class C<[!^_!]> {}
929
+ ''' ;
930
+ await assertNullHover (content);
931
+ }
932
+
810
933
Future <void > test_unnamed_library_directive () async {
811
934
var content = '''
812
935
/// This is a string.
0 commit comments