Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of deprecated PlatformTokenizerCache #3593

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.scalafmt.{Formatted, Scalafmt, Versions}
import org.scalafmt.config.{ProjectFiles, ScalafmtConfig}
import org.scalafmt.CompatCollections.ParConverters._

import scala.meta.internal.tokenizers.PlatformTokenizerCache
import scala.meta.parsers.ParseException
import scala.meta.tokenizers.TokenizeException

Expand Down Expand Up @@ -36,7 +35,6 @@ object ScalafmtCoreRunner extends ScalafmtRunner {
val code = handleFile(inputMethod, options, scalafmtConf)
exitCode.getAndUpdate(ExitCode.merge(code, _))
if (options.check && !code.isOk) Breaks.break
PlatformTokenizerCache.megaCache.clear()
termDisplay.taskProgress(termDisplayMessage)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import org.scalafmt.interfaces.Scalafmt
import org.scalafmt.interfaces.ScalafmtSession
import org.scalafmt.sysops.FileOps

import scala.meta.internal.tokenizers.PlatformTokenizerCache
import util.control.Breaks._

object ScalafmtDynamicRunner extends ScalafmtRunner {
Expand Down Expand Up @@ -53,7 +52,6 @@ object ScalafmtDynamicRunner extends ScalafmtRunner {
reporter.error(e.file, e)
if (options.check) break
}
PlatformTokenizerCache.megaCache.clear()
termDisplay.taskProgress(termDisplayMessage)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ case class ScalafmtReflect(
case _ =>
formatMethod.invoke(null, code, config.target, emptyRange)
}
clearTokenizerCache()
if (version < ScalafmtVersion(2, 3, 0))
moduleInstance("scala.meta.internal.tokenizers.PlatformTokenizerCache$")
.invoke("megaCache")
.invoke("clear")
formattedGet.invoke(formatted).asInstanceOf[String]
}.recoverWith {
case ReflectionException(e)
Expand Down Expand Up @@ -168,13 +171,6 @@ case class ScalafmtReflect(
}
}

private def clearTokenizerCache(): Unit = {
val cache = moduleInstance(
"scala.meta.internal.tokenizers.PlatformTokenizerCache$"
)
cache.invoke("megaCache").invoke("clear")
}

private def moduleInstance(fqn: String): Object = {
val module = loadClass(fqn).getField("MODULE$")
module.setAccessible(true)
Expand Down
Loading