@@ -119,6 +119,14 @@ void [!^f!]() {}
119
119
await testContents (contents);
120
120
}
121
121
122
+ Future <void > test_atDeclaration_importPrefix () async {
123
+ var contents = '''
124
+ import 'dart:math' as [!^math!];
125
+ ''' ;
126
+
127
+ await testContents (contents);
128
+ }
129
+
122
130
Future <void > test_atDeclaration_method () async {
123
131
var contents = '''
124
132
class A {
@@ -185,6 +193,15 @@ extension StringExtension on String {
185
193
await testContents (contents);
186
194
}
187
195
196
+ Future <void > test_comment_importPrefix () async {
197
+ var contents = '''
198
+ /// This is a comment for [^math]
199
+ import 'dart:math' as [!math!];
200
+ ''' ;
201
+
202
+ await testContents (contents);
203
+ }
204
+
188
205
Future <void > test_comment_instanceMember_qualified () async {
189
206
var contents = '''
190
207
/// [A.myFi^eld].
@@ -450,6 +467,91 @@ foo(Object pair) {
450
467
await testContents (contents);
451
468
}
452
469
470
+ Future <void > test_importPrefix () async {
471
+ var contents = '''
472
+ import 'dart:math' as [!math!];
473
+
474
+ ^math.Random? r;
475
+ ''' ;
476
+
477
+ await testContents (contents);
478
+ }
479
+
480
+ Future <void > test_importPrefix_multiple () async {
481
+ setLocationLinkSupport ();
482
+
483
+ var code = TestCode .parse ('''
484
+ import 'dart:math' as /*[0*/math/*0]*/;
485
+ import 'dart:async' as /*[1*/math/*1]*/;
486
+
487
+ /*[2*/^math/*2]*/.Random? r;
488
+ ''' );
489
+
490
+ await initialize ();
491
+ await openFile (mainFileUri, code.code);
492
+ var res = await getDefinitionAsLocationLinks (
493
+ mainFileUri,
494
+ code.position.position,
495
+ );
496
+
497
+ expect (res, hasLength (2 ));
498
+ for (var (index, loc) in res.indexed) {
499
+ expect (loc.originSelectionRange, equals (code.ranges.last.range));
500
+ expect (loc.targetRange, equals (code.ranges[index].range));
501
+ expect (loc.targetSelectionRange, equals (code.ranges[index].range));
502
+ }
503
+ }
504
+
505
+ Future <void > test_importPrefix_multiple_alone () async {
506
+ var code = TestCode .parse ('''
507
+ import 'dart:math' as /*[0*/math/*0]*/;
508
+ import 'dart:async' as /*[1*/math/*1]*/;
509
+
510
+ void foo() {
511
+ // ignore: prefix_identifier_not_followed_by_dot
512
+ /*[2*/^math/*2]*/;
513
+ }
514
+ ''' );
515
+
516
+ await initialize ();
517
+ await openFile (mainFileUri, code.code);
518
+ var res = await getDefinitionAsLocation (
519
+ mainFileUri,
520
+ code.position.position,
521
+ );
522
+
523
+ expect (res, hasLength (2 ));
524
+ for (var (index, loc) in res.indexed) {
525
+ expect (loc.range, equals (code.ranges[index].range));
526
+ }
527
+ }
528
+
529
+ Future <void > test_importPrefix_multiple_comment () async {
530
+ setLocationLinkSupport ();
531
+
532
+ var code = TestCode .parse ('''
533
+ import 'dart:math' as /*[0*/math/*0]*/;
534
+ import 'dart:async' as /*[1*/math/*1]*/;
535
+
536
+ /// This is a comment that talks about [/*[2*/^math/*2]*/].
537
+ math.Random? r;
538
+ ''' );
539
+
540
+ await initialize ();
541
+ await openFile (mainFileUri, code.code);
542
+ var res = await getDefinitionAsLocationLinks (
543
+ mainFileUri,
544
+ code.position.position,
545
+ );
546
+
547
+ expect (res, hasLength (2 ));
548
+ for (var (index, loc) in res.indexed) {
549
+ expect (loc.originSelectionRange, equals (code.ranges.last.range));
550
+ expect (loc.targetRange, equals (code.ranges[index].range));
551
+ expect (loc.targetSelectionRange, equals (code.ranges[index].range));
552
+ }
553
+ }
554
+
453
555
Future <void > test_locationLink_class () async {
454
556
setLocationLinkSupport ();
455
557
0 commit comments