Skip to content

Commit 2c8add7

Browse files
authored
Merge pull request #546 from romanowski/better-comments
New using directive syntax
2 parents 0bd3365 + 0162676 commit 2c8add7

File tree

63 files changed

+772
-791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+772
-791
lines changed

build.sc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import $file.project.settings, settings.{
1515
localRepoResourcePath,
1616
platformExecutableJarExtension
1717
}
18+
import $file.project.deps, deps.customRepositories
1819

1920
import java.io.File
2021
import java.nio.charset.Charset
@@ -113,9 +114,7 @@ object `generate-reference-doc` extends SbtModule with ScalaCliScalafixModule {
113114
def moduleDeps = Seq(
114115
cli
115116
)
116-
def repositories = super.repositories ++ Seq(
117-
coursier.Repositories.sonatype("snapshots")
118-
)
117+
def repositories = super.repositories ++ customRepositories
119118
def ivyDeps = Agg(
120119
Deps.caseApp,
121120
Deps.munit
@@ -176,9 +175,8 @@ class Build(val crossScalaVersion: String)
176175
def scalacOptions = T {
177176
super.scalacOptions() ++ Seq("-Xasync", "-Ywarn-unused", "-deprecation")
178177
}
179-
def repositories = super.repositories ++ Seq(
180-
coursier.Repositories.sonatype("snapshots")
181-
)
178+
def repositories = super.repositories ++ customRepositories
179+
182180
def compileIvyDeps = super.compileIvyDeps() ++ Agg(
183181
Deps.svm
184182
)
@@ -324,9 +322,9 @@ trait Cli extends SbtModule with CliLaunchers with ScalaCliPublishModule with Fo
324322
build(Scala.defaultInternal),
325323
`test-runner`(Scala.defaultInternal)
326324
)
327-
def repositories = super.repositories ++ Seq(
328-
coursier.Repositories.sonatype("snapshots")
329-
)
325+
326+
def repositories = super.repositories ++ customRepositories
327+
330328
def ivyDeps = super.ivyDeps() ++ Agg(
331329
Deps.caseApp,
332330
Deps.coursierLauncher,

examples/cross-build/Hello.js.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// using scala 2.13
2-
// using target scala-js
1+
//> using scala 2.13
2+
//> using target scala-js
33

44
import scala.scalajs.js
55

examples/cross-build/Hello.native.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// using scala 2.13
2-
// using target scala-native
1+
//> using scala 2.13
2+
//> using target scala-native
33

44
import scala.scalanative.libc._
55
import scala.scalanative.unsafe._

examples/scala-versions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Using directives syntax is still experimental and may change in future versions
9595
So when we will have:
9696

9797
```scala title=version.scala
98-
// using scala 2.12.5
98+
//> using scala 2.12.5
9999

100100
object OldCode
101101
//rest of the config
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File was generated from based on docs/cookbooks/scala-versions.md, do not edit manually!
22

3-
// using scala 2.12.5
3+
//> using scala 2.12.5
44

55
object OldCode
66
//rest of the config

examples/scripting/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ print all files located in path passed as the first argument
1212
Create a file name `ls.sc`
1313
```scala
1414
#!/usr/bin/env scala-cli
15-
// using lib "com.lihaoyi::os-lib:0.7.8"
15+
//> using lib "com.lihaoyi::os-lib:0.7.8"
1616
val cwd = if(args.nonEmpty) os.Path(args(0), os.pwd) else os.pwd
1717
println(os.list(cwd).map(_.last).mkString("\n"))
1818
```

examples/utest/MyTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// using lib "com.lihaoyi::utest::0.7.10"
1+
//> using lib "com.lihaoyi::utest::0.7.10"
22

33
import utest._
44

gcbenchmark/gcbenchmark.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// using lib "com.lihaoyi::os-lib:0.8.0"
2-
// using lib "com.lihaoyi::pprint:0.7.1"
3-
// using scala "2.13"
1+
//> using lib "com.lihaoyi::os-lib:0.8.0"
2+
//> using lib "com.lihaoyi::pprint:0.7.1"
3+
//> using scala "2.13"
44

55
// Usage: scala-cli gcbenchmark.scala -- <path_to_scala_cli_executable>
66

mill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ EOF
2020
exit 1
2121
fi
2222

23-
eval "$(cs java --env --jvm temurin:17)"
23+
eval "$(cs java --env --jvm temurin:17 || cs java --env --jvm openjdk:1.17.0)"
2424

2525
exec /usr/bin/env bash "$DIR/millw" "$@"

modules/build/src/main/scala/scala/build/ConsoleBloopBuildClient.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ object ConsoleBloopBuildClient {
151151
private val red = Console.RED
152152
private val yellow = Console.YELLOW
153153

154-
private def getPrefix(severity: Severity) =
155-
if (severity == Severity.Error) s"[${red}error$reset] "
154+
def diagnosticPrefix(isError: Boolean): String =
155+
if (isError) s"[${red}error$reset] "
156156
else s"[${yellow}warn$reset] "
157157

158158
def printFileDiagnostic(
@@ -163,9 +163,7 @@ object ConsoleBloopBuildClient {
163163
val isWarningOrError = diag.getSeverity == bsp4j.DiagnosticSeverity.ERROR ||
164164
diag.getSeverity == bsp4j.DiagnosticSeverity.WARNING
165165
if (isWarningOrError) {
166-
val prefix =
167-
if (diag.getSeverity == bsp4j.DiagnosticSeverity.ERROR) s"[${red}error$reset] "
168-
else s"[${yellow}warn$reset] "
166+
val prefix = diagnosticPrefix(diag.getSeverity == bsp4j.DiagnosticSeverity.ERROR)
169167

170168
val line = (diag.getRange.getStart.getLine + 1).toString + ":"
171169
val col = (diag.getRange.getStart.getCharacter + 1).toString + ":"
@@ -217,7 +215,7 @@ object ConsoleBloopBuildClient {
217215
val isWarningOrError = true
218216
if (isWarningOrError) {
219217
val msgIt = message.linesIterator
220-
val prefix = getPrefix(severity)
218+
val prefix = diagnosticPrefix(severity == Severity.Error)
221219
out.println(prefix + (if (msgIt.hasNext) " " + msgIt.next() else ""))
222220
msgIt.foreach(line => out.println(prefix + line))
223221

0 commit comments

Comments
 (0)