File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
src/dotty/tools/languageserver
test/dotty/tools/languageserver Expand file tree Collapse file tree 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
338338 implicit val ctx = driver.currentCtx
339339
340340 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)
342343 val tpw = tp.widenTermRefExpr
343344
344345 if (tpw == NoType ) new Hover
345346 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(" " )
346350 val str = tpw.show.toString
347- new Hover (List (JEither .forLeft(str)).asJava, null )
351+ new Hover (List (JEither .forLeft(doc + str)).asJava, null )
348352 }
349353 }
350354
Original file line number Diff line number Diff line change @@ -9,6 +9,13 @@ class HoverTest {
99 @ Test def hoverOnWhiteSpace0 : Unit =
1010 code " $m1 $m2" .withSource.hover(m1 to m2, " " )
1111
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+
1219 @ Test def hoverOnClass0 : Unit = {
1320 code """ $m1 ${m2}class Foo $m3 $m4""" .withSource
1421 .hover(m1 to m2, " " )
You can’t perform that action at this time.
0 commit comments