From b969ba3a528936fe1285f27e7b81bcd8acd6cda6 Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Fri, 27 Sep 2024 18:34:50 +0200 Subject: [PATCH] s/PcExplicitResultTypes/PresentationCompilerTypeInferrer/ --- ...la => PresentationCompilerTypeInferrer.scala} | 12 ++++++------ .../internal/rule/ExplicitResultTypes.scala | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) rename scalafix-rules/src/main/scala-3/pc/{PcExplicitResultTypes.scala => PresentationCompilerTypeInferrer.scala} (92%) diff --git a/scalafix-rules/src/main/scala-3/pc/PcExplicitResultTypes.scala b/scalafix-rules/src/main/scala-3/pc/PresentationCompilerTypeInferrer.scala similarity index 92% rename from scalafix-rules/src/main/scala-3/pc/PcExplicitResultTypes.scala rename to scalafix-rules/src/main/scala-3/pc/PresentationCompilerTypeInferrer.scala index 2c6721124..6326552fa 100644 --- a/scalafix-rules/src/main/scala-3/pc/PcExplicitResultTypes.scala +++ b/scalafix-rules/src/main/scala-3/pc/PresentationCompilerTypeInferrer.scala @@ -18,7 +18,7 @@ import scalafix.patch.Patch import scalafix.patch.Patch.empty import scalafix.v1.* -final class PcExplicitResultTypes private ( +final class PresentationCompilerTypeInferrer private ( pc: LazyValue[Option[PresentationCompiler]] ) { @@ -84,7 +84,7 @@ final class PcExplicitResultTypes private ( * Prepare the static presentation compiler already in the classpath or download * and classload one dynamically. */ -object PcExplicitResultTypes { +object PresentationCompilerTypeInferrer { private def configure( config: Configuration, pc: PresentationCompiler @@ -106,7 +106,7 @@ object PcExplicitResultTypes { ) } - def dynamic(config: Configuration): PcExplicitResultTypes = { + def dynamic(config: Configuration): PresentationCompilerTypeInferrer = { val newPc: LazyValue[Option[PresentationCompiler]] = LazyValue.from { () => Try( @@ -116,18 +116,18 @@ object PcExplicitResultTypes { ) ) } - new PcExplicitResultTypes(newPc) + new PresentationCompilerTypeInferrer(newPc) } def static( config: Configuration, pc: PresentationCompiler - ): PcExplicitResultTypes = { + ): PresentationCompilerTypeInferrer = { val newPc: LazyValue[Option[PresentationCompiler]] = LazyValue.from { () => Try(configure(config, pc)) } - new PcExplicitResultTypes(newPc) + new PresentationCompilerTypeInferrer(newPc) } } diff --git a/scalafix-rules/src/main/scala-3/scalafix/internal/rule/ExplicitResultTypes.scala b/scalafix-rules/src/main/scala-3/scalafix/internal/rule/ExplicitResultTypes.scala index fa1bcf6e0..97b7e8dde 100644 --- a/scalafix-rules/src/main/scala-3/scalafix/internal/rule/ExplicitResultTypes.scala +++ b/scalafix-rules/src/main/scala-3/scalafix/internal/rule/ExplicitResultTypes.scala @@ -4,13 +4,13 @@ import scala.meta.* import dotty.tools.pc.ScalaPresentationCompiler import metaconfig.Configured -import scalafix.internal.pc.PcExplicitResultTypes +import scalafix.internal.pc.PresentationCompilerTypeInferrer import scalafix.patch.Patch import scalafix.v1.* final class ExplicitResultTypes( val config: ExplicitResultTypesConfig, - fallback: Option[PcExplicitResultTypes] + pcTypeInferrer: Option[PresentationCompilerTypeInferrer] ) extends ExplicitResultTypesBase[Scala3Printer] { def this() = this(ExplicitResultTypesConfig.default, None) @@ -20,7 +20,7 @@ final class ExplicitResultTypes( } private def shutdownCompiler(): Unit = { - fallback.foreach(_.shutdownCompiler()) + pcTypeInferrer.foreach(_.shutdownCompiler()) } override def withConfiguration(config: Configuration): Configured[Rule] = { @@ -52,10 +52,10 @@ final class ExplicitResultTypes( stripPatchVersion(config.scalaVersion) == stripPatchVersion(compilerScalaVersion) ) - PcExplicitResultTypes + PresentationCompilerTypeInferrer .static(config, new ScalaPresentationCompiler()) else - PcExplicitResultTypes.dynamic(config) + PresentationCompilerTypeInferrer.dynamic(config) } ) ) @@ -64,7 +64,7 @@ final class ExplicitResultTypes( override def fix(implicit ctx: SemanticDocument): Patch = try { - implicit val printer = new Scala3Printer(fallback) + implicit val printer = new Scala3Printer(pcTypeInferrer) unsafeFix() } catch { case _: Throwable if !config.fatalWarnings => @@ -74,7 +74,7 @@ final class ExplicitResultTypes( } class Scala3Printer( - fallback: Option[PcExplicitResultTypes] + pcTypeInferrer: Option[PresentationCompilerTypeInferrer] ) extends Printer { def defnType( @@ -84,6 +84,6 @@ class Scala3Printer( )(implicit ctx: SemanticDocument ): Option[Patch] = { - fallback.flatMap(_.defnType(replace)) + pcTypeInferrer.flatMap(_.defnType(replace)) } }