Skip to content

Commit

Permalink
Fix scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Aug 3, 2022
1 parent 6311689 commit 71954ef
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ object ConsoleBloopBuildClient {
def printFileDiagnostic(
logger: Logger,
path: Either[String, os.Path],
diag: bsp4j.Diagnostic,
diag: bsp4j.Diagnostic
): Unit = {
val isWarningOrErrorOrHint = diag.getSeverity == bsp4j.DiagnosticSeverity.ERROR ||
diag.getSeverity == bsp4j.DiagnosticSeverity.WARNING ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DirectiveTests extends munit.FunSuite {
def bloopConfigOpt = Some(BloopServer.bloopConfig)

val extraRepoTmpDir = os.temp.dir(prefix = "scala-cli-tests-extra-repo-")
val directories = Directories.under(extraRepoTmpDir)
val directories = Directories.under(extraRepoTmpDir)

override def afterAll(): Unit = {
TestInputs.tryRemoveAll(extraRepoTmpDir)
Expand All @@ -38,21 +38,21 @@ class DirectiveTests extends munit.FunSuite {
)
testInputs.withBuild(baseOptions, buildThreads, bloopConfigOpt) {
(_, _, maybeBuild) =>
val build = maybeBuild.orThrow
val dep = build.options.classPathOptions.extraDependencies.toSeq.headOption
val build = maybeBuild.orThrow
val dep = build.options.classPathOptions.extraDependencies.toSeq.headOption
assert(dep.nonEmpty)

val position = dep.get.positions.headOption
assert(position.nonEmpty)

val (startPos, endPos) = position.get match {
case Position.File(_, startPos, endPos) => (startPos, endPos)
case _ => sys.error("cannot happen")
case _ => sys.error("cannot happen")
}

expect(startPos == (0,15))
expect(endPos == (0,40))
expect(startPos == (0, 15))
expect(endPos == (0, 40))
}
}

}
}
6 changes: 4 additions & 2 deletions modules/cli/src/main/scala/scala/cli/commands/Bsp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ object Bsp extends ScalaCommand[BspOptions] {
CurrentParams.workspaceOpt = Some(inputs.workspace)
val configDb = ConfigDb.open(options.shared.directories.directories)
.orExit(logger)
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(configDb.get(Keys.actions).getOrElse(None))
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(
configDb.get(Keys.actions).getOrElse(None)
)

BspThreads.withThreads { threads =>
val bsp = scala.build.bsp.Bsp.create(
Expand Down
6 changes: 4 additions & 2 deletions modules/cli/src/main/scala/scala/cli/commands/Compile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ object Compile extends ScalaCommand[CompileOptions] {
val compilerMaker = options.shared.compilerMaker(threads)
val configDb = ConfigDb.open(options.shared.directories.directories)
.orExit(logger)
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(configDb.get(Keys.actions).getOrElse(None))
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(
configDb.get(Keys.actions).getOrElse(None)
)

if (options.watch.watchMode) {
val watcher = Build.watch(
Expand Down
6 changes: 4 additions & 2 deletions modules/cli/src/main/scala/scala/cli/commands/Doc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ object Doc extends ScalaCommand[DocOptions] {

val configDb = ConfigDb.open(options.shared.directories.directories)
.orExit(logger)
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(configDb.get(Keys.actions).getOrElse(None))
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(
configDb.get(Keys.actions).getOrElse(None)
)

val builds =
Build.build(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ object Metabrowse extends ScalaCommand[MetabrowseOptions] {
val compilerMaker = options.shared.compilerMaker(threads)
val configDb = ConfigDb.open(options.shared.directories.directories)
.orExit(logger)
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(configDb.get(Keys.actions).getOrElse(None))
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(
configDb.get(Keys.actions).getOrElse(None)
)

val builds =
Build.build(
Expand Down
6 changes: 4 additions & 2 deletions modules/cli/src/main/scala/scala/cli/commands/Package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ object Package extends ScalaCommand[PackageOptions] {
val cross = options.compileCross.cross.getOrElse(false)
val configDb = ConfigDb.open(options.shared.directories.directories)
.orExit(logger)
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(configDb.get(Keys.actions).getOrElse(None))
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(
configDb.get(Keys.actions).getOrElse(None)
)

if (options.watch.watchMode) {
var expectedModifyEpochSecondOpt = Option.empty[Long]
Expand Down
6 changes: 4 additions & 2 deletions modules/cli/src/main/scala/scala/cli/commands/Repl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ object Repl extends ScalaCommand[ReplOptions] {
val cross = options.compileCross.cross.getOrElse(false)
val configDb = ConfigDb.open(options.shared.directories.directories)
.orExit(logger)
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(configDb.get(Keys.actions).getOrElse(None))
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(
configDb.get(Keys.actions).getOrElse(None)
)

if (inputs.isEmpty) {
val artifacts = initialBuildOptions.artifacts(logger, Scope.Main).orExit(logger)
Expand Down
6 changes: 4 additions & 2 deletions modules/cli/src/main/scala/scala/cli/commands/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ object Run extends ScalaCommand[RunOptions] {

val configDb = ConfigDb.open(options.shared.directories.directories)
.orExit(logger)
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(configDb.get(Keys.actions).getOrElse(None))
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(
configDb.get(Keys.actions).getOrElse(None)
)

if (options.watch.watchMode) {
var processOpt = Option.empty[(Process, CompletableFuture[_])]
Expand Down
6 changes: 4 additions & 2 deletions modules/cli/src/main/scala/scala/cli/commands/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ object Test extends ScalaCommand[TestOptions] {
val cross = options.compileCross.cross.getOrElse(false)
val configDb = ConfigDb.open(options.shared.directories.directories)
.orExit(logger)
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(configDb.get(Keys.actions).getOrElse(None))
val actionableDiagnostics =
options.shared.logging.verbosityOptions.actions.orElse(
configDb.get(Keys.actions).getOrElse(None)
)

def maybeTest(builds: Builds, allowExit: Boolean): Unit = {
val optionsKeys = builds.map.keys.toVector.map(_.optionsKey).distinct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CliLogger(

for {
filePath <- f.path
info <- relatedInformation
info <- relatedInformation
} {
val location = new Location(filePath.toNIO.toUri.toASCIIString, range)
val related = new b.DiagnosticRelatedInformation(location, info.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package scala.build.errors
import scala.build.Position
import scala.build.errors.Diagnostic.RelatedInformation


trait Diagnostic {
def message: String
def severity: Severity
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/main/scala/scala/build/errors/Severity.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package scala.build.errors

import ch.epfl.scala.bsp4j as b
import ch.epfl.scala.bsp4j.DiagnosticSeverity

sealed abstract class Severity extends Product with Serializable {
def toBsp4j: b.DiagnosticSeverity
}

object Severity {
case object Error extends Severity {
override def toBsp4j: DiagnosticSeverity = b.DiagnosticSeverity.ERROR
override def toBsp4j: b.DiagnosticSeverity = b.DiagnosticSeverity.ERROR
}
case object Warning extends Severity {
override def toBsp4j: DiagnosticSeverity = b.DiagnosticSeverity.WARNING
override def toBsp4j: b.DiagnosticSeverity = b.DiagnosticSeverity.WARNING
}
case object Hint extends Severity {
override def toBsp4j: DiagnosticSeverity = b.DiagnosticSeverity.HINT
override def toBsp4j: b.DiagnosticSeverity = b.DiagnosticSeverity.HINT
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1143,15 +1143,13 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
test("bsp should report actionable diagnostic when enabled") {
val fileName = "Hello.scala"
val inputs = TestInputs(
Seq(
os.rel / fileName ->
s"""//> using lib "com.lihaoyi::os-lib:0.7.8"
|
|object Hello extends App {
| println("Hello")
|}
|""".stripMargin
)
os.rel / fileName ->
s"""//> using lib "com.lihaoyi::os-lib:0.7.8"
|
|object Hello extends App {
| println("Hello")
|}
|""".stripMargin
)
withBsp(inputs, Seq(".", "--actions")) {
(root, localClient, remoteServer) =>
Expand All @@ -1169,7 +1167,7 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
expect(visibleDiagnostics.length == 1)

val updateActionableDiagnostic = visibleDiagnostics.head

checkDiagnostic(
diagnostic = updateActionableDiagnostic,
expectedMessage = "com.lihaoyi::os-lib:0.7.8 is outdated",
Expand All @@ -1184,7 +1182,9 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])

val relatedInformation = updateActionableDiagnostic.getRelatedInformation()
expect(relatedInformation.getMessage.contains("com.lihaoyi::os-lib:"))
expect(relatedInformation.getLocation().getUri() == (root /fileName).toNIO.toUri.toASCIIString)
expect(
relatedInformation.getLocation().getUri() == (root / fileName).toNIO.toUri.toASCIIString
)
}
}
}
Expand Down Expand Up @@ -1245,7 +1245,7 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
expect(diagnostic.getMessage == expectedMessage)
else
expect(diagnostic.getMessage.contains(expectedMessage))
for(es <- expectedSource)
for (es <- expectedSource)
expect(diagnostic.getSource == es)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import scala.build.Position
import scala.build.errors.{Diagnostic, Severity}
import scala.build.errors.Diagnostic.RelatedInformation


abstract class ActionableDiagnostic extends Diagnostic {

/** Provide the message of actionable diagnostic
Expand Down
4 changes: 4 additions & 0 deletions website/docs/reference/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,10 @@ Aliases: `-i`

Interactive mode

#### `--actions`

Enable actionable diagnostics

## Watch options

Available in commands:
Expand Down

0 comments on commit 71954ef

Please sign in to comment.