Skip to content

Commit 52e76f6

Browse files
committed
Add more tests for go to definition with imports
1 parent 3f84ea0 commit 52e76f6

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
@@ -137,4 +137,55 @@ class DefinitionTest {
137137
.definition(m5 to m6, List(m1 to m2))
138138
}
139139

140+
@Test def goToDefinitionRenamedImport: Unit = {
141+
withSources(
142+
code"""package a
143+
class ${m1}Foo${m2}""",
144+
code"""package b
145+
import a.{${m3}Foo${m4} => ${m5}Bar${m6}}
146+
class C extends ${m7}Bar${m8}"""
147+
).definition(m1 to m2, List(m1 to m2))
148+
.definition(m3 to m4, List(m1 to m2))
149+
.definition(m5 to m6, List(m1 to m2))
150+
.definition(m7 to m8, List(m1 to m2))
151+
}
152+
153+
@Test def goToDefinitionImportAlternatives: Unit = {
154+
withSources(
155+
code"""package a
156+
class ${m1}Foo${m2}
157+
object ${m3}Foo${m4}""",
158+
code"""package b
159+
import a.${m5}Foo${m6}
160+
class C extends ${m7}Foo${m8} {
161+
val bar = ${m9}Foo${m10}
162+
}"""
163+
).definition(m1 to m2, List(m1 to m2))
164+
.definition(m3 to m4, List(m3 to m4))
165+
.definition(m5 to m6, List(m1 to m2, m3 to m4))
166+
.definition(m7 to m8, List(m1 to m2))
167+
.definition(m9 to m10, List(m3 to m4))
168+
}
169+
170+
@Test def goToDefinitionImportAlternativesWithRename: Unit = {
171+
val m11 = new util.embedded.CodeMarker("m11")
172+
val m12 = new util.embedded.CodeMarker("m12")
173+
174+
withSources(
175+
code"""package a
176+
class ${m1}Foo${m2}
177+
object ${m3}Foo${m4}""",
178+
code"""package b
179+
import a.{${m5}Foo${m6} => ${m7}Bar${m8}}
180+
class C extends ${m9}Bar${m10} {
181+
val buzz = ${m11}Bar${m12}
182+
}"""
183+
).definition(m1 to m2, List(m1 to m2))
184+
.definition(m3 to m4, List(m3 to m4))
185+
.definition(m5 to m6, List(m1 to m2, m3 to m4))
186+
.definition(m7 to m8, List(m1 to m2, m3 to m4))
187+
.definition(m9 to m10, List(m1 to m2))
188+
.definition(m11 to m12, List(m3 to m4))
189+
}
190+
140191
}

0 commit comments

Comments
 (0)