Skip to content

Commit

Permalink
Align the output of 'Implicit searches by type' with the current appr…
Browse files Browse the repository at this point in the history
…oach
  • Loading branch information
danicheg committed Feb 11, 2024
1 parent 706454a commit 848d42f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
package ch.epfl.scala

final case class ImplicitSearchDebugInfo private (firings: Int, sourceFiles: List[String]) {
override def toString: String =
s"""
|{
| "firings": $firings,
| "sourceFiles": [
| ${sourceFiles.mkString("", ",\n", "")}
| ]
|}""".stripMargin
}
final case class ImplicitSearchDebugInfo private (firings: Int, sourceFiles: List[String])

object ImplicitSearchDebugInfo {
def apply(firings: Int, sourceFiles: List[String]): Option[ImplicitSearchDebugInfo] =
Expand Down
27 changes: 14 additions & 13 deletions plugin/src/main/scala/ch/epfl/scala/ProfilingPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,25 @@ class ProfilingPlugin(val global: Global) extends Plugin { self =>
logger.info("Implicit searches by position", implicitSearchesPosition)

val sortedImplicitSearches =
implementation.implicitSearchesSourceFilesByType.toVector.flatMap {
case (tpe, sourceFiles) =>
val firings = implementation.implicitSearchesByType.getOrElse(tpe, 0)
val files = sourceFiles.toList.flatMap {
case f if f.length > 0 =>
List(f.path)
case _ =>
List.empty
}

ImplicitSearchDebugInfo(firings, files).map(tpe -> _)
}
implementation.implicitSearchesSourceFilesByType.toVector
.flatMap {
case (tpe, sourceFiles) =>
val firings = implementation.implicitSearchesByType.getOrElse(tpe, 0)
val files = sourceFiles.toList.flatMap {
case f if f.length > 0 =>
List(f.path)
case _ =>
List.empty
}

ImplicitSearchDebugInfo(firings, files).map(tpe -> _)
}
.sortBy(_._2.firings)
// Make sure to stringify types right after typer to avoid compiler crashes
val stringifiedSortedImplicitSearches =
global.exitingTyper(
sortedImplicitSearches
.map(kv => kv._1.toString() -> kv._2.toString())
.map(kv => kv._1.toString() -> kv._2)
)
logger.info("Implicit searches by type", toLinkedHashMap(stringifiedSortedImplicitSearches))
}
Expand Down

0 comments on commit 848d42f

Please sign in to comment.