File tree 2 files changed +13
-2
lines changed
src/dotty/tools/languageserver
test/dotty/tools/languageserver
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -338,13 +338,17 @@ class DottyLanguageServer extends LanguageServer
338
338
implicit val ctx = driver.currentCtx
339
339
340
340
val pos = sourcePosition(driver, uri, params.getPosition)
341
- val tp = Interactive .enclosingType(driver.openedTrees(uri), pos)
341
+ val trees = driver.openedTrees(uri)
342
+ val tp = Interactive .enclosingType(trees, pos)
342
343
val tpw = tp.widenTermRefExpr
343
344
344
345
if (tpw == NoType ) new Hover
345
346
else {
347
+ import dotty .tools .dotc .core .Comments ._
348
+ val symbol = Interactive .enclosingSourceSymbol(trees, pos)
349
+ val doc = ctx.docCtx.flatMap(_.docstring(symbol)).map(_.raw + " / " ).getOrElse(" " )
346
350
val str = tpw.show.toString
347
- new Hover (List (JEither .forLeft(str)).asJava, null )
351
+ new Hover (List (JEither .forLeft(doc + str)).asJava, null )
348
352
}
349
353
}
350
354
Original file line number Diff line number Diff line change @@ -9,6 +9,13 @@ class HoverTest {
9
9
@ Test def hoverOnWhiteSpace0 : Unit =
10
10
code " $m1 $m2" .withSource.hover(m1 to m2, " " )
11
11
12
+ @ Test def hoverOnClassShowsDoc : Unit = {
13
+ code """ $m1 /** foo */ ${m2}class Foo $m3 $m4""" .withSource
14
+ .hover(m1 to m2, " " )
15
+ .hover(m2 to m3, " /** foo */ / Foo" )
16
+ .hover(m3 to m4, " " )
17
+ }
18
+
12
19
@ Test def hoverOnClass0 : Unit = {
13
20
code """ $m1 ${m2}class Foo $m3 $m4""" .withSource
14
21
.hover(m1 to m2, " " )
You can’t perform that action at this time.
0 commit comments