Skip to content

Commit e3d69c9

Browse files
committed
Add more tests for go to definition with imports
1 parent 0f88828 commit e3d69c9

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

language-server/test/dotty/tools/languageserver/DefinitionTest.scala

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,55 @@ class DefinitionTest {
5555
.definition(m5 to m6, List(m1 to m2))
5656
}
5757

58+
@Test def goToDefinitionRenamedImport: Unit = {
59+
withSources(
60+
code"""package a
61+
class ${m1}Foo${m2}""",
62+
code"""package b
63+
import a.{${m3}Foo${m4} => ${m5}Bar${m6}}
64+
class C extends ${m7}Bar${m8}"""
65+
).definition(m1 to m2, List(m1 to m2))
66+
.definition(m3 to m4, List(m1 to m2))
67+
.definition(m5 to m6, List(m1 to m2))
68+
.definition(m7 to m8, List(m1 to m2))
69+
}
70+
71+
@Test def goToDefinitionImportAlternatives: Unit = {
72+
withSources(
73+
code"""package a
74+
class ${m1}Foo${m2}
75+
object ${m3}Foo${m4}""",
76+
code"""package b
77+
import a.${m5}Foo${m6}
78+
class C extends ${m7}Foo${m8} {
79+
val bar = ${m9}Foo${m10}
80+
}"""
81+
).definition(m1 to m2, List(m1 to m2))
82+
.definition(m3 to m4, List(m3 to m4))
83+
.definition(m5 to m6, List(m1 to m2, m3 to m4))
84+
.definition(m7 to m8, List(m1 to m2))
85+
.definition(m9 to m10, List(m3 to m4))
86+
}
87+
88+
@Test def goToDefinitionImportAlternativesWithRename: Unit = {
89+
val m11 = new util.embedded.CodeMarker("m11")
90+
val m12 = new util.embedded.CodeMarker("m12")
91+
92+
withSources(
93+
code"""package a
94+
class ${m1}Foo${m2}
95+
object ${m3}Foo${m4}""",
96+
code"""package b
97+
import a.{${m5}Foo${m6} => ${m7}Bar${m8}}
98+
class C extends ${m9}Bar${m10} {
99+
val buzz = ${m11}Bar${m12}
100+
}"""
101+
).definition(m1 to m2, List(m1 to m2))
102+
.definition(m3 to m4, List(m3 to m4))
103+
.definition(m5 to m6, List(m1 to m2, m3 to m4))
104+
.definition(m7 to m8, List(m1 to m2, m3 to m4))
105+
.definition(m9 to m10, List(m1 to m2))
106+
.definition(m11 to m12, List(m3 to m4))
107+
}
108+
58109
}

0 commit comments

Comments
 (0)