forked from fwcd/kotlin-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocumentSymbolsTest.kt
32 lines (27 loc) · 1.18 KB
/
DocumentSymbolsTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package org.javacs.kt
import org.eclipse.lsp4j.DocumentSymbolParams
import org.eclipse.lsp4j.SymbolKind
import org.eclipse.lsp4j.TextDocumentIdentifier
import org.hamcrest.Matchers.hasItem
import org.hamcrest.Matchers.not
import org.junit.Assert.assertThat
import org.junit.Before
import org.junit.Test
class DocumentSymbolsTest: LanguageServerTestFixture("symbols") {
val file = "DocumentSymbols.kt"
@Before fun `open DocumentSymbols`() {
open(file)
}
@Test fun `find document symbols`() {
val fileId = TextDocumentIdentifier(uri(file).toString())
val found = languageServer.textDocumentService.documentSymbol(DocumentSymbolParams(fileId)).get()
val byKind = found.groupBy({ it.kind }, { it.name })
val all = found.map { it.name }.toList()
assertThat(byKind[SymbolKind.Class], hasItem("DocumentSymbols"))
assertThat(byKind[SymbolKind.Constructor], hasItem("DocumentSymbols"))
assertThat(byKind[SymbolKind.Property], hasItem("aProperty"))
assertThat(byKind[SymbolKind.Function], hasItem("aFunction"))
assertThat(all, not(hasItem("aFunctionArg")))
assertThat(all, not(hasItem("aConstructorArg")))
}
}