File tree Expand file tree Collapse file tree 2 files changed +110
-0
lines changed
main/kotlin/com/sourcegraph/semanticdb_kotlinc
test/kotlin/com/sourcegraph/semanticdb_kotlinc/test Expand file tree Collapse file tree 2 files changed +110
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,9 @@ class GlobalSymbolsCache(testing: Boolean = false) : Iterable<Symbol> {
93
93
if (symbol.fir.isLocalMember) return locals + symbol
94
94
95
95
val owner = getParentSymbol(symbol, locals)
96
+
97
+ if (owner.isLocal()) return locals + symbol
98
+
96
99
val semanticdbDescriptor = semanticdbDescriptor(symbol)
97
100
98
101
return Symbol .createGlobal(owner, semanticdbDescriptor)
Original file line number Diff line number Diff line change @@ -192,6 +192,113 @@ class AnalyzerTest {
192
192
}
193
193
}
194
194
195
+ @Test
196
+ fun `local classes` (@TempDir path : Path ) {
197
+ val document =
198
+ compileSemanticdb(
199
+ path,
200
+ """
201
+ package sample
202
+
203
+ fun foo() {
204
+ class LocalClass {
205
+ fun localClassMethod() {}
206
+ }
207
+ }
208
+ """ )
209
+
210
+ val occurrences =
211
+ arrayOf(
212
+ SymbolOccurrence {
213
+ role = Role .DEFINITION
214
+ symbol = " sample/foo()."
215
+ range {
216
+ startLine = 2
217
+ startCharacter = 4
218
+ endLine = 2
219
+ endCharacter = 7
220
+ }
221
+ },
222
+ // LocalClass
223
+ SymbolOccurrence {
224
+ role = Role .DEFINITION
225
+ symbol = " local0"
226
+ range {
227
+ startLine = 3
228
+ startCharacter = 8
229
+ endLine = 3
230
+ endCharacter = 18
231
+ }
232
+ },
233
+ // LocalClass constructor
234
+ SymbolOccurrence {
235
+ role = Role .DEFINITION
236
+ symbol = " local1"
237
+ range {
238
+ startLine = 3
239
+ startCharacter = 8
240
+ endLine = 3
241
+ endCharacter = 18
242
+ }
243
+ },
244
+ // localClassMethod
245
+ SymbolOccurrence {
246
+ role = Role .DEFINITION
247
+ symbol = " local2"
248
+ range {
249
+ startLine = 4
250
+ startCharacter = 8
251
+ endLine = 4
252
+ endCharacter = 24
253
+ }
254
+ },
255
+ )
256
+ assertSoftly(document.occurrencesList) {
257
+ withClue(this ) { occurrences.forEach(::shouldContain) }
258
+ }
259
+
260
+ val symbols =
261
+ arrayOf(
262
+ SymbolInformation {
263
+ symbol = " sample/foo()."
264
+ displayName = " foo"
265
+ language = KOTLIN
266
+ documentation {
267
+ message = " ```kotlin\n public final fun foo(): Unit\n ```"
268
+ format = Semanticdb .Documentation .Format .MARKDOWN
269
+ }
270
+ },
271
+ SymbolInformation {
272
+ symbol = " local0"
273
+ displayName = " LocalClass"
274
+ language = KOTLIN
275
+ documentation {
276
+ message = " ```kotlin\n local final class LocalClass : Any\n ```"
277
+ format = Semanticdb .Documentation .Format .MARKDOWN
278
+ }
279
+ },
280
+ SymbolInformation {
281
+ symbol = " local1"
282
+ displayName = " LocalClass"
283
+ language = KOTLIN
284
+ documentation {
285
+ message = " ```kotlin\n public constructor(): LocalClass\n ```"
286
+ format = Semanticdb .Documentation .Format .MARKDOWN
287
+ }
288
+ },
289
+ SymbolInformation {
290
+ symbol = " local2"
291
+ displayName = " localClassMethod"
292
+ language = KOTLIN
293
+ documentation {
294
+ message = " ```kotlin\n public final fun localClassMethod(): Unit\n ```"
295
+ format = Semanticdb .Documentation .Format .MARKDOWN
296
+ }
297
+ },
298
+ )
299
+ assertSoftly(document.symbolsList) { withClue(this ) { symbols.forEach(::shouldContain) } }
300
+ }
301
+
195
302
@Test
196
303
fun overrides (@TempDir path : Path ) {
197
304
val document =
You can’t perform that action at this time.
0 commit comments