@@ -3,6 +3,7 @@ package dotty.tools.languageserver
33import org .junit .Test
44
55import dotty .tools .languageserver .util .Code ._
6+ import dotty .tools .languageserver .util .embedded .CodeMarker
67
78class DefinitionTest {
89
@@ -43,4 +44,85 @@ class DefinitionTest {
4344 ).definition(m3 to m4, List (m1 to m2))
4445 }
4546
47+ @ Test def goToDefNamedArg : Unit = {
48+ code """ object Foo {
49+ def foo( ${m1}x ${m2}: Int) = ${m3}x ${m4}
50+ foo( ${m5}x ${m6} = 2)
51+ } """ .withSource
52+ .definition(m1 to m2, List (m1 to m2))
53+ .definition(m3 to m4, List (m1 to m2))
54+ .definition(m5 to m6, List (m1 to m2))
55+ }
56+
57+ @ Test def goToDefNamedArgOverload : Unit = {
58+ val m9 = new CodeMarker (" m9" )
59+ val m10 = new CodeMarker (" m10" )
60+ val m11 = new CodeMarker (" m11" )
61+ val m12 = new CodeMarker (" m12" )
62+ val m13 = new CodeMarker (" m13" )
63+ val m14 = new CodeMarker (" m14" )
64+
65+ code """ object Foo {
66+ def foo( ${m1}x ${m2}: String): String = ${m3}x ${m4}
67+ def foo( ${m5}x ${m6}: Int): String = foo( ${m7}x ${m8} = ${m9}x ${m10}.toString)
68+ foo( ${m11}x ${m12} = "a")
69+ foo( ${m13}x ${m14} = 2)
70+ } """ .withSource
71+ .definition(m1 to m2, List (m1 to m2))
72+ .definition(m3 to m4, List (m1 to m2))
73+ .definition(m5 to m6, List (m5 to m6))
74+ .definition(m7 to m8, List (m1 to m2))
75+ .definition(m9 to m10, List (m5 to m6))
76+ .definition(m11 to m12, List (m1 to m2))
77+ .definition(m13 to m14, List (m5 to m6))
78+ }
79+
80+ @ Test def goToConstructorNamedArg : Unit = {
81+ withSources(
82+ code """ class Foo( ${m1}x ${m2}: Int) """ ,
83+ code """ class Bar extends Foo( ${m3}x ${m4} = 5) """ ,
84+ code """ object Buzz { new Foo( ${m5}x ${m6} = 2) } """
85+ ) .definition(m1 to m2, List (m1 to m2))
86+ .definition(m3 to m4, List (m1 to m2))
87+ .definition(m5 to m6, List (m1 to m2))
88+ }
89+
90+ @ Test def goToConstructorNamedArgOverload : Unit = {
91+ val m9 = new CodeMarker (" m9" )
92+ val m10 = new CodeMarker (" m10" )
93+ val m11 = new CodeMarker (" m11" )
94+ val m12 = new CodeMarker (" m12" )
95+
96+ withSources(
97+ code """ class Foo( ${m1}x ${m2}: String) {
98+ def this( ${m3}x ${m4}: Int) = this( ${m5}x ${m6} = ${m7}x ${m8}.toString)
99+ } """ ,
100+ code """ object Bar {
101+ new Foo( ${m9}x ${m10} = 1)
102+ new Foo( ${m11}x ${m12} = "a")
103+ } """
104+ ) .definition(m1 to m2, List (m1 to m2))
105+ .definition(m3 to m4, List (m3 to m4))
106+ .definition(m5 to m6, List (m1 to m2))
107+ .definition(m7 to m8, List (m3 to m4))
108+ .definition(m9 to m10, List (m3 to m4))
109+ .definition(m11 to m12, List (m1 to m2))
110+ }
111+
112+ @ Test def goToParamCopyMethod : Unit = {
113+ val m9 = new CodeMarker (" m9" )
114+ val m10 = new CodeMarker (" m10" )
115+
116+ withSources(
117+ code """ case class Foo( ${m1}x ${m2}: Int, ${m3}y ${m4}: String) """ ,
118+ code """ object Bar {
119+ Foo(0, "a").copy( ${m5}x ${m6} = 1, ${m7}y ${m8} = "b")
120+ Foo(2, "c").copy( ${m9}y ${m10} = "d") """
121+ ) .definition(m1 to m2, List (m1 to m2))
122+ .definition(m3 to m4, List (m3 to m4))
123+ .definition(m5 to m6, List (m1 to m2))
124+ .definition(m7 to m8, List (m3 to m4))
125+ .definition(m9 to m10, List (m3 to m4))
126+ }
127+
46128}
0 commit comments