Skip to content

Commit

Permalink
Add back, re-configure & re-enable Scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Aug 22, 2017
1 parent 19fd664 commit 7320e79
Show file tree
Hide file tree
Showing 27 changed files with 84 additions and 131 deletions.
8 changes: 0 additions & 8 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,3 @@ docstrings = JavaDoc

# This also seems more idiomatic to include whitespace in import x.{ yyy }
spaces.inImportCurlyBraces = true

# This works around sequence wildcard (`_*`) turning into `_ *`
spaces.beforeSeqWildcard = true

# Vertical alignment only => for pattern matching
align.tokens.add = [
{ code = "=>", owner = "Case" }
]
5 changes: 1 addition & 4 deletions bin/run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ set -eu
set -o nounset
SCALA_VERSION="$1"

# drop scalafmt on the 1.0.0 branch to dogfood 1.0.0-RC2 before there is a sbt 1.0 of new-sbt-scalafnt
# see https://github.com/lucidsoftware/neo-sbt-scalafmt/pull/34
# scalafmt::test \
# test:scalafmt::test \

sbt -Dfile.encoding=UTF-8 \
-J-XX:ReservedCodeCacheSize=256M \
-J-Xmx3046M -J-Xms3046M -J-server \
+mimaReportBinaryIssues \
scalafmtTest \
zincRoot/test:compile \
crossTestBridges \
"publishBridgesAndSet $SCALA_VERSION" \
Expand Down
22 changes: 11 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ def internalPath = file("internal")
lazy val compilerBridgeScalaVersions = List(scala212, scala211, scala210)

def mimaSettings: Seq[Setting[_]] = Seq(
mimaPreviousArtifacts := Set(organization.value % moduleName.value % "1.0.0-RC3"
cross (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled)
mimaPreviousArtifacts := Set(
organization.value % moduleName.value % "1.0.0-RC3"
cross (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled)
)
)

Expand Down Expand Up @@ -151,17 +152,11 @@ lazy val zincRoot: Project = (project in file("."))
else v
},
bintrayPackage := "zinc",
scmInfo := Some(
ScmInfo(url("https://github.com/sbt/zinc"), "git@github.com:sbt/zinc.git")),
scmInfo := Some(ScmInfo(url("https://github.com/sbt/zinc"), "git@github.com:sbt/zinc.git")),
description := "Incremental compiler of Scala",
homepage := Some(url("https://github.com/sbt/zinc")),
developers +=
Developer("jvican", "Jorge Vicente Cantero", "@jvican", url("https://github.com/jvican")),
// drop scalafmt on the 1.0.0 branch to dogfood 1.0.0-RC2 before there is a sbt 1.0 of new-sbt-scalafnt
// see https://github.com/lucidsoftware/neo-sbt-scalafmt/pull/34
// scalafmtOnCompile := true,
// scalafmtVersion 1.0.0-RC3 has regression
// scalafmtVersion := "0.6.8"
)),
minimalSettings,
otherRootSettings,
Expand Down Expand Up @@ -218,7 +213,13 @@ lazy val zincPersist = (project in internalPath / "zinc-persist")
// Implements the core functionality of detecting and propagating changes incrementally.
// Defines the data structures for representing file fingerprints and relationships and the overall source analysis
lazy val zincCore = (project in internalPath / "zinc-core")
.dependsOn(zincApiInfo, zincClasspath, compilerInterface, compilerBridge % Test, zincTesting % Test)
.dependsOn(
zincApiInfo,
zincClasspath,
compilerInterface,
compilerBridge % Test,
zincTesting % Test
)
.configure(addBaseSettingsAndTestDeps)
.settings(
// we need to fork because in unit tests we set usejavacp = true which means
Expand Down Expand Up @@ -327,7 +328,6 @@ def wrapIn(color: String, content: String): String = {
else color + content + scala.Console.RESET
}


// Compiler-side interface to compiler that is compiled against the compiler being used either in advance or on the fly.
// Includes API and Analyzer phases that extract source API and relationships.
lazy val compilerBridge: Project = (project in internalPath / "compiler-bridge")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ class ExtractAPI[GlobalType <: Global](
lzy(processDefinitions(s, declared)),
lzy(processDefinitions(s, inherited)))
}
private def processDefinitions(in: Symbol,
defs: List[Symbol]): Array[xsbti.api.ClassDefinition] =
private def processDefinitions(in: Symbol, defs: List[Symbol]): Array[xsbti.api.ClassDefinition] =
sort(defs.toArray).flatMap((d: Symbol) => definition(in, d))
private[this] def sort(defs: Array[Symbol]): Array[Symbol] = {
Arrays.sort(defs, sortClasses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ object Compat {
}

private trait CachedCompilerCompat { self: CachedCompiler0 =>
def newCompiler(settings: Settings, reporter: DelegatingReporter, output: Output): ZincCompiler = {
def newCompiler(
settings: Settings,
reporter: DelegatingReporter,
output: Output
): ZincCompiler = {
// Mixin RangePositions manually if we're in 2.10.x -- unnecessary as of 2.11.x
if (settings.Yrangepos.value) new ZincCompilerRangePos(settings, reporter, output)
else new ZincCompiler(settings, reporter, output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,8 @@ class DependencySpecification extends UnitSpec {
val srcH = "trait H extends G.T[Int] with (E[Int] @unchecked)"

val compilerForTesting = new ScalaCompilerForUnitTesting
val classDependencies = compilerForTesting.extractDependenciesFromSrcs(srcA,
srcB,
srcC,
srcD,
srcE,
srcF,
srcG,
srcH)
val classDependencies =
compilerForTesting.extractDependenciesFromSrcs(srcA, srcB, srcC, srcD, srcE, srcF, srcG, srcH)
classDependencies
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ object ClassToAPI {
fieldToDef(c, classFileForClass(c), enclPkg)(f)
}

def fieldToDef(c: Class[_], cf: => ClassFile, enclPkg: Option[String])(f: Field): api.FieldLike = {
def fieldToDef(c: Class[_], cf: => ClassFile, enclPkg: Option[String])(
f: Field
): api.FieldLike = {
val name = f.getName
val accs = access(f.getModifiers, enclPkg)
val mods = modifiers(f.getModifiers)
Expand Down Expand Up @@ -367,9 +369,7 @@ object ClassToAPI {
arrayMap(exceptions)(t =>
api.Annotation.of(Throws, Array(api.AnnotationArgument.of("value", t.toString))))

def parameter(annots: Array[Annotation],
parameter: Type,
varArgs: Boolean): api.MethodParameter =
def parameter(annots: Array[Annotation], parameter: Type, varArgs: Boolean): api.MethodParameter =
api.MethodParameter.of(
"",
annotated(reference(parameter), annots),
Expand Down
5 changes: 1 addition & 4 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/HashAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ final class HashAPI private (
def this(includePrivate: Boolean, includeParamNames: Boolean) {
// in the old logic we used to always include definitions hence
// includeDefinitions=true
this(includePrivate,
includeParamNames,
includeDefinitions = true,
includeSealedChildren = true)
this(includePrivate, includeParamNames, includeDefinitions = true, includeSealedChildren = true)
}

import scala.collection.mutable
Expand Down
9 changes: 4 additions & 5 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/SameAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
case _ =>
debug(
flag = false,
"Different qualifier categories: " + a.getClass.getName + " -- " + b.getClass.getName)
"Different qualifier categories: " + a.getClass.getName + " -- " + b.getClass.getName
)
}

def sameModifiers(a: Modifiers, b: Modifiers): Boolean =
Expand Down Expand Up @@ -184,8 +185,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
case _ => false
}

def sameParameterizedDefinition(a: ParameterizedDefinition,
b: ParameterizedDefinition): Boolean =
def sameParameterizedDefinition(a: ParameterizedDefinition, b: ParameterizedDefinition): Boolean =
debug(sameTypeParameters(a.typeParameters, b.typeParameters),
"Different type parameters for " + a.name) &&
sameParameterizedSpecificAPI(a, b)
Expand All @@ -208,8 +208,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
debug(sameType(a.tpe, b.tpe), "Different alias type for " + a.name)
def sameDeclarationSpecificAPI(a: TypeDeclaration, b: TypeDeclaration): Boolean =
debug(sameType(a.lowerBound, b.lowerBound), "Different lower bound for declaration " + a.name) &&
debug(sameType(a.upperBound, b.upperBound),
"Different upper bound for declaration " + a.name)
debug(sameType(a.upperBound, b.upperBound), "Different upper bound for declaration " + a.name)
def sameFieldSpecificAPI(a: FieldLike, b: FieldLike): Boolean =
debug(
sameFieldCategory(a, b),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ package p3 { class x { object y { object z; class z } } }
package p4 { class x { class y { object z; class z } } }

class ClassCanonicalNameSpec extends FlatSpec with Matchers {
"ClassToAPI.classCanonicalName" should """return "" for null""" in assert(getCustomCanonicalName(null) === "")
"ClassToAPI.classCanonicalName" should """return "" for null""" in
assert(getCustomCanonicalName(null) === "")

import scala.reflect._
def check[T: ClassTag](expected: Expected) = checkClass(expected, classTag[T].runtimeClass, "tag")
Expand Down Expand Up @@ -60,17 +61,17 @@ class ClassCanonicalNameSpec extends FlatSpec with Matchers {

checkRef(OO, p1.x.y)
checkRef(OC, new p2.x.y)
checkRef(CO, { val c1 = new p3.x ; c1.y })
checkRef(CC, { val c1 = new p4.x ; new c1.y })
checkRef(CO, { val c1 = new p3.x; c1.y })
checkRef(CC, { val c1 = new p4.x; new c1.y })

checkRef(OOO, p1.x.y.z)
checkRef(OOC, new p1.x.y.z)
checkRef(OCO, { val c2 = new p2.x.y ; c2.z })
checkRef(OCC, { val c2 = new p2.x.y ; new c2.z })
checkRef(COO, { val c1 = new p3.x ; c1.y.z })
checkRef(COC, { val c1 = new p3.x ; new c1.y.z })
checkRef(CCO, { val c1 = new p4.x ; val c2 = new c1.y ; c2.z })
checkRef(CCC, { val c1 = new p4.x ; val c2 = new c1.y ; new c2.z })
checkRef(OCO, { val c2 = new p2.x.y; c2.z })
checkRef(OCC, { val c2 = new p2.x.y; new c2.z })
checkRef(COO, { val c1 = new p3.x; c1.y.z })
checkRef(COC, { val c1 = new p3.x; new c1.y.z })
checkRef(CCO, { val c1 = new p4.x; val c2 = new c1.y; c2.z })
checkRef(CCC, { val c1 = new p4.x; val c2 = new c1.y; new c2.z })

object O extends Expected("x$")
object C extends Expected("x")
Expand All @@ -90,22 +91,21 @@ class ClassCanonicalNameSpec extends FlatSpec with Matchers {
object CCC extends Expected("x.y.z")

class Expected(
val canonicalClassName: String,
val nativeClassNameIsMalformed: Boolean = false
val canonicalClassName: String,
val nativeClassNameIsMalformed: Boolean = false
) {
val nesting = {
val n0 = getClass.getSimpleName stripSuffix "$"
Seq(n0, "-" * (n0.length - 1)).flatMap(_.zipWithIndex).sortBy(_._2).map(_._1).mkString
}

val nativeCanonicalClassName = (
if (nativeClassNameIsMalformed) "Malformed class name"
else canonicalClassName
)
val nativeCanonicalClassName =
if (nativeClassNameIsMalformed) "Malformed class name" else canonicalClassName
}

def handleMalformed(s: => String) =
try s catch {
try s
catch {
case e: InternalError if e.getMessage == "Malformed class name" => "Malformed class name"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class NameHashingSpecification extends UnitSpec {
if (optimizedSealed) {
nameHashesA.namesIn(UseScope.PatMatTarget) shouldEqual nameHashesB.namesIn(
UseScope.PatMatTarget)
nameHashesA.in(UseScope.PatMatTarget) should not equal nameHashesB.in(
UseScope.PatMatTarget)
nameHashesA.in(UseScope.PatMatTarget) should not equal nameHashesB.in(UseScope.PatMatTarget)
}

HashAPI(a) should not equal HashAPI(b)
Expand Down Expand Up @@ -136,9 +135,8 @@ class NameHashingSpecification extends UnitSpec {
val nameHashing = new NameHashing(false)
val deff =
Def.of("bar", publicAccess, defaultModifiers, Array.empty, Array.empty, Array.empty, intTpe)
val classFoo = simpleClassLike(name = "Foo",
dt = DefinitionType.ClassDef,
structure = simpleStructure(deff))
val classFoo =
simpleClassLike(name = "Foo", dt = DefinitionType.ClassDef, structure = simpleStructure(deff))
val objectFoo =
simpleClassLike(name = "Foo", dt = DefinitionType.Module, structure = simpleStructure(deff))
val nameHashes1 = nameHashing.nameHashes(classFoo)
Expand Down Expand Up @@ -210,13 +208,8 @@ class NameHashingSpecification extends UnitSpec {

/** def foo: { bar: Int } */
val fooMethod1 = {
val barMethod1 = Def.of("bar",
publicAccess,
defaultModifiers,
Array.empty,
Array.empty,
Array.empty,
intTpe)
val barMethod1 =
Def.of("bar", publicAccess, defaultModifiers, Array.empty, Array.empty, Array.empty, intTpe)
Def.of("foo",
publicAccess,
defaultModifiers,
Expand All @@ -228,13 +221,8 @@ class NameHashingSpecification extends UnitSpec {

/** def foo: { bar: String } */
val fooMethod2 = {
val barMethod2 = Def.of("bar",
publicAccess,
defaultModifiers,
Array.empty,
Array.empty,
Array.empty,
strTpe)
val barMethod2 =
Def.of("bar", publicAccess, defaultModifiers, Array.empty, Array.empty, Array.empty, strTpe)
Def.of("foo",
publicAccess,
defaultModifiers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ object ClasspathUtilities {
final val AppClassPath = "app.class.path"
final val BootClassPath = "boot.class.path"

def createClasspathResources(classpath: Seq[File],
instance: ScalaInstance): Map[String, String] =
def createClasspathResources(classpath: Seq[File], instance: ScalaInstance): Map[String, String] =
createClasspathResources(classpath, instance.allJars)

def createClasspathResources(appPaths: Seq[File], bootPaths: Seq[File]): Map[String, String] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import scala.sys.process.ProcessLogger
* @param reporter A reporter for semantic Javac error messages.
* @param cwd The current working directory of the Javac process, used when parsing Filenames.
*/
final class JavacLogger(log: sbt.util.Logger, reporter: Reporter, cwd: File)
extends ProcessLogger {
final class JavacLogger(log: sbt.util.Logger, reporter: Reporter, cwd: File) extends ProcessLogger {
import scala.collection.mutable.ListBuffer
import sbt.util.Level.{ Info, Error, Value => LogLevel }

Expand Down
10 changes: 2 additions & 8 deletions internal/zinc-core/src/main/scala/sbt/internal/inc/Compile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ private final class AnalysisCallback(

def classDependency(onClassName: String, sourceClassName: String, context: DependencyContext) = {
if (onClassName != sourceClassName)
add(intSrcDeps,
sourceClassName,
InternalDependency.of(sourceClassName, onClassName, context))
add(intSrcDeps, sourceClassName, InternalDependency.of(sourceClassName, onClassName, context))
}

private[this] def externalBinaryDependency(binary: File,
Expand Down Expand Up @@ -229,11 +227,7 @@ private final class AnalysisCallback(
// but not in the same compiler run (as in javac v. scalac)
classDependency(dependsOn, fromClassName, context)
case None =>
externalDependency(classFile,
onBinaryClassName,
fromClassName,
fromSourceFile,
context)
externalDependency(classFile, onBinaryClassName, fromClassName, fromSourceFile, context)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ private[inc] abstract class IncrementalCommon(val log: sbt.util.Logger, options:
modifiedSrcs.flatMap(previous.relations.classNames) ++ modifiedSrcs.flatMap(
current.relations.classNames)

val incChanges = changedIncremental(recompiledClasses,
previous.apis.internalAPI,
current.apis.internalAPI)
val incChanges =
changedIncremental(recompiledClasses, previous.apis.internalAPI, current.apis.internalAPI)

debug("\nChanges:\n" + incChanges)
val transitiveStep = options.transitiveStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ private final class IncrementalNameHashing(log: sbt.util.Logger, options: IncOpt
)

// Get the member reference dependencies of all classes transitively invalidated by inheritance
log.debug(
"Getting direct dependencies of all classes transitively invalidated by inheritance.")
log.debug("Getting direct dependencies of all classes transitively invalidated by inheritance.")
val memberRefA = transitiveInheritance flatMap memberRefInvalidationInternal
// Get the classes that depend on externals by member reference.
// This includes non-inheritance dependencies and is not transitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ private[inc] sealed trait RelationDescriptor[A, B] {

private[inc] case class FFRelationDescriptor(
header: String,
selectCorresponding: Relations => Relation[File, File])
extends RelationDescriptor[File, File] {
selectCorresponding: Relations => Relation[File, File]
) extends RelationDescriptor[File, File] {
override def firstWrite(a: File): String = a.toString
override def secondWrite(b: File): String = b.toString
override def firstRead(s: String): File = new File(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ private object ZincLMHelper {
}
}

private def defaultUpdateConfiguration(targetDir: File, noSource: Boolean): UpdateConfiguration = {
private def defaultUpdateConfiguration(
targetDir: File,
noSource: Boolean
): UpdateConfiguration = {
val retrieve = RetrieveConfiguration()
.withRetrieveDirectory(targetDir)
.withOutputPattern(defaultRetrievePattern)
Expand Down
Loading

0 comments on commit 7320e79

Please sign in to comment.