-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
88 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.7.3 | ||
sbt.version=1.10.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,5 @@ object NoComma { | |
Select(reify(Vector).tree, TermName("apply")), | ||
items)) | ||
} | ||
*/ | ||
*/ | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package sbtnocomma | ||
|
||
import sbt.* | ||
import scala.quoted.Expr | ||
import scala.quoted.Quotes | ||
import scala.quoted.Varargs | ||
|
||
object NoComma { | ||
inline def nocomma(inline a: SettingsDefinition): Vector[Setting[?]] = | ||
${ nocommaImpl('a) } | ||
|
||
def nocommaImpl(a: Expr[SettingsDefinition])(using q: Quotes): Expr[Vector[Setting[?]]] = { | ||
import q.reflect.* | ||
a.asTerm match { | ||
case Inlined(_, _, t: Block) => | ||
val values = (t.statements :+ t.expr).map { | ||
case t: Term => | ||
t.asExpr match { | ||
case '{ $x: Seq[Setting[?]] } => | ||
'{ Def.SettingList($x) } | ||
case '{ $x: Setting[?] } => | ||
'{ Def.SettingList($x :: Nil) } | ||
case '{ $x: SettingsDefinition } => | ||
x | ||
case _ => | ||
report.errorAndAbort("unexpected") | ||
} | ||
case _ => | ||
report.errorAndAbort("unexpected") | ||
} | ||
'{ Vector[SettingsDefinition](${ Varargs(values) }*).flatMap(_.settings) } | ||
case other => | ||
report.errorAndAbort("unexpected") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package sbtnocomma | ||
|
||
import sbt.* | ||
|
||
object NoCommaPlugin extends AutoPlugin { | ||
override def trigger = allRequirements | ||
object autoImport { | ||
inline def nocomma(inline a: SettingsDefinition): Vector[Setting[?]] = | ||
${ NoComma.nocommaImpl('a) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters