1
1
package org.javacs.kt
2
2
3
+ import org.eclipse.lsp4j.DocumentSymbol
3
4
import org.eclipse.lsp4j.DocumentSymbolParams
5
+ import org.eclipse.lsp4j.Position
6
+ import org.eclipse.lsp4j.Range
4
7
import org.eclipse.lsp4j.SymbolKind
5
8
import org.eclipse.lsp4j.TextDocumentIdentifier
6
9
import org.hamcrest.Matchers.hasItem
7
10
import org.hamcrest.Matchers.not
8
- import org.junit.Assert.assertThat
11
+ import org.junit.Assert.assertEquals
9
12
import org.junit.Before
10
13
import org.junit.Test
11
14
@@ -19,14 +22,14 @@ class DocumentSymbolsTest : LanguageServerTestFixture("symbols") {
19
22
@Test fun `find document symbols` () {
20
23
val fileId = TextDocumentIdentifier (uri(file).toString())
21
24
val found = languageServer.textDocumentService.documentSymbol(DocumentSymbolParams (fileId)).get()
22
- val byKind = found.groupBy({ it.left.kind }, { it.left.name })
23
- val all = found.map { it.left.name }.toList()
25
+ val expected = listOf (DocumentSymbol (" DocumentSymbols" , SymbolKind .Class , Range (Position (0 , 0 ), Position (8 , 1 )), Range (Position (0 , 14 ), Position (0 , 29 )), null , listOf (
26
+ DocumentSymbol (" DocumentSymbols" , SymbolKind .Constructor , Range (Position (0 , 29 ), Position (0 , 31 )), Range (Position (0 , 29 ), Position (0 , 31 )), null , listOf ()),
27
+ DocumentSymbol (" aProperty" , SymbolKind .Property , Range (Position (1 , 4 ), Position (1 , 21 )), Range (Position (1 , 8 ), Position (1 , 17 )), null , listOf ()),
28
+ DocumentSymbol (" aFunction" , SymbolKind .Function , Range (Position (3 , 4 ), Position (4 , 5 )), Range (Position (3 , 8 ), Position (3 , 17 )), null , listOf ()),
29
+ DocumentSymbol (" DocumentSymbols" , SymbolKind .Constructor , Range (Position (6 , 4 ), Position (7 , 5 )), Range (Position (6 , 4 ), Position (7 , 5 )), null , listOf ())
30
+ )))
31
+ val all = found.map { it.right }.toList()
24
32
25
- assertThat(byKind[SymbolKind .Class ], hasItem(" DocumentSymbols" ))
26
- assertThat(byKind[SymbolKind .Constructor ], hasItem(" DocumentSymbols" ))
27
- assertThat(byKind[SymbolKind .Property ], hasItem(" aProperty" ))
28
- assertThat(byKind[SymbolKind .Function ], hasItem(" aFunction" ))
29
- assertThat(all, not (hasItem(" aFunctionArg" )))
30
- assertThat(all, not (hasItem(" aConstructorArg" )))
33
+ assertEquals(all.toString(), expected, all)
31
34
}
32
35
}
0 commit comments