Skip to content

Commit 11fdc77

Browse files
authored
Merge pull request #585 from scala-js/topic/scalafmt305
Upgrade scalafmt to 3.0.5
2 parents 45bdab5 + e5a9391 commit 11fdc77

File tree

12 files changed

+52
-54
lines changed

12 files changed

+52
-54
lines changed

.scalafmt.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 3.0.2
1+
version = 3.0.5
22
project.git = true
33
style = Scala.js
44
project.includeFilters = ["src/main/scala/org/scalajs/.*\\.scala"]

scalafix/src/main/scala/org/scalajs/dom/scalafix/DefaultFacadeArgs.scala

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class DefaultFacadeArgs extends SemanticRule("DefaultFacadeArgs") {
99
doc.tree.collect {
1010

1111
case Defn.Def(mods, _, _, paramss, _, body) if Util.isJsNative(body) =>
12-
1312
// https://github.com/scala-js/scala-js/issues/4553
1413
// `js.native` as default arg doesn't compile for top-level method facades.
1514
if (Util.isJSGlobal(mods)) {

scalafix/src/main/scala/org/scalajs/dom/scalafix/GenerateApiReport.scala

+20-19
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ class GenerateApiReport extends SemanticRule("GenerateApiReport") {
2525
case a: Defn.Object => process(a.mods, a.symbol, a.templ, ScopeType.Object)
2626
case a: Defn.Trait => process(a.mods, a.symbol, a.templ, ScopeType.Trait)
2727
case a: Pkg.Object => process(a.mods, a.symbol, a.templ, ScopeType.Object)
28-
case _ =>
28+
case _ =>
2929
}
3030

3131
Patch.empty
3232
}
3333

34-
private def process(parentMods: List[Mod], sym: Symbol, body: Template, typ: ScopeType)(implicit doc: SemanticDocument): Unit = {
34+
private def process(parentMods: List[Mod], sym: Symbol, body: Template, typ: ScopeType)(
35+
implicit doc: SemanticDocument): Unit = {
3536
// Skip non-public scopes
3637
val info = sym.info.get
3738
if (!info.isPublic && !info.isPackageObject)
@@ -41,10 +42,10 @@ class GenerateApiReport extends SemanticRule("GenerateApiReport") {
4142
_.filter {
4243
case Mod.Annot(Init(tpe, _, List(List(_, ver)))) if tpe.toString == "deprecated" =>
4344
set(
44-
ver match {
45-
case Lit.String(s) => s
46-
case term => term.toString
47-
}
45+
ver match {
46+
case Lit.String(s) => s
47+
case term => term.toString
48+
}
4849
)
4950
false
5051
case _ => true
@@ -54,10 +55,10 @@ class GenerateApiReport extends SemanticRule("GenerateApiReport") {
5455
var scopeDeprecatedVer = Option.empty[String]
5556
inspectAnnotationsFn(v => scopeDeprecatedVer = Some(v))(parentMods)
5657

57-
val parents = Util.parents(sym).iterator.map(Util.typeSymbol).toList
58+
val parents = Util.parents(sym).iterator.map(Util.typeSymbol).toList
5859
val domParents = parents.iterator.filter(isScalaJsDom).toSet
59-
val isJsType = parents.exists(isScalaJs)
60-
val s = state.register(sym, isJsType, typ, domParents, scopeDeprecatedVer)
60+
val isJsType = parents.exists(isScalaJs)
61+
val s = state.register(sym, isJsType, typ, domParents, scopeDeprecatedVer)
6162

6263
def letsSeeHowLazyWeCanBeLol(t: Tree): Unit = {
6364
// Skip non-public members
@@ -77,17 +78,17 @@ class GenerateApiReport extends SemanticRule("GenerateApiReport") {
7778
var deprecatedVer = Option.empty[String]
7879
val inspectAnnotations = inspectAnnotationsFn(v => deprecatedVer = Some(v))
7980
t2 match {
80-
case Decl.Def(mods, name, tparams, paramss, tpe) => t2 = Decl.Def(inspectAnnotations(mods), name, tparams, paramss, tpe)
81-
case Decl.Val(mods, pats, tpe) => t2 = Decl.Val(inspectAnnotations(mods), pats, tpe)
82-
case Decl.Var(mods, pats, tpe) => t2 = Decl.Var(inspectAnnotations(mods), pats, tpe)
83-
case Defn.Type(mods, names, params, tpe) => t2 = Defn.Type(inspectAnnotations(mods), names, params, tpe)
84-
case _ =>
81+
case Decl.Def(mods, name, tparams, paramss, tpe) =>
82+
t2 = Decl.Def(inspectAnnotations(mods), name, tparams, paramss, tpe)
83+
case Decl.Val(mods, pats, tpe) => t2 = Decl.Val(inspectAnnotations(mods), pats, tpe)
84+
case Decl.Var(mods, pats, tpe) => t2 = Decl.Var(inspectAnnotations(mods), pats, tpe)
85+
case Defn.Type(mods, names, params, tpe) => t2 = Defn.Type(inspectAnnotations(mods), names, params, tpe)
86+
case _ =>
8587
}
8688

8789
// Generate member desc
8890
val desc =
89-
t2
90-
.toString
91+
t2.toString
9192
.replace('\n', ' ')
9293
.replace("=", " = ")
9394
.replace("@inline ", "")
@@ -131,10 +132,10 @@ class GenerateApiReport extends SemanticRule("GenerateApiReport") {
131132
}
132133

133134
private def saveReport(): Unit = {
134-
val scalaVer = Util.scalaSeriesVer.replace('.', '_')
135+
val scalaVer = Util.scalaSeriesVer.replace('.', '_')
135136
val projectRoot = System.getProperty("user.dir")
136-
val reportFile = Paths.get(s"$projectRoot/api-reports/$scalaVer.txt")
137-
val api = state.result().iterator.map(_.stripPrefix("org/scalajs/dom/")).mkString("\n")
137+
val reportFile = Paths.get(s"$projectRoot/api-reports/$scalaVer.txt")
138+
val api = state.result().iterator.map(_.stripPrefix("org/scalajs/dom/")).mkString("\n")
138139

139140
val content =
140141
s"""|scala-js-dom API

scalafix/src/main/scala/org/scalajs/dom/scalafix/MutableState.scala

+9-13
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ final class MutableState {
1010

1111
private[this] val scopes = mutable.Map.empty[Symbol, Scope]
1212

13-
def register(sym : Symbol,
14-
isJsType : Boolean,
15-
scopeType : ScopeType,
16-
parents : Set[Symbol],
17-
deprecatedVer: Option[String]): Scope = synchronized {
13+
def register(sym: Symbol, isJsType: Boolean, scopeType: ScopeType, parents: Set[Symbol],
14+
deprecatedVer: Option[String]): Scope = synchronized {
1815
scopes.get(sym) match {
1916
case None =>
2017
val s = Scope(sym)(scopeType, parents)
@@ -70,11 +67,11 @@ final class MutableState {
7067
// Pass 2
7168
for (root <- scopes.valuesIterator) {
7269
val scopeName = root.symbol.value.stripSuffix("#").stripSuffix(".")
73-
val flagLang = if (root.isJsType) "J" else "S"
74-
val flagTyp = root.scopeType.id
75-
val flags = flagLang + flagTyp
76-
val prefix = s"$scopeName[$flags] "
77-
val scopeKey = s"$scopeName$sortHack[$flags"
70+
val flagLang = if (root.isJsType) "J" else "S"
71+
val flagTyp = root.scopeType.id
72+
val flags = flagLang + flagTyp
73+
val prefix = s"$scopeName[$flags] "
74+
val scopeKey = s"$scopeName$sortHack[$flags"
7875

7976
var membersFound = false
8077
for {
@@ -102,15 +99,14 @@ object MutableState {
10299
var global: MutableState = null
103100

104101
sealed abstract class ScopeType(final val id: String)
102+
105103
object ScopeType {
106104
case object Class extends ScopeType("C")
107105
case object Trait extends ScopeType("T")
108106
case object Object extends ScopeType("O")
109107
}
110108

111-
final case class Scope(symbol: Symbol)
112-
(val scopeType: ScopeType,
113-
val parents: Set[Symbol]) {
109+
final case class Scope(symbol: Symbol)(val scopeType: ScopeType, val parents: Set[Symbol]) {
114110

115111
private[MutableState] val directMembers = mutable.Set.empty[Member]
116112
private[MutableState] var isJsType = false

scalafix/src/main/scala/org/scalajs/dom/scalafix/Util.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object Util {
2727
def isJSGlobal(mods: List[Mod]): Boolean =
2828
mods.exists {
2929
case Mod.Annot(Init(Type.Name("JSGlobal"), _, _)) => true
30-
case _ => false
30+
case _ => false
3131
}
3232

3333
def isJsNative(t: Term): Boolean = {
@@ -95,10 +95,10 @@ object Util {
9595

9696
def typeSymbol(t: SemanticType): Symbol =
9797
t match {
98-
case x: TypeRef => x.symbol
99-
case x: SingleType => x.symbol
100-
case x: ThisType => x.symbol
101-
case x: SuperType => x.symbol
98+
case x: TypeRef => x.symbol
99+
case x: SingleType => x.symbol
100+
case x: ThisType => x.symbol
101+
case x: SuperType => x.symbol
102102
// case x: ConstantType => xxx // (constant) =>
103103
// case x: IntersectionType => xxx // (types) =>
104104
// case x: UnionType => xxx // (types) =>
@@ -110,8 +110,7 @@ object Util {
110110
// case x: ByNameType => xxx // (tpe) =>
111111
// case x: RepeatedType => xxx // (tpe) =>
112112
// case NoType => Symbol.None
113-
case _ => Symbol.None
113+
case _ => Symbol.None
114114
}
115115

116-
117-
}
116+
}

tests-shared/src/main/scala/org/scalajs/dom/tests/shared/AsyncTesting.scala

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ object AsyncTesting {
3434
}
3535

3636
implicit final class AsyncFutureOps[A](private val self: Future[A]) extends AnyVal {
37+
3738
def tap(f: A => Any): Future[A] =
3839
self.map { a => f(a); a }
3940

tests-shared/src/main/scala/org/scalajs/dom/tests/shared/IdbTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object IdbTest {
7373

7474
for {
7575
john <- getFirstName(getJohn)
76-
bob <- getFirstName(getBob)
76+
bob <- getFirstName(getBob)
7777
} yield {
7878
assertEquals("John", john)
7979
assertEquals("Bob", bob)

tests-shared/src/main/scala/org/scalajs/dom/tests/shared/SharedTests.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ trait SharedTests {
1414

1515
// This tests that ops are always implicitly available, no imports required
1616
@Test final def DOMTokenListOpsTest(): Unit = {
17-
org.scalajs.dom.document.querySelectorAll("*")
17+
org.scalajs.dom.document
18+
.querySelectorAll("*")
1819
.iterator
1920
.collect { case e: org.scalajs.dom.html.Element => e }
2021
.map(_.classList.mkString)

tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/Client.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import scala.util.Success
88
final class Client(worker: Worker) {
99
import Protocol._
1010

11-
private var preInit = new js.Array[Message]
11+
private var preInit = new js.Array[Message]
1212
private var promises = new js.Array[Promise[String]]
1313

1414
worker.onmessage = (e: MessageEvent) => {
@@ -22,8 +22,8 @@ final class Client(worker: Worker) {
2222

2323
def send(cmd: WebWorkerCmd): Future[String] = {
2424
val id = promises.length
25-
val p = Promise[String]()
26-
val m = Message(id, cmd.id)
25+
val p = Promise[String]()
26+
val m = Message(id, cmd.id)
2727
promises.push(p)
2828
if (preInit eq null)
2929
worker.postMessage(m)

tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/Protocol.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.scalajs.js
44

55
object Protocol {
66

7-
type MsgId = Int
7+
type MsgId = Int
88
type Message = js.Tuple2[MsgId, String]
99

1010
def Message(id: MsgId, data: String): Message =

tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/Server.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ object Server extends ServerResponses {
1010
val ww = DedicatedWorkerGlobalScope.self
1111

1212
ww.onmessage = (e: MessageEvent) => {
13-
val msgIn = e.data.asInstanceOf[Message]
14-
val id = msgIn._1
15-
val cmdId = msgIn._2
16-
val cmd = WebWorkerCmd.byId(cmdId)
13+
val msgIn = e.data.asInstanceOf[Message]
14+
val id = msgIn._1
15+
val cmdId = msgIn._2
16+
val cmd = WebWorkerCmd.byId(cmdId)
1717
respond(cmd).onComplete { t =>
1818
val output = t.getOrElse(t.failed.get.toString)
1919
val msgOut = Message(id, output)

tests-webworker/src/main/scala/org/scalajs/dom/tests/webworker/WebWorkerTests.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ sealed abstract class WebWorkerCmd {
1313

1414
object WebWorkerCmd {
1515

16-
case object SayHello extends WebWorkerCmd
16+
case object SayHello extends WebWorkerCmd
1717
case object TestConsole extends WebWorkerCmd
18-
case object TestIdb extends WebWorkerCmd
18+
case object TestIdb extends WebWorkerCmd
1919

2020
def byId(id: String): WebWorkerCmd =
2121
id match {
@@ -55,6 +55,7 @@ trait ServerResponses {
5555
Future(s)
5656

5757
private implicit class AsyncOps(r: AsyncResult) {
58+
5859
def andReturn(s: String): Future[String] =
5960
r.map { t =>
6061
t.get

0 commit comments

Comments
 (0)