Skip to content
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 @@ -23,4 +23,12 @@ private[ducktape] object CodePrinter {
report.info(struct)
value
}

def codeAtSpan(span: Span)(using Quotes) =
span.toPosition.sourceCode.mkString

def codeAtSpanWithLocation(span: Span)(using Quotes) = {
val pos = span.toPosition
s"'${pos.sourceCode.mkString}' @ ${pos.sourceFile.name}:${pos.endLine + 1}:${pos.endColumn + 1}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.annotation.tailrec
import scala.quoted.*

private[ducktape] object PathSelector {
def unapply(using Quotes)(expr: quotes.reflect.Term): Some[Path] = {
def unapply(using outer: Quotes)(expr: quotes.reflect.Term): Some[Path] = {
@tailrec
def recurse(using Quotes)(acc: List[Path.Segment], term: quotes.reflect.Term): Path = {
import quotes.reflect.*
Expand Down Expand Up @@ -90,8 +90,10 @@ private[ducktape] object PathSelector {
Path(ident.tpe.asType, acc.toVector)

case other =>
Logger.debug(s"Matched an unexpected term")
report.errorAndAbort(s"Couldn't parse an unexpected config option: ${other.show(using Printer.TreeStructure)}")
Logger.debug(s"Matched an unexpected term: ${Printer.TreeStructure.show(other)}")
val pos = expr.pos
val code = pos.sourceCode.mkString
outer.reflect.report.errorAndAbort(s"Couldn't parse '$code' as a valid path selector", pos)
}
}

Expand Down