@@ -19,7 +19,8 @@ class CompletionTest {
19
19
.completion(m1, Set (
20
20
(" print" , Method , " (x: Any): Unit" ),
21
21
(" printf" , Method , " (text: String, xs: Any*): Unit" ),
22
- (" println" , Method , " method println" )
22
+ (" println" , Method , " (x: Any): Unit" ),
23
+ (" println" , Method , " (): Unit" )
23
24
))
24
25
}
25
26
@@ -35,17 +36,22 @@ class CompletionTest {
35
36
36
37
@ Test def completionFromScalaPackageObject : Unit = {
37
38
code " class Foo { val foo: BigD ${m1} } " .withSource
38
- .completion(m1, Set ((" BigDecimal" , Field , " type and getter BigDecimal" )))
39
+ .completion(m1, Set ((" BigDecimal" , Field , " scala.BigDecimal" ),
40
+ (" BigDecimal" , Method , " => math.BigDecimal.type" )))
39
41
}
40
42
41
43
@ Test def completionFromSyntheticPackageObject : Unit = {
42
44
code " class Foo { val foo: IArr ${m1} } " .withSource
43
- .completion(m1, Set ((" IArray" , Field , " type and object IArray" )))
45
+ .completion(m1, Set ((" IArray" , Field , " scala.IArray" ),
46
+ (" IArray" , Module , " scala.IArray$package.IArray$" )))
44
47
}
45
48
46
49
@ Test def completionFromJavaDefaults : Unit = {
47
50
code " class Foo { val foo: Runn ${m1} } " .withSource
48
- .completion(m1, Set ((" Runnable" , Class , " trait and object Runnable" )))
51
+ .completion(m1, Set (
52
+ (" Runnable" , Class , " java.lang.Runnable" ),
53
+ (" Runnable" , Module , " Runnable$" )
54
+ ))
49
55
}
50
56
51
57
@ Test def completionWithImplicitConversion : Unit = {
@@ -125,7 +131,8 @@ class CompletionTest {
125
131
object Foo """ ,
126
132
code """ package pgk1
127
133
import pkg0.F ${m1}"""
128
- ).completion(m1, Set ((" Foo" , Class , " class and object Foo" )))
134
+ ).completion(m1, Set ((" Foo" , Class , " pkg0.Foo" ),
135
+ (" Foo" , Module , " pkg0.Foo$" )))
129
136
}
130
137
131
138
@ Test def importCompleteIncludePackage : Unit = {
@@ -157,7 +164,8 @@ class CompletionTest {
157
164
158
165
@ Test def importJavaClass : Unit = {
159
166
code """ import java.io.FileDesc ${m1}""" .withSource
160
- .completion(m1, Set ((" FileDescriptor" , Class , " class and object FileDescriptor" )))
167
+ .completion(m1, Set ((" FileDescriptor" , Class , " java.io.FileDescriptor" ),
168
+ (" FileDescriptor" , Module , " java.io.FileDescriptor$" )))
161
169
}
162
170
163
171
@ Test def importJavaStaticMethod : Unit = {
@@ -187,7 +195,8 @@ class CompletionTest {
187
195
188
196
@ Test def importRename : Unit = {
189
197
code """ import java.io.{FileDesc ${m1} => Foo} """ .withSource
190
- .completion(m1, Set ((" FileDescriptor" , Class , " class and object FileDescriptor" )))
198
+ .completion(m1, Set ((" FileDescriptor" , Class , " java.io.FileDescriptor" ),
199
+ (" FileDescriptor" , Module , " java.io.FileDescriptor$" )))
191
200
}
192
201
193
202
@ Test def importGivenByType : Unit = {
@@ -254,7 +263,8 @@ class CompletionTest {
254
263
@ Test def completionOnRenamedImport : Unit = {
255
264
code """ import java.io.{FileDescriptor => AwesomeStuff}
256
265
trait Foo { val x: Awesom $m1 } """ .withSource
257
- .completion(m1, Set ((" AwesomeStuff" , Class , " class and object FileDescriptor" )))
266
+ .completion(m1, Set ((" AwesomeStuff" , Class , " java.io.FileDescriptor" ),
267
+ (" AwesomeStuff" , Module , " java.io.FileDescriptor$" )))
258
268
}
259
269
260
270
@ Test def completionOnRenamedImport2 : Unit = {
@@ -263,7 +273,8 @@ class CompletionTest {
263
273
import java.io.{FileDescriptor => MyImportedSymbol}
264
274
val x: MyImp $m1
265
275
} """ .withSource
266
- .completion(m1, Set ((" MyImportedSymbol" , Class , " class and object FileDescriptor" )))
276
+ .completion(m1, Set ((" MyImportedSymbol" , Class , " java.io.FileDescriptor" ),
277
+ (" MyImportedSymbol" , Module , " java.io.FileDescriptor$" )))
267
278
}
268
279
269
280
@ Test def completionRenamedAndOriginalNames : Unit = {
@@ -272,8 +283,10 @@ class CompletionTest {
272
283
| import java.util.{HashMap => HashMap2}
273
284
| val x: Hash $m1
274
285
|} """ .withSource
275
- .completion(m1, Set ((" HashMap" , Class , " class and object HashMap" ),
276
- (" HashMap2" , Class , " class and object HashMap" )))
286
+ .completion(m1, Set ((" HashMap" , Class , " java.util.HashMap" ),
287
+ (" HashMap" , Module , " java.util.HashMap$" ),
288
+ (" HashMap2" , Class , " java.util.HashMap" ),
289
+ (" HashMap2" , Module , " java.util.HashMap$" )))
277
290
}
278
291
279
292
@ Test def completionRenamedThrice : Unit = {
@@ -283,9 +296,12 @@ class CompletionTest {
283
296
| import java.util.{HashMap => MyHashMap3}
284
297
| val x: MyHash $m1
285
298
|} """ .withSource
286
- .completion(m1, Set ((" MyHashMap" , Class , " class and object HashMap" ),
287
- (" MyHashMap2" , Class , " class and object HashMap" ),
288
- (" MyHashMap3" , Class , " class and object HashMap" )))
299
+ .completion(m1, Set ((" MyHashMap" , Class , " java.util.HashMap" ),
300
+ (" MyHashMap" , Module , " java.util.HashMap$" ),
301
+ (" MyHashMap2" , Class , " java.util.HashMap" ),
302
+ (" MyHashMap2" , Module , " java.util.HashMap$" ),
303
+ (" MyHashMap3" , Class , " java.util.HashMap" ),
304
+ (" MyHashMap3" , Module , " java.util.HashMap$" )))
289
305
}
290
306
291
307
@ Test def completeFromWildcardImports : Unit = {
@@ -369,7 +385,8 @@ class CompletionTest {
369
385
|object Test extends Foo, Bar {
370
386
| val x = xx $m1
371
387
|} """ .withSource
372
- .completion(m1, Set ((" xxxx" , Method , " method xxxx" ))) // 2 different signatures are merged into one generic description
388
+ .completion(m1, Set ((" xxxx" , Method , " (s: String): String" ),
389
+ (" xxxx" , Method , " (i: Int): Int" )))
373
390
}
374
391
375
392
@ Test def dontCompleteFromAmbiguousImportsForEqualNestingLevels : Unit = {
@@ -482,7 +499,8 @@ class CompletionTest {
482
499
| def bar(i: Int) = 0
483
500
|}
484
501
|import Foo.b $m1""" .withSource
485
- .completion(m1, Set ((" bar" , Class , " class and method bar" )))
502
+ .completion(m1, Set ((" bar" , Class , " Foo.bar" ),
503
+ (" bar" , Method , " (i: Int): Int" )))
486
504
}
487
505
488
506
@ Test def completionTypeAndLazyValue : Unit = {
@@ -491,7 +509,8 @@ class CompletionTest {
491
509
| lazy val bar = 3
492
510
|}
493
511
|import Foo.b $m1""" .withSource
494
- .completion(m1, Set ((" bar" , Field , " type and lazy value bar" )))
512
+ .completion(m1, Set ((" bar" , Field , " Foo.bar" ),
513
+ (" bar" , Field , " Int" )))
495
514
}
496
515
497
516
@ Test def keepTrackOfTermsAndTypesSeparately : Unit = {
@@ -506,7 +525,8 @@ class CompletionTest {
506
525
| type ZZZZ = YY $m2
507
526
|} """ .withSource
508
527
.completion(m1, Set ((" YYYY" , Field , " Int$" )))
509
- .completion(m2, Set ((" YYYY" , Field , " type and value YYYY" )))
528
+ .completion(m2, Set ((" YYYY" , Field , " XXXX.YYYY" ),
529
+ (" YYYY" , Field , " Int$" )))
510
530
}
511
531
512
532
@ Test def completeRespectingAccessModifiers : Unit = {
@@ -535,6 +555,29 @@ class CompletionTest {
535
555
.completion(m1, Set ((" xxxx" , Method , " (a: Int): Int" )))
536
556
}
537
557
558
+ @ Test def completePrimaryConstructorParameter : Unit = {
559
+ code """ class Foo(abc: Int) {
560
+ | ab $m1
561
+ | def method1: Int = {
562
+ | ab $m2
563
+ | 42
564
+ | }
565
+ | def method2: Int = {
566
+ | val smth = ab $m3
567
+ | 42
568
+ | }
569
+ |} """ .withSource
570
+ .completion(m1, Set ((" abc" , Field , " Int" )))
571
+ .completion(m2, Set ((" abc" , Field , " Int" )))
572
+ .completion(m2, Set ((" abc" , Field , " Int" )))
573
+ }
574
+
575
+ @ Test def completeExtensionReceiver : Unit = {
576
+ code """ extension (string: String) def xxxx = str $m1"""
577
+ .withSource
578
+ .completion(m1, Set ((" string" , Field , " String" )))
579
+ }
580
+
538
581
@ Test def completeExtensionMethodWithoutParameter : Unit = {
539
582
code """ object Foo
540
583
|extension (foo: Foo.type) def xxxx = 1
0 commit comments