All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalafmt.dynamic.ConsoleScalafmtReporter.scala Maven / Gradle / Ivy

The newest version!
package org.scalafmt.dynamic

import java.io.{PrintStream, PrintWriter}
import java.nio.file.Path

import org.scalafmt.dynamic.exceptions.ScalafmtException
import org.scalafmt.interfaces.ScalafmtReporter
import java.io.OutputStreamWriter

object ConsoleScalafmtReporter extends ConsoleScalafmtReporter(System.err)

class ConsoleScalafmtReporter(out: PrintStream) extends ScalafmtReporter {
  override def error(file: Path, e: Throwable): Unit = {
    out.print(s"error: $file: ")
    trimStacktrace(e)
    e.printStackTrace(out)
  }

  override def error(path: Path, message: String): Unit = {
    out.println(s"error: $path: $message")
  }

  override def error(file: Path, message: String, e: Throwable): Unit = {
    error(file, ScalafmtException(message, e))
  }

  override def excluded(filename: Path): Unit = {
    out.println(s"file excluded: $filename")
  }

  override def parsedConfig(config: Path, scalafmtVersion: String): Unit = {
    out.println(s"parsed config (v$scalafmtVersion): $config")
  }

  override def downloadWriter(): PrintWriter = new PrintWriter(out)

  override def downloadOutputStreamWriter(): OutputStreamWriter =
    new OutputStreamWriter(out)

  protected def trimStacktrace(e: Throwable): Unit = ()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy