@@ -22,6 +22,7 @@ import core._, core.Decorators.{sourcePos => _, _}
22
22
import Comments ._ , Contexts ._ , Flags ._ , Names ._ , NameOps ._ , Symbols ._ , SymDenotations ._ , Trees ._ , Types ._
23
23
import classpath .ClassPathEntries
24
24
import reporting ._ , reporting .diagnostic .MessageContainer
25
+ import typer .Typer
25
26
import util ._
26
27
import interactive ._ , interactive .InteractiveDriver ._
27
28
import Interactive .Include
@@ -347,7 +348,16 @@ class DottyLanguageServer extends LanguageServer
347
348
if (tpw == NoType ) new Hover
348
349
else {
349
350
val symbol = Interactive .enclosingSourceSymbol(trees, pos)
350
- val docComment = ctx.docCtx.flatMap(_.docstring(symbol))
351
+ val docComment = ctx.docCtx.flatMap(_.docstring(symbol)).map {
352
+ case comment if ! comment.isExpanded =>
353
+ val typer = new Typer ()
354
+ val owner = symbol.owner
355
+ val cookingCtx = ctx.withOwner(owner)
356
+ typer.cookComment(symbol, owner)(cookingCtx)
357
+ ctx.docCtx.get.docstring(symbol).get
358
+ case comment =>
359
+ comment
360
+ }
351
361
val markedStrings = docMarkedStrings(docComment, tpw.show.toString)
352
362
new Hover (markedStrings.map(JEither .forRight(_)).asJava, null )
353
363
}
@@ -468,9 +478,11 @@ object DottyLanguageServer {
468
478
469
479
private def docMarkedStrings (comment : Option [Comment ], typeInfo : String ): List [lsp4j.MarkedString ] = {
470
480
471
- val docHover = comment.map { comment =>
472
- new lsp4j.MarkedString (" scala" , comment.raw)
473
- }
481
+ val docHover =
482
+ for {
483
+ cmt <- comment
484
+ body <- cmt.expandedBody
485
+ } yield new lsp4j.MarkedString (" scala" , body)
474
486
475
487
val typeInfoHover = new lsp4j.MarkedString ()
476
488
typeInfoHover.setValue(typeInfo)
0 commit comments