Merge pull request #3440 from dwijnand/scalafmt

Scalafmt 1.2.0
This commit is contained in:
Dale Wijnand 2017-08-14 17:48:28 +01:00 committed by GitHub
commit 037559c8d3
11 changed files with 56 additions and 14 deletions

View File

@ -33,7 +33,7 @@ def buildLevelSettings: Seq[Setting[_]] =
scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt"), "git@github.com:sbt/sbt.git")),
resolvers += Resolver.mavenLocal,
scalafmtOnCompile := true,
scalafmtVersion := "1.1.0",
scalafmtVersion := "1.2.0",
))
def commonSettings: Seq[Setting[_]] =

View File

@ -85,7 +85,10 @@ final class ContextUtil[C <: blackbox.Context](val ctx: C) {
* Collects all definitions in the tree for use in checkReferences.
* This excludes definitions in wrapped expressions because checkReferences won't allow nested dereferencing anyway.
*/
def collectDefs(tree: Tree, isWrapper: (String, Type, Tree) => Boolean): collection.Set[Symbol] = {
def collectDefs(
tree: Tree,
isWrapper: (String, Type, Tree) => Boolean
): collection.Set[Symbol] = {
val defs = new collection.mutable.HashSet[Symbol]
// adds the symbols for all non-Ident subtrees to `defs`.
val process = new Traverser {

View File

@ -246,7 +246,9 @@ object ParserInput {
}
}
private def wrapInputTask[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
private def wrapInputTask[T: c.WeakTypeTag](
c: blackbox.Context
)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[InputTask[T]](tree)
wrap[Task[T]](c)(inputParser(c)(e), pos)
}
@ -275,7 +277,9 @@ object ParserInput {
wrap[T](c)(c.universe.reify { Def.toSParser(e.splice) }, pos)
}
private def wrapInitParser[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
private def wrapInitParser[T: c.WeakTypeTag](
c: blackbox.Context
)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[Initialize[Parser[T]]](tree)
val es = c.universe.reify { Def.toISParser(e.splice) }
wrapInit[T](c)(es, pos)

View File

@ -300,7 +300,9 @@ object TaskMacro {
}
}
private[this] def transformMacroImpl(c: blackbox.Context)(init: c.Tree)(newName: String): c.Tree = {
private[this] def transformMacroImpl(c: blackbox.Context)(init: c.Tree)(
newName: String
): c.Tree = {
import c.universe._
val target =
c.macroApplication match {

View File

@ -412,7 +412,12 @@ object Defaults extends BuildCommon {
derive(scalaBinaryVersion := binaryScalaVersion(scalaVersion.value))
))
def makeCrossSources(scalaSrcDir: File, javaSrcDir: File, sv: String, cross: Boolean): Seq[File] = {
def makeCrossSources(
scalaSrcDir: File,
javaSrcDir: File,
sv: String,
cross: Boolean
): Seq[File] = {
if (cross)
Seq(scalaSrcDir.getParentFile / s"${scalaSrcDir.name}-$sv", scalaSrcDir, javaSrcDir)
else
@ -3151,7 +3156,9 @@ trait BuildCommon {
def classpath: Classpath = Attributed blankSeq s
}
def overrideConfigs(cs: Configuration*)(configurations: Seq[Configuration]): Seq[Configuration] = {
def overrideConfigs(cs: Configuration*)(
configurations: Seq[Configuration]
): Seq[Configuration] = {
val existingName = configurations.map(_.name).toSet
val newByName = cs.map(c => (c.name, c)).toMap
val overridden = configurations map { conf =>

View File

@ -44,7 +44,11 @@ object SessionVar {
task.copy(info = task.info.postTransform(g))
}
def resolveContext[T](key: ScopedKey[Task[T]], context: Scope, state: State): ScopedKey[Task[T]] = {
def resolveContext[T](
key: ScopedKey[Task[T]],
context: Scope,
state: State
): ScopedKey[Task[T]] = {
val subScope = Scope.replaceThis(context)(key.scope)
val scope = Project.structure(state).data.definingScope(subScope, key.key) getOrElse subScope
ScopedKey(scope, key.key)

View File

@ -617,7 +617,11 @@ private[sbt] object Load {
new LoadedBuild(loaded.root, units)
}
def resolveProjects(uri: URI, unit: PartBuildUnit, rootProject: URI => String): LoadedBuildUnit = {
def resolveProjects(
uri: URI,
unit: PartBuildUnit,
rootProject: URI => String
): LoadedBuildUnit = {
IO.assertAbsolute(uri)
val resolve = (_: Project).resolve(ref => Scope.resolveProjectRef(uri, rootProject, ref))
new LoadedBuildUnit(
@ -842,7 +846,11 @@ private[sbt] object Load {
// a. Apply all the project manipulations from .sbt files in order
// b. Deduce the auto plugins for the project
// c. Finalize a project with all its settings/configuration.
def finalizeProject(p: Project, files: Seq[File], expand: Boolean): (Project, Seq[Project]) = {
def finalizeProject(
p: Project,
files: Seq[File],
expand: Boolean
): (Project, Seq[Project]) = {
val configFiles = files flatMap { f =>
memoSettings.get(f)
}

View File

@ -264,7 +264,10 @@ private[sbt] case class SbtParser(file: File, lines: Seq[String]) extends Parsed
* @param imports - trees
* @return imports per line
*/
private def importsToLineRanges(modifiedContent: String, imports: Seq[Tree]): Seq[(String, Int)] = {
private def importsToLineRanges(
modifiedContent: String,
imports: Seq[Tree]
): Seq[(String, Int)] = {
val toLineRange = imports map convertImport(modifiedContent)
val groupedByLineNumber = toLineRange.groupBy { case (_, lineNumber) => lineNumber }
val mergedImports = groupedByLineNumber.map {

View File

@ -153,7 +153,11 @@ abstract class TestBuild {
val root = projects.head
val projectMap = mapBy(projects)(_.id)
}
final class Proj(val id: String, val delegates: Seq[ProjectRef], val configurations: Seq[Config]) {
final class Proj(
val id: String,
val delegates: Seq[ProjectRef],
val configurations: Seq[Config]
) {
override def toString =
"Project " + id + "\n Delegates:\n " + delegates.mkString("\n ") +
"\n Configurations:\n " + configurations.mkString("\n ")

View File

@ -65,7 +65,10 @@ final class ScriptedTests(resourceBaseDirectory: File,
}
}
private def createScriptedHandlers(testDir: File, buffered: Logger): Map[Char, StatementHandler] = {
private def createScriptedHandlers(
testDir: File,
buffered: Logger
): Map[Char, StatementHandler] = {
val fileHandler = new FileCommands(testDir)
val sbtHandler = new SbtHandler(testDir, launcher, buffered, launchOpts)
Map('$' -> fileHandler, '>' -> sbtHandler, '#' -> CommentHandler)

View File

@ -73,7 +73,11 @@ final class TestDefinition(val name: String,
override def hashCode: Int = (name.hashCode, TestFramework.hashCode(fingerprint)).hashCode
}
final class TestRunner(delegate: Runner, listeners: Vector[TestReportListener], log: ManagedLogger) {
final class TestRunner(
delegate: Runner,
listeners: Vector[TestReportListener],
log: ManagedLogger
) {
final def tasks(testDefs: Set[TestDefinition]): Array[TestTask] =
delegate.tasks(