From 34b11a02a985696578976b175ca644f5a4a8aca7 Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Wed, 6 Dec 2023 17:55:26 +0100 Subject: [PATCH] improvement: base64-encode bloop error ids --- .../scala/meta/internal/builds/BSPErrorHandler.scala | 9 ++++----- .../scala/scala/meta/internal/metals/ReportContext.scala | 2 +- tests/unit/src/test/scala/tests/ReportsSuite.scala | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/builds/BSPErrorHandler.scala b/metals/src/main/scala/scala/meta/internal/builds/BSPErrorHandler.scala index 546262bdd02..d968ecc8663 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/BSPErrorHandler.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/BSPErrorHandler.scala @@ -9,6 +9,8 @@ import scala.meta.internal.metals.Report import scala.meta.internal.metals.ReportContext import scala.meta.internal.metals.Tables +import com.google.common.io.BaseEncoding + class BspErrorHandler( currentSession: () => Option[BspSession], tables: Tables, @@ -30,11 +32,8 @@ class BspErrorHandler( protected def logError(message: String): Unit = scribe.error(message) private def createReport(message: String) = { - val id = MessageDigest - .getInstance("MD5") - .digest(message.getBytes) - .map(_.toChar) - .mkString + val digest = MessageDigest.getInstance("MD5").digest(message.getBytes) + val id = BaseEncoding.base64().encode(digest) val sanitized = reportContext.bloop.sanitize(message) reportContext.bloop.create( Report( diff --git a/mtags-shared/src/main/scala/scala/meta/internal/metals/ReportContext.scala b/mtags-shared/src/main/scala/scala/meta/internal/metals/ReportContext.scala index e1e6370060f..cba45550521 100644 --- a/mtags-shared/src/main/scala/scala/meta/internal/metals/ReportContext.scala +++ b/mtags-shared/src/main/scala/scala/meta/internal/metals/ReportContext.scala @@ -273,7 +273,7 @@ object Report { def apply(name: String, text: String, error: Throwable): Report = Report(name, text, error, path = None) - val idPrefix = "id: " + val idPrefix = "error id: " val summaryTitle = "#### Short summary: " } diff --git a/tests/unit/src/test/scala/tests/ReportsSuite.scala b/tests/unit/src/test/scala/tests/ReportsSuite.scala index 7450e47aace..0a600ed8066 100644 --- a/tests/unit/src/test/scala/tests/ReportsSuite.scala +++ b/tests/unit/src/test/scala/tests/ReportsSuite.scala @@ -123,7 +123,7 @@ class ReportsSuite extends BaseSuite { val obtained = new String(Files.readAllBytes(path.get), StandardCharsets.UTF_8) assertNoDiff( - s"""|id: $testId + s"""|error id: $testId |${exampleText(StdReportContext.WORKSPACE_STR)} |#### Short summary: |