@@ -19,7 +19,7 @@ import scala.io.Codec
19
19
import dotc ._
20
20
import ast .{Trees , tpd }
21
21
import core ._ , core .Decorators .{sourcePos => _ , _ }
22
- import Contexts ._ , Flags ._ , Names ._ , NameOps ._ , Symbols ._ , SymDenotations ._ , Trees ._ , Types ._
22
+ import Comments . Comment , Contexts ._ , Flags ._ , Names ._ , NameOps ._ , Symbols ._ , SymDenotations ._ , Trees ._ , Types ._
23
23
import classpath .ClassPathEntries
24
24
import reporting ._ , reporting .diagnostic .MessageContainer
25
25
import util ._
@@ -348,9 +348,9 @@ class DottyLanguageServer extends LanguageServer
348
348
else {
349
349
import dotty .tools .dotc .core .Comments ._
350
350
val symbol = Interactive .enclosingSourceSymbol(trees, pos)
351
- val doc = ctx.docCtx.flatMap(_.docstring(symbol)).map(_.raw + " / " ).getOrElse( " " )
352
- val str = tpw.show.toString
353
- new Hover (List (JEither .forLeft(doc + str )).asJava, null )
351
+ val docComment = ctx.docCtx.flatMap(_.docstring(symbol))
352
+ val markedString = docMarkedString(docComment, tpw.show.toString)
353
+ new Hover (List (JEither .forRight(markedString )).asJava, null )
354
354
}
355
355
}
356
356
@@ -467,6 +467,21 @@ object DottyLanguageServer {
467
467
item
468
468
}
469
469
470
+ private def docMarkedString (comment : Option [Comment ], info : String ): lsp4j.MarkedString = {
471
+
472
+ val formattedComment = comment.map { comment =>
473
+ s """ ```scala
474
+ | ${comment.raw}
475
+ |```
476
+ | """ .stripMargin
477
+ }.getOrElse(" " )
478
+
479
+ val markedString = new lsp4j.MarkedString ()
480
+ markedString.setValue(formattedComment + info)
481
+ markedString
482
+ }
483
+
484
+
470
485
/** Create an lsp4j.SymbolInfo from a Symbol and a SourcePosition */
471
486
def symbolInfo (sym : Symbol , pos : SourcePosition )(implicit ctx : Context ): lsp4j.SymbolInformation = {
472
487
def symbolKind (sym : Symbol )(implicit ctx : Context ): lsp4j.SymbolKind = {
0 commit comments