Skip to content

Commit 52a0135

Browse files
committed
Use quotes alias
1 parent d6a585f commit 52a0135

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

sourcecode/src-3/sourcecode/Macros.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,25 @@ trait ArgsMacros {
6464
}
6565

6666
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))
6868
def isSyntheticName(name: String) = {
6969
name == "<init>" || (name.startsWith("<local ") && name.endsWith(">")) || name == "$anonfun" || name == "macro"
7070
}
71-
def getName(using Quotes)(s: qctx.reflect.Symbol) = {
71+
def getName(using Quotes)(s: quotes.reflect.Symbol) = {
7272
s.name.trim
7373
.stripSuffix("$") // meh
7474
}
7575
}
7676

7777
object Macros {
7878

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 = {
8080
var owner0 = owner
8181
while(skipIf(owner0)) owner0 = owner0.owner
8282
owner0
8383
}
8484

85-
def actualOwner(using Quotes)(owner: qctx.reflect.Symbol): qctx.reflect.Symbol =
85+
def actualOwner(using Quotes)(owner: quotes.reflect.Symbol): quotes.reflect.Symbol =
8686
findOwner(owner, owner0 => Util.isSynthetic(owner0) || Util.getName(owner0) == "ev")
8787

8888
/**
@@ -94,11 +94,11 @@ object Macros {
9494
* Where n is an ordinal. This method returns the first owner that is not
9595
* such a synthetic variable.
9696
*/
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"})
9999

100100
def nameImpl(using Quotes): Expr[Name] = {
101-
import qctx.reflect._
101+
import quotes.reflect._
102102
val owner = actualOwner(Symbol.spliceOwner)
103103
val simpleName = Util.getName(owner)
104104
'{Name(${Expr(simpleName)})}
@@ -112,14 +112,14 @@ object Macros {
112112
s
113113

114114
def nameMachineImpl(using Quotes): Expr[Name.Machine] = {
115-
import qctx.reflect._
115+
import quotes.reflect._
116116
val owner = nonMacroOwner(Symbol.spliceOwner)
117117
val simpleName = adjustName(Util.getName(owner))
118118
'{Name.Machine(${Expr(simpleName)})}
119119
}
120120

121121
def fullNameImpl(using Quotes): Expr[FullName] = {
122-
import qctx.reflect._
122+
import quotes.reflect._
123123
@annotation.tailrec def cleanChunk(chunk: String): String =
124124
val refined = chunk.stripPrefix("_$").stripSuffix("$")
125125
if chunk != refined then cleanChunk(refined) else refined
@@ -135,7 +135,7 @@ object Macros {
135135
}
136136

137137
def fullNameMachineImpl(using Quotes): Expr[FullName.Machine] = {
138-
import qctx.reflect._
138+
import quotes.reflect._
139139
val owner = nonMacroOwner(Symbol.spliceOwner)
140140
val fullName = owner.fullName.trim
141141
.split("\\.", -1)
@@ -146,23 +146,23 @@ object Macros {
146146
}
147147

148148
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
151151
'{sourcecode.File(${Expr(file)})}
152152
}
153153

154154
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
156156
'{sourcecode.FileName(${Expr(name)})}
157157
}
158158

159159
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
161161
'{sourcecode.Line(${Expr(line)})}
162162
}
163163

164164
def enclosingImpl(using Quotes): Expr[Enclosing] = {
165-
import qctx.reflect._
165+
import quotes.reflect._
166166
val path = enclosing(machine = false)(!Util.isSynthetic(_))
167167
'{Enclosing(${Expr(path)})}
168168
}
@@ -182,7 +182,7 @@ object Macros {
182182
}
183183

184184
def argsImpl(using qctx: Quotes): Expr[Args] = {
185-
import qctx.reflect._
185+
import quotes.reflect._
186186

187187
val param: List[List[ValDef]] = {
188188
def nearestEnclosingMethod(owner: Symbol): List[List[ValDef]] =
@@ -212,7 +212,7 @@ object Macros {
212212

213213

214214
def text[T: Type](v: Expr[T])(using Quotes): Expr[sourcecode.Text[T]] = {
215-
import qctx.reflect._
215+
import quotes.reflect._
216216
val txt = Term.of(v).pos.sourceCode
217217
'{sourcecode.Text[T]($v, ${Expr(txt)})}
218218
}
@@ -225,8 +225,8 @@ object Macros {
225225

226226
}
227227

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._
230230

231231
var current = Symbol.spliceOwner
232232
if (!machine)

0 commit comments

Comments
 (0)