@@ -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 ._
@@ -346,9 +346,9 @@ class DottyLanguageServer extends LanguageServer
346
346
else {
347
347
import dotty .tools .dotc .core .Comments ._
348
348
val symbol = Interactive .enclosingSourceSymbol(trees, pos)
349
- val doc = ctx.docCtx.flatMap(_.docstring(symbol)).map(_.raw + " / " ).getOrElse( " " )
350
- val str = tpw.show.toString
351
- new Hover (List (JEither .forLeft(doc + str )).asJava, null )
349
+ val docComment = ctx.docCtx.flatMap(_.docstring(symbol))
350
+ val markedString = docMarkedString(docComment, tpw.show.toString)
351
+ new Hover (List (JEither .forRight(markedString )).asJava, null )
352
352
}
353
353
}
354
354
@@ -465,6 +465,21 @@ object DottyLanguageServer {
465
465
item
466
466
}
467
467
468
+ private def docMarkedString (comment : Option [Comment ], info : String ): lsp4j.MarkedString = {
469
+
470
+ val formattedComment = comment.map { comment =>
471
+ s """ ```scala
472
+ | ${comment.raw}
473
+ |```
474
+ | """ .stripMargin
475
+ }.getOrElse(" " )
476
+
477
+ val markedString = new lsp4j.MarkedString ()
478
+ markedString.setValue(formattedComment + info)
479
+ markedString
480
+ }
481
+
482
+
468
483
/** Create an lsp4j.SymbolInfo from a Symbol and a SourcePosition */
469
484
def symbolInfo (sym : Symbol , pos : SourcePosition )(implicit ctx : Context ): lsp4j.SymbolInformation = {
470
485
def symbolKind (sym : Symbol )(implicit ctx : Context ): lsp4j.SymbolKind = {
0 commit comments