![JAR search and dependency download from the Maven repository](/logo.png)
com.lucidchart.scalafmt.impl.Scalafmtter.scala Maven / Gradle / Ivy
The newest version!
package com.lucidchart.scalafmt.impl
import com.lucidchart.scalafmt.api
import com.lucidchart.scalafmt.api.Dialect
import java.nio.file.Path
import java.util.function
import org.scalafmt
import org.scalafmt.config.ScalafmtConfig
import scala.meta.dialects
class Scalafmtter(config: ScalafmtConfig) extends api.Scalafmtter {
self =>
def formatter(dialect: Dialect) = new function.Function[String, String] {
private[this] val config = dialect match {
case Dialect.SBT => self.config.copy(runner = self.config.runner.copy(dialect = dialects.Sbt0137))
case Dialect.SCALA => self.config
}
def apply(code: String) = scalafmt.Scalafmt.format(code, config).get
}
def includeFile(file: Path) = config.project.matcher.matches(file.toString)
// Otherwise, this cache hangs on to a lot
override protected def finalize() = try ScalametaUtil.clearCache() finally super.finalize()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy