Skip to content

Commit

Permalink
expose low-level API for scalafix repo dogfooding
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Jun 11, 2023
1 parent 5c08e52 commit 0c2767a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,25 @@ object ScalafixInterface {
)
)
})

def fromClassloader(
classloader: ClassLoader,
logger: Logger = ConsoleLogger(System.out)
): () => ScalafixInterface =
new LazyValue({ () =>
val callback = new ScalafixLogger(logger)
val scalafixArguments = ScalafixAPI
.classloadInstance(classloader)
.newArguments()
.withMainCallback(callback)
val printStream =
new PrintStream(
LoggingOutputStream(
logger,
Level.Info
)
)
new ScalafixInterface(scalafixArguments, Nil)
.withArgs(Arg.PrintStream(printStream))
})
}

0 comments on commit 0c2767a

Please sign in to comment.