@@ -21,6 +21,7 @@ import kotlin.test.assertEquals
21
21
import org.intellij.lang.annotations.Language
22
22
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
23
23
import org.junit.jupiter.api.io.TempDir
24
+ import java.nio.file.Paths
24
25
25
26
@OptIn(ExperimentalCompilerApi ::class )
26
27
@ExperimentalContracts
@@ -39,7 +40,8 @@ class AnalyzerTest {
39
40
pluginOptions =
40
41
listOf (
41
42
PluginOption (" semanticdb-kotlinc" , " sourceroot" , path.toString()),
42
- PluginOption (" semanticdb-kotlinc" , " targetroot" , buildPath.toString()))
43
+ PluginOption (" semanticdb-kotlinc" , " targetroot" , buildPath.toString())
44
+ )
43
45
commandLineProcessors = listOf (AnalyzerCommandLineProcessor ())
44
46
workingDir = path.toFile()
45
47
}
@@ -59,7 +61,8 @@ class AnalyzerTest {
59
61
package sample
60
62
class Banana {
61
63
fun foo() { }
62
- }""" )
64
+ }"""
65
+ )
63
66
64
67
val occurrences =
65
68
arrayOf(
@@ -132,7 +135,8 @@ class AnalyzerTest {
132
135
133
136
import kotlin.Boolean
134
137
import kotlin.Int as KInt
135
- """ )
138
+ """
139
+ )
136
140
137
141
val occurrences =
138
142
arrayOf(
@@ -205,7 +209,8 @@ class AnalyzerTest {
205
209
fun localClassMethod() {}
206
210
}
207
211
}
208
- """ )
212
+ """
213
+ )
209
214
210
215
val occurrences =
211
216
arrayOf(
@@ -314,7 +319,8 @@ class AnalyzerTest {
314
319
class Class : Interface {
315
320
override fun foo() {}
316
321
}
317
- """ )
322
+ """
323
+ )
318
324
319
325
val occurrences =
320
326
arrayOf(
@@ -447,7 +453,8 @@ class AnalyzerTest {
447
453
override fun foo() {}
448
454
}
449
455
}
450
- """ )
456
+ """
457
+ )
451
458
452
459
val occurrences =
453
460
arrayOf(
@@ -630,7 +637,8 @@ class AnalyzerTest {
630
637
package sample
631
638
632
639
fun foo(arg: Int): Boolean = true
633
- """ )
640
+ """
641
+ )
634
642
635
643
val occurrences =
636
644
arrayOf(
@@ -693,7 +701,8 @@ class AnalyzerTest {
693
701
pluginOptions =
694
702
listOf (
695
703
PluginOption (" semanticdb-kotlinc" , " sourceroot" , path.toString()),
696
- PluginOption (" semanticdb-kotlinc" , " targetroot" , buildPath.toString()))
704
+ PluginOption (" semanticdb-kotlinc" , " targetroot" , buildPath.toString())
705
+ )
697
706
commandLineProcessors = listOf (AnalyzerCommandLineProcessor ())
698
707
workingDir = path.toFile()
699
708
}
@@ -1119,7 +1128,8 @@ class AnalyzerTest {
1119
1128
counter1() // => The value of the counter is 36
1120
1129
println(-counter2) // => Counter(value=-5)
1121
1130
}
1122
- """ )
1131
+ """
1132
+ )
1123
1133
1124
1134
val result =
1125
1135
KotlinCompilation ()
@@ -1130,7 +1140,8 @@ class AnalyzerTest {
1130
1140
pluginOptions =
1131
1141
listOf (
1132
1142
PluginOption (" semanticdb-kotlinc" , " sourceroot" , path.toString()),
1133
- PluginOption (" semanticdb-kotlinc" , " targetroot" , buildPath.toString()))
1143
+ PluginOption (" semanticdb-kotlinc" , " targetroot" , buildPath.toString())
1144
+ )
1134
1145
commandLineProcessors = listOf (AnalyzerCommandLineProcessor ())
1135
1146
workingDir = path.toFile()
1136
1147
}
@@ -1139,6 +1150,166 @@ class AnalyzerTest {
1139
1150
result.exitCode shouldBe KotlinCompilation .ExitCode .OK
1140
1151
}
1141
1152
1153
+
1154
+ @Test
1155
+ fun `compound package name semicolon test` (@TempDir path : Path ) {
1156
+ val document =
1157
+ compileSemanticdb(
1158
+ path, """
1159
+ package hello.sample;
1160
+ class Apple
1161
+ """ .trimIndent()
1162
+ )
1163
+
1164
+ val occurrences =
1165
+ arrayOf(
1166
+ SymbolOccurrence {
1167
+ role = Role .REFERENCE
1168
+ symbol = " hello/"
1169
+ range {
1170
+ startLine = 0
1171
+ startCharacter = 8
1172
+ endLine = 0
1173
+ endCharacter = 13
1174
+ }
1175
+ },
1176
+ SymbolOccurrence {
1177
+ role = Role .REFERENCE
1178
+ symbol = " hello/sample/"
1179
+ range {
1180
+ startLine = 0
1181
+ startCharacter = 14
1182
+ endLine = 0
1183
+ endCharacter = 20
1184
+ }
1185
+ },
1186
+ SymbolOccurrence {
1187
+ role = Role .DEFINITION
1188
+ symbol = " hello/sample/Apple#"
1189
+ range {
1190
+ startLine = 1
1191
+ startCharacter = 6
1192
+ endLine = 1
1193
+ endCharacter = 11
1194
+ }
1195
+ },
1196
+ SymbolOccurrence {
1197
+ role = Role .DEFINITION
1198
+ symbol = " hello/sample/Apple#`<init>`()."
1199
+ range {
1200
+ startLine = 1
1201
+ startCharacter = 6
1202
+ endLine = 1
1203
+ endCharacter = 11
1204
+ }
1205
+ },
1206
+ )
1207
+
1208
+ assertSoftly(document.occurrencesList) {
1209
+ withClue(document.occurrencesList) { occurrences.forEach(::shouldContain) }
1210
+ }
1211
+
1212
+ val symbols =
1213
+ arrayOf(
1214
+ SymbolInformation {
1215
+ symbol = " hello/sample/Apple#"
1216
+ language = KOTLIN
1217
+ displayName = " Apple"
1218
+ documentation =
1219
+ Documentation {
1220
+ format = Semanticdb .Documentation .Format .MARKDOWN
1221
+ message = " ```kotlin\n public final class Apple : Any\n ```"
1222
+ }
1223
+ })
1224
+
1225
+ assertSoftly(document.symbolsList) { withClue(this ) { symbols.forEach(::shouldContain) } }
1226
+ }
1227
+
1228
+
1229
+ @Test
1230
+ fun `simple package name semicolon test` (@TempDir path : Path ) {
1231
+ val document =
1232
+ compileSemanticdb(
1233
+ path,
1234
+ """
1235
+ package sample;
1236
+ class Banana {
1237
+ fun foo() { }
1238
+ }"""
1239
+ )
1240
+
1241
+ val occurrences =
1242
+ arrayOf(
1243
+ SymbolOccurrence {
1244
+ role = Role .REFERENCE
1245
+ symbol = " sample/"
1246
+ range {
1247
+ startLine = 0
1248
+ startCharacter = 8
1249
+ endLine = 0
1250
+ endCharacter = 14
1251
+ }
1252
+ },
1253
+ SymbolOccurrence {
1254
+ role = Role .DEFINITION
1255
+ symbol = " sample/Banana#"
1256
+ range {
1257
+ startLine = 1
1258
+ startCharacter = 6
1259
+ endLine = 1
1260
+ endCharacter = 12
1261
+ }
1262
+ },
1263
+ SymbolOccurrence {
1264
+ role = Role .DEFINITION
1265
+ symbol = " sample/Banana#foo()."
1266
+ range {
1267
+ startLine = 2
1268
+ startCharacter = 8
1269
+ endLine = 2
1270
+ endCharacter = 11
1271
+ }
1272
+ },
1273
+ SymbolOccurrence {
1274
+ role = Role .DEFINITION
1275
+ symbol = " sample/Banana#"
1276
+ range {
1277
+ startLine = 1
1278
+ startCharacter = 6
1279
+ endLine = 1
1280
+ endCharacter = 12
1281
+ }
1282
+ },
1283
+ )
1284
+ assertSoftly(document.occurrencesList) {
1285
+ withClue(this ) { occurrences.forEach(::shouldContain) }
1286
+ }
1287
+
1288
+ val symbols =
1289
+ arrayOf(
1290
+ SymbolInformation {
1291
+ symbol = " sample/Banana#"
1292
+ language = KOTLIN
1293
+ displayName = " Banana"
1294
+ documentation =
1295
+ Documentation {
1296
+ format = Semanticdb .Documentation .Format .MARKDOWN
1297
+ message = " ```kotlin\n public final class Banana : Any\n ```"
1298
+ }
1299
+ },
1300
+ SymbolInformation {
1301
+ symbol = " sample/Banana#foo()."
1302
+ language = KOTLIN
1303
+ displayName = " foo"
1304
+ documentation =
1305
+ Documentation {
1306
+ format = Semanticdb .Documentation .Format .MARKDOWN
1307
+ message = " ```kotlin\n public final fun foo(): Unit\n ```"
1308
+ }
1309
+ })
1310
+ assertSoftly(document.symbolsList) { withClue(this ) { symbols.forEach(::shouldContain) } }
1311
+ }
1312
+
1142
1313
@Test
1143
1314
fun documentation (@TempDir path : Path ) {
1144
1315
val document =
@@ -1157,7 +1328,8 @@ class AnalyzerTest {
1157
1328
*
1158
1329
**/
1159
1330
inline fun docstrings(msg: String): Int { return msg.length }
1160
- """ .trimIndent())
1331
+ """ .trimIndent()
1332
+ )
1161
1333
document.assertDocumentation(" sample/Docstrings#" , " Example class docstring" )
1162
1334
document.assertDocumentation(" sample/docstrings()." , " Example method docstring" )
1163
1335
}
0 commit comments