forked from fwcd/kotlin-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHoverTest.kt
89 lines (67 loc) · 3.12 KB
/
HoverTest.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package org.javacs.kt
import org.hamcrest.Matchers.*
import org.junit.Assert.assertThat
import org.junit.Ignore
import org.junit.Test
class HoverLiteralsTest : SingleFileTestFixture("hover", "Literals.kt") {
@Test fun `string reference`() {
val hover = languageServer.textDocumentService.hover(hoverParams(file, 3, 19)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("val stringLiteral: String"))
}
}
class HoverFunctionReferenceTest : SingleFileTestFixture("hover", "FunctionReference.kt") {
@Test fun `function reference`() {
val hover = languageServer.textDocumentService.hover(hoverParams(file, 2, 45)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("fun isFoo(s: String): Boolean"))
}
}
class HoverObjectReferenceTest : SingleFileTestFixture("hover", "ObjectReference.kt") {
@Test fun `object reference`() {
val hover = languageServer.textDocumentService.hover(hoverParams(file, 2, 7)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("object AnObject"))
}
@Test fun `object reference with incomplete method`() {
val hover = languageServer.textDocumentService.hover(hoverParams(file, 6, 7)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("object AnObject"))
}
@Test fun `object reference with method`() {
val hover = languageServer.textDocumentService.hover(hoverParams(file, 10, 7)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("object AnObject"))
}
@Test fun `object method`() {
val hover = languageServer.textDocumentService.hover(hoverParams(file, 10, 15)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("fun doh(): Unit"))
}
}
@Ignore
class HoverRecoverTest : SingleFileTestFixture("hover", "Recover.kt") {
@Test fun `incrementally repair a single-expression function`() {
replace(file, 2, 9, "\"Foo\"", "intFunction()")
val hover = languageServer.textDocumentService.hover(hoverParams(file, 2, 11)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("fun intFunction(): Int"))
}
@Test fun `incrementally repair a block function`() {
replace(file, 5, 13, "\"Foo\"", "intFunction()")
val hover = languageServer.textDocumentService.hover(hoverParams(file, 5, 13)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("fun intFunction(): Int"))
}
}
class HoverAcrossFilesTest : LanguageServerTestFixture("hover") {
@Test fun `resolve across files`() {
val from = "ResolveFromFile.kt"
val to = "ResolveToFile.kt"
open(from)
open(to)
val hover = languageServer.textDocumentService.hover(hoverParams(from, 3, 26)).get()!!
val contents = hover.contents.right
assertThat(contents.value, containsString("fun target(): Unit"))
}
}