From 3a2b7782f6c336dd2a18cd2369efd87767beb8e7 Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Tue, 3 Oct 2023 16:46:32 +0200 Subject: [PATCH] review changes --- .../internal/metals/doctor/DoctorResults.scala | 16 ++++++++++++++-- .../internal/mtags/CommonMtagsEnrichments.scala | 15 ++++++++++++--- .../scala/meta/internal/pc/HoverProvider.scala | 4 ++++ .../scala/meta/internal/pc/HoverProvider.scala | 14 ++++++++++++-- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/doctor/DoctorResults.scala b/metals/src/main/scala/scala/meta/internal/metals/doctor/DoctorResults.scala index 7667b1a5d84..75f8b130261 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/doctor/DoctorResults.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/doctor/DoctorResults.scala @@ -20,7 +20,7 @@ final case class DoctorResults( object DoctorResults { // Version of the Doctor json that is returned. - val version = 4 + val version = 5 } final case class DoctorFolderResults( @@ -41,6 +41,7 @@ final case class DoctorFolderResults( ) targets.foreach(targetList => json("targets") = targetList.map(_.toJson)) json("explanations") = explanations + json("errorReports") = errorReports.map(_.toJson) json } } @@ -168,4 +169,15 @@ final case class ErrorReportInfo( uri: String, buildTarget: Option[String], shortSummary: String, -) +) { + def toJson: Obj = { + val json = ujson.Obj( + "name" -> name, + "timestamp" -> timestamp, + "uri" -> uri, + "shortSummary" -> shortSummary, + ) + buildTarget.foreach(json("buildTarget") = _) + json + } +} diff --git a/mtags-shared/src/main/scala/scala/meta/internal/mtags/CommonMtagsEnrichments.scala b/mtags-shared/src/main/scala/scala/meta/internal/mtags/CommonMtagsEnrichments.scala index 36fda09576c..0c9c59486d2 100644 --- a/mtags-shared/src/main/scala/scala/meta/internal/mtags/CommonMtagsEnrichments.scala +++ b/mtags-shared/src/main/scala/scala/meta/internal/mtags/CommonMtagsEnrichments.scala @@ -358,16 +358,25 @@ trait CommonMtagsEnrichments { s"""|range: ${r.start} - ${r.end} |uri: ${r.uri()} |text: - |$withMarkers""".stripMargin + |```scala + |$withMarkers + |``` + |""".stripMargin case o: OffsetParams => s"""|offset: ${o.offset()} |uri: ${o.uri()} |text: - |${textWithPosMarker(o.offset(), o.text())}""".stripMargin + |```scala + |${textWithPosMarker(o.offset(), o.text())} + |``` + |""".stripMargin case v => s"""|uri: ${v.uri()} |text: - |${v.text()}""".stripMargin + |```scala + |${v.text()} + |``` + |""".stripMargin } } } diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/HoverProvider.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/HoverProvider.scala index 5d725c7a2d4..13f3aa056c1 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/HoverProvider.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/HoverProvider.scala @@ -63,10 +63,14 @@ class HoverProvider(val compiler: MetalsGlobal, params: OffsetParams)(implicit |tpe: ${tree.tpe} | |tree: + |```scala |$tree + |``` | |full tree: + |```scala |${unit.body} + |``` |""".stripMargin, s"empty hover in $fileName", s"$fileName::$posId" diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/HoverProvider.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/HoverProvider.scala index 02b79b756f1..5cb1457f8e1 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/HoverProvider.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/HoverProvider.scala @@ -66,9 +66,19 @@ object HoverProvider: |has error: ${tpw.isError} | |path: - |- ${path.map(_.toString()).mkString("\n- ")} + |${path + .map(tree => s"""|```scala + |$tree + |``` + |""".stripMargin) + .mkString("\n")} |trees: - |- ${trees.map(_.toString()).mkString("\n- ")} + |${trees + .map(tree => s"""|```scala + |$tree + |``` + |""".stripMargin) + .mkString("\n")} |""".stripMargin, s"empty hover in $uri", s"$uri::$posId",