From aa58829c514f0f5adb5c4396d97ff62bfaea2f33 Mon Sep 17 00:00:00 2001 From: Roman Janusz Date: Sun, 19 Mar 2023 17:03:30 +0100 Subject: [PATCH] introduced EnclosingValName util --- src/main/scala/com/github/ghik/sbt/nosbt/Macros.scala | 4 ++++ .../com/github/ghik/sbt/nosbt/util/EnclosingValName.scala | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 src/main/scala/com/github/ghik/sbt/nosbt/util/EnclosingValName.scala diff --git a/src/main/scala/com/github/ghik/sbt/nosbt/Macros.scala b/src/main/scala/com/github/ghik/sbt/nosbt/Macros.scala index 59fc805..89e5212 100644 --- a/src/main/scala/com/github/ghik/sbt/nosbt/Macros.scala +++ b/src/main/scala/com/github/ghik/sbt/nosbt/Macros.scala @@ -6,6 +6,7 @@ class Macros(val c: blackbox.Context) { import c.universe.* private def ScalaPkg = q"_root_.scala" + private def NosbtPkg = q"_root_.com.github.ghik.sbt.nosbt" private def classBeingConstructed: ClassSymbol = { val ownerConstr = c.internal.enclosingOwner @@ -58,4 +59,7 @@ class Macros(val c: blackbox.Context) { def mkCrossSubProjectImpl(platforms: c.Tree*): Tree = q"${c.prefix}.mkCrossSubProject($enclosingValName)(..$platforms)" + + def enclosingValNameImpl: Tree = + q"$NosbtPkg.util.EnclosingValName($enclosingValName)" } diff --git a/src/main/scala/com/github/ghik/sbt/nosbt/util/EnclosingValName.scala b/src/main/scala/com/github/ghik/sbt/nosbt/util/EnclosingValName.scala new file mode 100644 index 0000000..f6566a2 --- /dev/null +++ b/src/main/scala/com/github/ghik/sbt/nosbt/util/EnclosingValName.scala @@ -0,0 +1,7 @@ +package com.github.ghik.sbt.nosbt +package util + +final case class EnclosingValName(name: String) +object EnclosingValName { + implicit def materialize: EnclosingValName = macro Macros.enclosingValNameImpl +}