Skip to content

Instantly share code, notes, and snippets.

import sjsonnew.BasicJsonProtocol._
import sbinary.DefaultProtocol._
val classFileCount = TaskKey[Int]("classFileCount")
Seq(Compile, Test).map { scope =>
scope / classFileCount := {
val s = streams.value.log
val dir = (scope / classDirectory).value
val current = (dir ** "*.class").get().size
package fix
import scala.meta._
import scalafix.v1._
object WasCalledTimes {
val Times: PartialFunction[Tree, Tree] = {
case Term.Select(
n,
Term.Name("times")
  1. kantan.codecs.strings.URLCodecTests 10162
  2. kantan.csv.URLCodecTests 10139
  3. kantan.codecs.strings.URLCodecTests 10017
  4. kantan.csv.URLCodecTests 9208
  5. kantan.csv.cats.RowCodecInstancesTests 5479
  6. kantan.csv.scalaz.RowCodecInstancesTests 5238
  7. kantan.csv.cats.RowCodecInstancesTests 4815
  8. kantan.csv.scalaz.RowCodecInstancesTests 4471
  9. kantan.codecs.scalaz.DecoderTests 2469
  10. kantan.codecs.scalaz.DecoderTests 1562
import sbt._
import sbt.Keys._
import scalafix.sbt.ScalafixPlugin
import scalafix.sbt.ScalafixPlugin.autoImport.ScalafixConfig
/**
* [[https://xuwei-k.hatenablog.com/entry/2025/03/11/214521]]
*/
object MyScalafixPlugin extends AutoPlugin {
import scala.meta._
import scalafix.v1._
class ThenReturn extends SyntacticRule("ThenReturn") {
val exclude = Seq("")
override def fix(implicit doc: SyntacticDocument): Patch = {
doc.input match {
case f: Input.VirtualFile if exclude.exists(f.path.contains) =>
Patch.empty
case _ =>
import com.typesafe.sbt.packager.universal.UniversalPlugin.autoImport._
import com.typesafe.sbt.web.SbtWeb.autoImport._
import play.twirl.sbt.Import.TwirlKeys
import sbt.Keys._
import sbt._
import sbtprojectmatrix.ProjectMatrixPlugin
import sbtprojectmatrix.ProjectMatrixPlugin.autoImport.projectMatrixBaseDirectory
object PlayLayoutProjectMatrixPlugin extends AutoPlugin {
override def requires = play.sbt.PlayWeb && ProjectMatrixPlugin
$ scala -Xprint:typer -e "for { a <- Option(2) ; b <- Option(a) } yield b"
[[syntax trees at end of typer]] // scalacmd15102494186904250690.scala
package <empty> {
object Main extends scala.AnyRef {
def <init>(): Main.type = {
Main.super.<init>();
()
};
def main(args: Array[String]): Unit = {
final class $anon extends scala.AnyRef {
package example
import org.wartremover.WartTraverser
import org.wartremover.WartUniverse
object DisableDoobieReadInstance extends WartTraverser {
override def apply(u: WartUniverse): u.Traverser =
new u.Traverser(this) {
import q.reflect.*
override def traverseTree(tree: Tree)(owner: Symbol): Unit = {
import scala.quoted.*
object Foo {
inline def f[A](inline x: A): List[(String, String)] = ${ impl('x) }
def impl[A](using q: Quotes)(x: Expr[A]): Expr[List[(String, String)]] = {
import q.reflect.*
x.asTerm match {
case Inlined(_, _, Block(_, Match(_, i :: Nil))) =>
i match {
TaskKey[Seq[String]]("allMainClassNames") := Def.taskDyn {
buildStructure.value.units
.apply(Keys.thisProjectRef.value.build)
.defined
.values
.toList
.map { p =>
LocalProject(p.id) / Compile / discoveredMainClasses
}
.join