@@ -1023,4 +1023,102 @@ class CompletionTest {
1023
1023
|class Foo[A]{ self: Futu ${m1} => } """ .withSource
1024
1024
.completion(m1, expected)
1025
1025
}
1026
+
1027
+ @ Test def backticks : Unit = {
1028
+ val expected = Set (
1029
+ (" getClass" , Method , " [X0 >: Foo.Bar.type](): Class[? <: X0]" ),
1030
+ (" ensuring" , Method , " (cond: Boolean): A" ),
1031
+ (" ##" , Method , " => Int" ),
1032
+ (" nn" , Method , " => Foo.Bar.type" ),
1033
+ (" ==" , Method , " (x$0: Any): Boolean" ),
1034
+ (" ensuring" , Method , " (cond: Boolean, msg: => Any): A" ),
1035
+ (" ne" , Method , " (x$0: Object): Boolean" ),
1036
+ (" valueOf" , Method , " ($name: String): Foo.Bar" ),
1037
+ (" equals" , Method , " (x$0: Any): Boolean" ),
1038
+ (" wait" , Method , " (x$0: Long): Unit" ),
1039
+ (" hashCode" , Method , " (): Int" ),
1040
+ (" notifyAll" , Method , " (): Unit" ),
1041
+ (" values" , Method , " => Array[Foo.Bar]" ),
1042
+ (" →" , Method , " [B](y: B): (A, B)" ),
1043
+ (" !=" , Method , " (x$0: Any): Boolean" ),
1044
+ (" fromOrdinal" , Method , " (ordinal: Int): Foo.Bar" ),
1045
+ (" asInstanceOf" , Method , " [X0] => X0" ),
1046
+ (" ->" , Method , " [B](y: B): (A, B)" ),
1047
+ (" wait" , Method , " (x$0: Long, x$1: Int): Unit" ),
1048
+ (" `back-tick`" , Field , " Foo.Bar" ),
1049
+ (" notify" , Method , " (): Unit" ),
1050
+ (" formatted" , Method , " (fmtstr: String): String" ),
1051
+ (" ensuring" , Method , " (cond: A => Boolean, msg: => Any): A" ),
1052
+ (" wait" , Method , " (): Unit" ),
1053
+ (" isInstanceOf" , Method , " [X0] => Boolean" ),
1054
+ (" `match`" , Field , " Foo.Bar" ),
1055
+ (" toString" , Method , " (): String" ),
1056
+ (" ensuring" , Method , " (cond: A => Boolean): A" ),
1057
+ (" eq" , Method , " (x$0: Object): Boolean" ),
1058
+ (" synchronized" , Method , " [X0](x$0: X0): X0" )
1059
+ )
1060
+ code """ object Foo:
1061
+ | enum Bar:
1062
+ | case `back-tick`
1063
+ | case `match`
1064
+ |
1065
+ | val x = Bar. ${m1}"""
1066
+ .withSource.completion(m1, expected)
1067
+ }
1068
+
1069
+ @ Test def backticksPrefix : Unit = {
1070
+ val expected = Set (
1071
+ (" `back-tick`" , Field , " Foo.Bar" ),
1072
+ )
1073
+ code """ object Foo:
1074
+ | enum Bar:
1075
+ | case `back-tick`
1076
+ | case `match`
1077
+ |
1078
+ | val x = Bar.`back ${m1}"""
1079
+ .withSource.completion(m1, expected)
1080
+ }
1081
+
1082
+ @ Test def backticksSpace : Unit = {
1083
+ val expected = Set (
1084
+ (" `has space`" , Field , " Foo.Bar" ),
1085
+ )
1086
+ code """ object Foo:
1087
+ | enum Bar:
1088
+ | case `has space`
1089
+ |
1090
+ | val x = Bar.`has s ${m1}"""
1091
+ .withSource.completion(m1, expected)
1092
+ }
1093
+
1094
+ @ Test def backticksCompleteBoth : Unit = {
1095
+ val expected = Set (
1096
+ (" formatted" , Method , " (fmtstr: String): String" ),
1097
+ (" `foo-bar`" , Field , " Int" ),
1098
+ (" foo" , Field , " Int" )
1099
+ )
1100
+ code """ object Foo:
1101
+ | object Bar:
1102
+ | val foo = 1
1103
+ | val `foo-bar` = 2
1104
+ | val `bar` = 3
1105
+ |
1106
+ | val x = Bar.fo ${m1}"""
1107
+ .withSource.completion(m1, expected)
1108
+ }
1109
+
1110
+ @ Test def backticksWhenNotNeeded : Unit = {
1111
+ val expected = Set (
1112
+ (" `formatted`" , Method , " (fmtstr: String): String" ),
1113
+ (" `foo-bar`" , Field , " Int" ),
1114
+ (" `foo`" , Field , " Int" )
1115
+ )
1116
+ code """ object Foo:
1117
+ | object Bar:
1118
+ | val foo = 1
1119
+ | val `foo-bar` = 2
1120
+ |
1121
+ | val x = Bar.`fo ${m1}"""
1122
+ .withSource.completion(m1, expected)
1123
+ }
1026
1124
}
0 commit comments