Skip to content

Commit 3716e30

Browse files
Update Scalafmt
1 parent b9d5558 commit 3716e30

34 files changed

+369
-266
lines changed

.scalafmt.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
version = "2.7.5"
1+
version = "3.9.8"
2+
runner.dialect = scala213source3
23
assumeStandardLibraryStripMargin = true
34
docstrings.style = Asterisk
45
docstrings.wrap = "yes"

build.sbt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -410,19 +410,18 @@ lazy val minimized8 = project
410410
.dependsOn(agent, javacPlugin)
411411
.disablePlugins(JavaFormatterPlugin)
412412

413-
def javacModuleOptions =
414-
List(
415-
"-J--add-exports",
416-
"-Jjdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
417-
"-J--add-exports",
418-
"-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
419-
"-J--add-exports",
420-
"-Jjdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
421-
"-J--add-exports",
422-
"-Jjdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
423-
"-J--add-exports",
424-
"-Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
425-
)
413+
def javacModuleOptions = List(
414+
"-J--add-exports",
415+
"-Jjdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
416+
"-J--add-exports",
417+
"-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
418+
"-J--add-exports",
419+
"-Jjdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
420+
"-J--add-exports",
421+
"-Jjdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
422+
"-J--add-exports",
423+
"-Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
424+
)
426425

427426
lazy val minimized17 = project
428427
.in(file("tests/minimized/.j17"))
@@ -459,7 +458,7 @@ lazy val unit = project
459458
.in(file("tests/unit"))
460459
.settings(
461460
testSettings,
462-
//javaOptions ++= Seq( "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
461+
// javaOptions ++= Seq( "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
463462
buildInfoKeys :=
464463
Seq[BuildInfoKey](
465464
version,
@@ -486,9 +485,11 @@ lazy val buildTools = project
486485
(Test / javaOptions) ++=
487486
List(
488487
s"-javaagent:${(agent / Compile / Keys.`package`).value}",
489-
s"-Dsemanticdb.pluginpath=${(javacPlugin / Compile / Keys.`package`).value}",
488+
s"-Dsemanticdb.pluginpath=${(javacPlugin / Compile / Keys.`package`)
489+
.value}",
490490
s"-Dsemanticdb.sourceroot=${(ThisBuild / baseDirectory).value}",
491-
s"-Dsemanticdb.targetroot=${(agent / Compile / target).value / "semanticdb-targetroot"}"
491+
s"-Dsemanticdb.targetroot=${(agent / Compile / target).value /
492+
"semanticdb-targetroot"}"
492493
),
493494
Test / envVars ++=
494495
Map(

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.14")
22
addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.9.0")
33
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.1")
44
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
5-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
5+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")
66
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.5.2")
77
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0")
88
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")

scip-java/src/main/scala/com/sourcegraph/scip_java/Dependencies.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ object Dependencies {
6262
.addRepositories(defaultExtraRepositories: _*)
6363

6464
if (artifact.endsWith("-jvm")) {
65-
val dependency = Dependencies
66-
.parseDependency(s"$group:${artifact.stripSuffix("-jvm")}:$version")
65+
val dependency = Dependencies.parseDependency(
66+
s"$group:${artifact.stripSuffix("-jvm")}:$version"
67+
)
6768
val result = task.addDependencies(dependency).runResult()
6869
return Some(result.files.head.toPath)
6970
}
7071

71-
val dependency = Dependencies
72-
.parseDependency(s"$group:$artifact-common:$version")
72+
val dependency = Dependencies.parseDependency(
73+
s"$group:$artifact-common:$version"
74+
)
7375
val result = task.addDependencies(dependency).runResult()
7476
result.files.head.toPath
7577
}.toOption
@@ -145,8 +147,10 @@ object Dependencies {
145147
}.toList
146148

147149
def parseDependencyEither(lib: String): Either[String, Dependency] = {
148-
DependencyParser
149-
.dependency(lib, defaultScalaVersion = BuildInfo.scalaVersion)
150+
DependencyParser.dependency(
151+
lib,
152+
defaultScalaVersion = BuildInfo.scalaVersion
153+
)
150154
}
151155

152156
private def parseDependency(lib: String): Dependency = {

scip-java/src/main/scala/com/sourcegraph/scip_java/Embedded.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ import os.CommandResult
1111

1212
object Embedded {
1313

14-
def semanticdbJar(tmpDir: Path): Path =
15-
copyFile(tmpDir, "semanticdb-plugin.jar")
14+
def semanticdbJar(tmpDir: Path): Path = copyFile(
15+
tmpDir,
16+
"semanticdb-plugin.jar"
17+
)
1618

17-
def gradlePluginJar(tmpDir: Path): Path =
18-
copyFile(tmpDir, "gradle-plugin.jar")
19+
def gradlePluginJar(tmpDir: Path): Path = copyFile(
20+
tmpDir,
21+
"gradle-plugin.jar"
22+
)
1923

2024
def agentJar(tmpDir: Path): Path = copyFile(tmpDir, "semanticdb-agent.jar")
2125

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BuildTool.scala

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@ object BuildTool {
2222
// detected, we should at least give a meaningful error message
2323
autoOrdered(index) :+ new BazelBuildTool(index)
2424

25-
def autoOrdered(index: IndexCommand): List[BuildTool] =
26-
List(
27-
// The order in this list is important -
28-
// first detected build tool will be used in `auto` mode
29-
// Bazel is missing because it isn't supported by auto-indexing
25+
def autoOrdered(index: IndexCommand): List[BuildTool] = List(
26+
// The order in this list is important -
27+
// first detected build tool will be used in `auto` mode
28+
// Bazel is missing because it isn't supported by auto-indexing
3029

31-
// first as it indicates user's intent to use SCIP auto-indexing
32-
new ScipBuildTool(index),
33-
// Maven first, then Gradle, then SBT
34-
// To match the order indicated in IntelliJ Java and Scala developer surveys 2022:
35-
// 1. https://www.jetbrains.com/lp/devecosystem-2022/java/#which-build-systems-do-you-regularly-use-if-any-
36-
// 2. https://www.jetbrains.com/lp/devecosystem-2022/scala/#which-build-systems-do-you-regularly-use-if-any-
37-
new MavenBuildTool(index),
38-
new GradleBuildTool(index),
39-
new SbtBuildTool(index),
40-
new MillBuildTool(index)
41-
)
42-
def allNames: String =
43-
all(IndexCommand()).filterNot(_.isHidden).map(_.name).mkString(", ")
30+
// first as it indicates user's intent to use SCIP auto-indexing
31+
new ScipBuildTool(index),
32+
// Maven first, then Gradle, then SBT
33+
// To match the order indicated in IntelliJ Java and Scala developer surveys 2022:
34+
// 1. https://www.jetbrains.com/lp/devecosystem-2022/java/#which-build-systems-do-you-regularly-use-if-any-
35+
// 2. https://www.jetbrains.com/lp/devecosystem-2022/scala/#which-build-systems-do-you-regularly-use-if-any-
36+
new MavenBuildTool(index),
37+
new GradleBuildTool(index),
38+
new SbtBuildTool(index),
39+
new MillBuildTool(index)
40+
)
41+
def allNames: String = all(IndexCommand())
42+
.filterNot(_.isHidden)
43+
.map(_.name)
44+
.mkString(", ")
4445

4546
def generateScipFromTargetroot(
4647
generateSemanticdbResult: CommandResult,

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ClasspathEntry.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object ClasspathEntry {
4242
* "dependencies.txt" - for example if they come from a multi-module build.
4343
*
4444
* @param targetroot
45-
* @return
45+
* @return
4646
*/
4747
def fromTargetroot(
4848
targetroot: Path,
@@ -61,7 +61,8 @@ object ClasspathEntry {
6161
* for multiple projects.
6262
*
6363
* @param targetroot
64-
* @return classpath entries read from the discovered files
64+
* @return
65+
* classpath entries read from the discovered files
6566
*/
6667
private def discoverDependenciesFromFiles(
6768
targetroot: Path
@@ -155,8 +156,9 @@ object ClasspathEntry {
155156
* given jar file.
156157
*/
157158
private def fromClasspathJarFile(jar: Path): Option[ClasspathEntry] = {
158-
val pom = jar
159-
.resolveSibling(jar.getFileName.toString.stripSuffix(".jar") + ".pom")
159+
val pom = jar.resolveSibling(
160+
jar.getFileName.toString.stripSuffix(".jar") + ".pom"
161+
)
160162
val sources = Option(
161163
jar.resolveSibling(
162164
jar.getFileName.toString.stripSuffix(".jar") + ".sources"

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/GradleBuildTool.scala

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,25 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
2121
"build.gradle",
2222
"build.gradle.kts"
2323
)
24-
gradleFiles
25-
.exists(name => Files.isRegularFile(index.workingDirectory.resolve(name)))
24+
gradleFiles.exists(name =>
25+
Files.isRegularFile(index.workingDirectory.resolve(name))
26+
)
2627
}
2728

2829
override def generateScip(): Int = {
29-
BuildTool
30-
.generateScipFromTargetroot(generateSemanticdb(), targetroot, index)
30+
BuildTool.generateScipFromTargetroot(
31+
generateSemanticdb(),
32+
targetroot,
33+
index
34+
)
3135
}
3236

3337
def targetroot: Path = index.finalTargetroot(defaultTargetroot)
3438

35-
private def defaultTargetroot: Path =
36-
Paths.get("build", "semanticdb-targetroot")
39+
private def defaultTargetroot: Path = Paths.get(
40+
"build",
41+
"semanticdb-targetroot"
42+
)
3743
private def generateSemanticdb(): CommandResult = {
3844
val gradleWrapper: Path = index
3945
.workingDirectory
@@ -127,14 +133,14 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
127133
)
128134
}
129135

130-
def semanticdbScalacGroovySyntax(): String =
131-
BuildInfo
132-
.semanticdbScalacVersions
133-
.removed(
134-
"2.12.3"
135-
) // Not supported because the last semanticdb-scalac_2.12.3 release doesn't support the option -P:semanticdb:targetroot:PATH.
136-
.map { case (key, value) =>
137-
s"'$key':'$value'"
138-
}.mkString("[", ", ", "]")
136+
def semanticdbScalacGroovySyntax(): String = BuildInfo
137+
.semanticdbScalacVersions
138+
.removed(
139+
"2.12.3"
140+
) // Not supported because the last semanticdb-scalac_2.12.3 release doesn't support the option -P:semanticdb:targetroot:PATH.
141+
.map { case (key, value) =>
142+
s"'$key':'$value'"
143+
}
144+
.mkString("[", ", ", "]")
139145

140146
}

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/GradleJavaToolchains.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ case class GradleJavaToolchains(
2929

3030
def isJavaAtLeast(version: Int): Boolean = {
3131
val actualVersion = javaVersion.getOrElse(sys.props("java.version"))
32-
GradleJavaToolchains
33-
.isJavaAtLeast(actualVersion, math.max(version, 0).toString())
32+
GradleJavaToolchains.isJavaAtLeast(
33+
actualVersion,
34+
math.max(version, 0).toString()
35+
)
3436
}
3537

3638
def executableJavacPath(): Option[Path] = {
@@ -79,8 +81,9 @@ object GradleJavaToolchains {
7981
val scalaEnabledPath = tmp.resolve("scala-enabled.txt")
8082
val kotlinEnabledPath = tmp.resolve("kotlin-enabled.txt")
8183
val javaVersionPath = tmp.resolve("java-version.txt")
82-
val kotlinMultiplatformEnabledPath = tmp
83-
.resolve("kotlin-multiplatform-enabled.txt")
84+
val kotlinMultiplatformEnabledPath = tmp.resolve(
85+
"kotlin-multiplatform-enabled.txt"
86+
)
8487
val gradleVersionPath = tmp.resolve("gradle-version.txt")
8588
val taskName = "scipDetectJavaToolchains"
8689
@Language("Groovy")
@@ -186,8 +189,9 @@ object GradleJavaToolchains {
186189
isJavaEnabled = Files.isRegularFile(javaEnabledPath),
187190
isScalaEnabled = Files.isRegularFile(scalaEnabledPath),
188191
isKotlinEnabled = Files.isRegularFile(kotlinEnabledPath),
189-
isKotlinMultiplatformEnabled = Files
190-
.isRegularFile(kotlinMultiplatformEnabledPath),
192+
isKotlinMultiplatformEnabled = Files.isRegularFile(
193+
kotlinMultiplatformEnabledPath
194+
),
191195
gradleCommand = gradleCommand,
192196
tmp = tmp
193197
)

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MavenBuildTool.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import os.CommandResult
1212

1313
class MavenBuildTool(index: IndexCommand) extends BuildTool("Maven", index) {
1414

15-
override def usedInCurrentDirectory(): Boolean =
16-
Files.isRegularFile(index.workingDirectory.resolve("pom.xml"))
15+
override def usedInCurrentDirectory(): Boolean = Files.isRegularFile(
16+
index.workingDirectory.resolve("pom.xml")
17+
)
1718

1819
override def generateScip(): Int = {
1920
BuildTool.generateScipFromTargetroot(
@@ -23,8 +24,10 @@ class MavenBuildTool(index: IndexCommand) extends BuildTool("Maven", index) {
2324
)
2425
}
2526

26-
private def defaultTargetroot: Path =
27-
Paths.get("target", "semanticdb-targetroot")
27+
private def defaultTargetroot: Path = Paths.get(
28+
"target",
29+
"semanticdb-targetroot"
30+
)
2831

2932
private def generateSemanticdb(): CommandResult = {
3033
TemporaryFiles.withDirectory(index) { tmp =>

0 commit comments

Comments
 (0)