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

dotty.tools.scaladoc.snippets.SnippetCompilationResult.scala Maven / Gradle / Ivy

There is a newer version: 3.6.3-RC1-bin-20241114-6a7d5d3-NIGHTLY
Show newest version
package dotty.tools.scaladoc
package snippets

import dotty.tools.io.{ AbstractFile }
import dotty.tools.dotc.util.{ SourcePosition, SrcPos }

case class Position(srcPos: SourcePosition, relativeLine: Int)

case class SnippetCompilerMessage(position: Option[Position], message: String, level: MessageLevel)

case class SnippetCompilationResult(
  wrappedSnippet: WrappedSnippet,
  isSuccessful: Boolean,
  result: Option[AbstractFile],
  messages: Seq[SnippetCompilerMessage]
):
  def reportMessages()(using CompilerContext) = messages.foreach {
    case SnippetCompilerMessage(posOpt, msg, level) =>
      val pos: SrcPos = posOpt.fold(dotty.tools.dotc.util.NoSourcePosition)(_.srcPos)
      level match {
        case MessageLevel.Info => report.log(msg, pos)
        case MessageLevel.Warning => report.warning(msg, pos)
        case MessageLevel.Error => report.error(msg, pos)
        case MessageLevel.Debug => report.log(msg, pos)
      }
  }

enum MessageLevel(val text: String):
  case Info extends MessageLevel("Info")
  case Warning extends MessageLevel("Warning")
  case Error extends MessageLevel("Error")
  case Debug extends MessageLevel("Debug")





© 2015 - 2024 Weber Informatics LLC | Privacy Policy