-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Regexes for scala native, splits up uses of certain Collections, System.console, and metaconfig. Also moves some tests to a JVM only directory.
- Loading branch information
Showing
38 changed files
with
560 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,9 +33,32 @@ jobs: | |
- run: | ||
# for GitOps tests | ||
git config --global user.email "[email protected]" && git config --global user.name "scalafmt" | ||
- run: TEST="2.12" sbt ci-test | ||
- run: TEST="2.12" sbt ci-test-jvm | ||
shell: bash | ||
- run: TEST="2.13" sbt ci-test | ||
- run: TEST="2.13" sbt ci-test-jvm | ||
shell: bash | ||
test-scala-native: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [windows-latest, ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up JVM | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
- run: | ||
# for GitOps tests | ||
git config --global user.email "[email protected]" && git config --global user.name "scalafmt" | ||
- run: TEST="2.12" sbt ci-test-native | ||
shell: bash | ||
- run: TEST="2.13" sbt ci-test-native | ||
shell: bash | ||
community-test: | ||
strategy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
scalafmt-cli/jvm/src/main/scala/org/scalafmt/cli/CliOptionsUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.scalafmt.cli | ||
|
||
import java.io.PrintWriter | ||
|
||
private[scalafmt] trait CliOptionsUtils { | ||
def getConsoleWriter(): Option[PrintWriter] = Option(System.console()) | ||
.map(_.writer) | ||
} |
35 changes: 35 additions & 0 deletions
35
scalafmt-cli/jvm/src/main/scala/org/scalafmt/cli/CliUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.scalafmt.cli | ||
|
||
import org.scalafmt.sysops.AbsoluteFile | ||
|
||
import com.martiansoftware.nailgun.NGContext | ||
|
||
private[scalafmt] trait CliUtils { | ||
protected val isScalaNative: Boolean = false | ||
|
||
def nailMain(nGContext: NGContext): Unit = { | ||
val workingDirectory = AbsoluteFile.fromPathIfAbsolute( | ||
nGContext.getWorkingDirectory, | ||
).getOrElse { | ||
throw new IllegalStateException( | ||
s"Expected absolute path, " + | ||
s"obtained nGContext.getWorkingDirectory = ${nGContext.getWorkingDirectory}", | ||
) | ||
} | ||
val exit = Cli.mainWithOptions( | ||
nGContext.getArgs, | ||
CliOptions.default.copy(common = | ||
CliOptions.default.common.copy( | ||
cwd = Some(workingDirectory), | ||
out = nGContext.out, | ||
in = nGContext.in, | ||
err = nGContext.err, | ||
), | ||
), | ||
) | ||
nGContext.exit(exit.code) | ||
} | ||
|
||
protected def getDynamicRunner(): ScalafmtRunner = ScalafmtDynamicRunner | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
scalafmt-cli/jvm/src/main/scala/org/scalafmt/cli/TermUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.scalafmt.cli | ||
|
||
import java.sql.Timestamp | ||
|
||
private[scalafmt] trait TermUtils { | ||
|
||
// Copy/pasted over from coursier, but unused in scalafmt | ||
private val format = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss") | ||
protected def formatTimestamp(ts: Long): String = format | ||
.format(new Timestamp(ts)) | ||
|
||
def noConsole = System.console() == null | ||
} |
7 changes: 7 additions & 0 deletions
7
scalafmt-cli/native/src/main/scala/org/scalafmt/cli/CliOptionsUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.scalafmt.cli | ||
|
||
import java.io.PrintWriter | ||
|
||
private[scalafmt] trait CliOptionsUtils { | ||
def getConsoleWriter(): Option[PrintWriter] = None | ||
} |
7 changes: 7 additions & 0 deletions
7
scalafmt-cli/native/src/main/scala/org/scalafmt/cli/CliUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.scalafmt.cli | ||
|
||
private[scalafmt] trait CliUtils { | ||
protected val isScalaNative: Boolean = true | ||
|
||
protected def getDynamicRunner(): ScalafmtRunner = ??? | ||
} |
9 changes: 9 additions & 0 deletions
9
scalafmt-cli/native/src/main/scala/org/scalafmt/cli/TermUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.scalafmt.cli | ||
|
||
private[scalafmt] trait TermUtils { | ||
|
||
// Copy/pasted over from coursier, but not used in scalafmt | ||
protected def formatTimestamp(ts: Long): String = ??? | ||
|
||
def noConsole = false | ||
} |
Oops, something went wrong.