@@ -64,25 +64,25 @@ trait ArgsMacros {
64
64
}
65
65
66
66
object Util {
67
- def isSynthetic (using Quotes )(s : qctx .reflect.Symbol ) = isSyntheticName(getName(s))
67
+ def isSynthetic (using Quotes )(s : quotes .reflect.Symbol ) = isSyntheticName(getName(s))
68
68
def isSyntheticName (name : String ) = {
69
69
name == " <init>" || (name.startsWith(" <local " ) && name.endsWith(" >" )) || name == " $anonfun" || name == " macro"
70
70
}
71
- def getName (using Quotes )(s : qctx .reflect.Symbol ) = {
71
+ def getName (using Quotes )(s : quotes .reflect.Symbol ) = {
72
72
s.name.trim
73
73
.stripSuffix(" $" ) // meh
74
74
}
75
75
}
76
76
77
77
object Macros {
78
78
79
- def findOwner (using Quotes )(owner : qctx .reflect.Symbol , skipIf : qctx .reflect.Symbol => Boolean ): qctx .reflect.Symbol = {
79
+ def findOwner (using Quotes )(owner : quotes .reflect.Symbol , skipIf : quotes .reflect.Symbol => Boolean ): quotes .reflect.Symbol = {
80
80
var owner0 = owner
81
81
while (skipIf(owner0)) owner0 = owner0.owner
82
82
owner0
83
83
}
84
84
85
- def actualOwner (using Quotes )(owner : qctx .reflect.Symbol ): qctx .reflect.Symbol =
85
+ def actualOwner (using Quotes )(owner : quotes .reflect.Symbol ): quotes .reflect.Symbol =
86
86
findOwner(owner, owner0 => Util .isSynthetic(owner0) || Util .getName(owner0) == " ev" )
87
87
88
88
/**
@@ -94,11 +94,11 @@ object Macros {
94
94
* Where n is an ordinal. This method returns the first owner that is not
95
95
* such a synthetic variable.
96
96
*/
97
- def nonMacroOwner (using Quotes )(owner : qctx .reflect.Symbol ): qctx .reflect.Symbol =
98
- findOwner(owner, owner0 => { owner0.flags.is(qctx .reflect.Flags .Macro ) && Util .getName(owner0) == " macro" })
97
+ def nonMacroOwner (using Quotes )(owner : quotes .reflect.Symbol ): quotes .reflect.Symbol =
98
+ findOwner(owner, owner0 => { owner0.flags.is(quotes .reflect.Flags .Macro ) && Util .getName(owner0) == " macro" })
99
99
100
100
def nameImpl (using Quotes ): Expr [Name ] = {
101
- import qctx .reflect ._
101
+ import quotes .reflect ._
102
102
val owner = actualOwner(Symbol .spliceOwner)
103
103
val simpleName = Util .getName(owner)
104
104
' {Name ($ {Expr (simpleName)})}
@@ -112,14 +112,14 @@ object Macros {
112
112
s
113
113
114
114
def nameMachineImpl (using Quotes ): Expr [Name .Machine ] = {
115
- import qctx .reflect ._
115
+ import quotes .reflect ._
116
116
val owner = nonMacroOwner(Symbol .spliceOwner)
117
117
val simpleName = adjustName(Util .getName(owner))
118
118
' {Name .Machine ($ {Expr (simpleName)})}
119
119
}
120
120
121
121
def fullNameImpl (using Quotes ): Expr [FullName ] = {
122
- import qctx .reflect ._
122
+ import quotes .reflect ._
123
123
@ annotation.tailrec def cleanChunk (chunk : String ): String =
124
124
val refined = chunk.stripPrefix(" _$" ).stripSuffix(" $" )
125
125
if chunk != refined then cleanChunk(refined) else refined
@@ -135,7 +135,7 @@ object Macros {
135
135
}
136
136
137
137
def fullNameMachineImpl (using Quotes ): Expr [FullName .Machine ] = {
138
- import qctx .reflect ._
138
+ import quotes .reflect ._
139
139
val owner = nonMacroOwner(Symbol .spliceOwner)
140
140
val fullName = owner.fullName.trim
141
141
.split(" \\ ." , - 1 )
@@ -146,23 +146,23 @@ object Macros {
146
146
}
147
147
148
148
def fileImpl (using Quotes ): Expr [sourcecode.File ] = {
149
- import qctx .reflect ._
150
- val file = qctx .reflect.Position .ofMacroExpansion.sourceFile.jpath.toAbsolutePath.toString
149
+ import quotes .reflect ._
150
+ val file = quotes .reflect.Position .ofMacroExpansion.sourceFile.jpath.toAbsolutePath.toString
151
151
' {sourcecode.File ($ {Expr (file)})}
152
152
}
153
153
154
154
def fileNameImpl (using Quotes ): Expr [sourcecode.FileName ] = {
155
- val name = qctx .reflect.Position .ofMacroExpansion.sourceFile.jpath.getFileName.toString
155
+ val name = quotes .reflect.Position .ofMacroExpansion.sourceFile.jpath.getFileName.toString
156
156
' {sourcecode.FileName ($ {Expr (name)})}
157
157
}
158
158
159
159
def lineImpl (using Quotes ): Expr [sourcecode.Line ] = {
160
- val line = qctx .reflect.Position .ofMacroExpansion.startLine + 1
160
+ val line = quotes .reflect.Position .ofMacroExpansion.startLine + 1
161
161
' {sourcecode.Line ($ {Expr (line)})}
162
162
}
163
163
164
164
def enclosingImpl (using Quotes ): Expr [Enclosing ] = {
165
- import qctx .reflect ._
165
+ import quotes .reflect ._
166
166
val path = enclosing(machine = false )(! Util .isSynthetic(_))
167
167
' {Enclosing ($ {Expr (path)})}
168
168
}
@@ -182,7 +182,7 @@ object Macros {
182
182
}
183
183
184
184
def argsImpl (using qctx : Quotes ): Expr [Args ] = {
185
- import qctx .reflect ._
185
+ import quotes .reflect ._
186
186
187
187
val param : List [List [ValDef ]] = {
188
188
def nearestEnclosingMethod (owner : Symbol ): List [List [ValDef ]] =
@@ -212,7 +212,7 @@ object Macros {
212
212
213
213
214
214
def text [T : Type ](v : Expr [T ])(using Quotes ): Expr [sourcecode.Text [T ]] = {
215
- import qctx .reflect ._
215
+ import quotes .reflect ._
216
216
val txt = Term .of(v).pos.sourceCode
217
217
' {sourcecode.Text [T ]($v, $ {Expr (txt)})}
218
218
}
@@ -225,8 +225,8 @@ object Macros {
225
225
226
226
}
227
227
228
- def enclosing (using Quotes )(machine : Boolean )(filter : qctx .reflect.Symbol => Boolean ): String = {
229
- import qctx .reflect ._
228
+ def enclosing (using Quotes )(machine : Boolean )(filter : quotes .reflect.Symbol => Boolean ): String = {
229
+ import quotes .reflect ._
230
230
231
231
var current = Symbol .spliceOwner
232
232
if (! machine)
0 commit comments