@@ -107,13 +107,11 @@ object Frame:
107
107
private def frameImpl (internal : Boolean )(using Quotes ): Expr [String ] =
108
108
import quotes .reflect .*
109
109
110
- val pos = quotes.reflect.Position .ofMacroExpansion
111
- val (startLine, startColumn) = (pos.startLine, pos.startColumn)
112
- val endLine = pos.endLine
110
+ val pos = quotes.reflect.Position .ofMacroExpansion
111
+ val fileName = pos.sourceFile.name
113
112
114
113
if ! internal then
115
114
findEnclosing { sym =>
116
- val fileName = pos.sourceFile.name
117
115
sym.fullName.startsWith(" kyo" ) && ! allowKyoFileSuffixes.exists(fileName.endsWith)
118
116
}.foreach { sym =>
119
117
report.errorAndAbort(
@@ -129,19 +127,21 @@ object Frame:
129
127
}
130
128
end if
131
129
132
- val fileContent =
133
- pos.sourceFile.content
134
- .getOrElse(report.errorAndAbort(" Can't locate source code to generate frame." ))
130
+ val cls = findEnclosing(_.isClassDef).map(_.fullName).getOrElse(" ?" )
131
+ val method = if internal then " ?" else findEnclosing(_.isDefDef).map(_.name).getOrElse(" ?" )
135
132
136
- val markedContent = fileContent.take(pos.end) + " 📍" + fileContent.drop(pos.end)
137
- val lines = markedContent.linesIterator.toList
138
- val snippetLines = lines.slice(startLine - 1 , endLine + 2 ).filter(_.exists(_ != ' ' ))
139
- val toDrop = snippetLines.map(_.takeWhile(_ == ' ' ).size).minOption.getOrElse(0 )
140
- val snippet = if internal then " <internal>" else snippetLines.map(_.drop(toDrop)).mkString(" \n " )
141
- val cls = findEnclosing(_.isClassDef).map(render).getOrElse(" ?" )
142
- val method = findEnclosing(_.isDefDef).map(render).getOrElse(" ?" )
133
+ val snippet =
134
+ if internal then " <internal>"
135
+ else
136
+ val content = pos.sourceFile.content.getOrElse(
137
+ report.errorAndAbort(" Can't locate source code" )
138
+ )
139
+ val marked = content.take(pos.end) + " 📍" + content.drop(pos.end)
140
+ val lines = marked.linesIterator.slice(pos.startLine - 1 , pos.endLine + 2 ).filter(_.exists(_ != ' ' )).toSeq
141
+ val toDrop = lines.map(_.takeWhile(_ == ' ' ).length).min
142
+ lines.map(_.drop(toDrop)).mkString(" \n " )
143
143
144
- Expr (s " $version${pos.sourceFile.name} : ${startLine + 1 }: ${startColumn + 1 }| $cls| $method| $snippet" )
144
+ Expr (s " $version$fileName : ${pos. startLine + 1 }: ${pos. startColumn + 1 }| $cls| $method| $snippet" )
145
145
end frameImpl
146
146
147
147
private def render (using Quotes )(symbol : quotes.reflect.Symbol ): String =
0 commit comments