From b80eb0650d0cdbd9c088fbda83721c1525b69a54 Mon Sep 17 00:00:00 2001 From: ragnar Date: Tue, 14 Jan 2025 16:50:36 +0100 Subject: [PATCH] fmt braces --- .../scala/channels/webnativewebsockets/WSConnector.scala | 3 ++- Modules/Channels/jvm/src/main/scala/channels/UDP.scala | 3 ++- .../ex201x/reswingexamples/dropdown/DropdownSample1.scala | 3 ++- .../ex201x/reswingexamples/dropdown/DropdownSample2.scala | 3 ++- .../ex201x/reswingexamples/dropdown/DropdownSample2b.scala | 3 ++- .../millgame/versions/signals/MillGame.scala | 3 ++- .../main/scala/ex201x/reswingexamples/reader/gui/GUI.scala | 3 ++- .../src/main/scala/loreCompilerPlugin/sourceExamples.scala | 3 ++- .../src/main/scala/loreCompilerPlugin/CompilerPlugin.scala | 6 ++++-- Modules/Lore/shared/src/main/scala/lore/backends/Util.scala | 3 ++- Modules/Lore/shared/src/main/scala/lore/optics/Optics.scala | 6 ++++-- .../rdts/datatypes/experiments/protocols/MultiPaxos.scala | 3 ++- .../src/main/scala/reactives/scheduler/CalculusLike.scala | 3 ++- .../src/main/scala/reactives/scheduler/TopoBundle.scala | 6 ++++-- .../lofi_acl/sync/acl/monotonic/FilteringAntiEntropy.scala | 3 ++- 15 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Modules/Channels/js/src/main/scala/channels/webnativewebsockets/WSConnector.scala b/Modules/Channels/js/src/main/scala/channels/webnativewebsockets/WSConnector.scala index 240b6df1b..4ee70315b 100644 --- a/Modules/Channels/js/src/main/scala/channels/webnativewebsockets/WSConnector.scala +++ b/Modules/Channels/js/src/main/scala/channels/webnativewebsockets/WSConnector.scala @@ -28,7 +28,7 @@ object WebsocketConnect { def connect(url: String): LatentConnection[MessageBuffer] = new LatentConnection { - override def prepare(incomingHandler: Receive[MessageBuffer]): Async[Abort, Connection[MessageBuffer]] = + override def prepare(incomingHandler: Receive[MessageBuffer]): Async[Abort, Connection[MessageBuffer]] = { Async.fromCallback { println(s"preparing connection") @@ -71,5 +71,6 @@ object WebsocketConnect { socket.close() Async.handler.fail(new WebsocketException("Websocket failed to connect")) } + } } } diff --git a/Modules/Channels/jvm/src/main/scala/channels/UDP.scala b/Modules/Channels/jvm/src/main/scala/channels/UDP.scala index da35d39af..1ab323aae 100644 --- a/Modules/Channels/jvm/src/main/scala/channels/UDP.scala +++ b/Modules/Channels/jvm/src/main/scala/channels/UDP.scala @@ -26,7 +26,7 @@ class UDPPseudoConnection( executionContext: ExecutionContext, initializeOutbound: Async[Any, SocketAddress], ) extends LatentConnection[MessageBuffer] { - override def prepare(receiver: Receive[MessageBuffer]): Async[Abort, Connection[MessageBuffer]] = + override def prepare(receiver: Receive[MessageBuffer]): Async[Abort, Connection[MessageBuffer]] = { Async.fromCallback[Connection[MessageBuffer]] { val datagramSocket = socketFactory() @@ -78,6 +78,7 @@ class UDPPseudoConnection( case Failure(exception) => connectionSuccess.fail(exception) } + } } diff --git a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample1.scala b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample1.scala index e9f11dbb1..f135346d3 100644 --- a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample1.scala +++ b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample1.scala @@ -7,7 +7,7 @@ import scala.swing.{BoxPanel, FlowPanel, Label, MainFrame, Orientation, SimpleSw object DropdownSample1 extends SimpleSwingApplication { - def top = + def top = { new MainFrame { val col1 = new ReTextField(text = "Berlin", columns = 30) @@ -78,4 +78,5 @@ object DropdownSample1 extends SimpleSwingApplication { } } } + } } diff --git a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample2.scala b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample2.scala index ba0144eb5..c7735f920 100644 --- a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample2.scala +++ b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample2.scala @@ -7,7 +7,7 @@ import scala.swing.{BoxPanel, FlowPanel, Label, MainFrame, Orientation, SimpleSw object DropdownSample2 extends SimpleSwingApplication { - def top = + def top = { new MainFrame { /* This version "artificially" introduces a Signal[List[Signal[String]] to illustrate higher @@ -71,4 +71,5 @@ object DropdownSample2 extends SimpleSwingApplication { } } } + } } diff --git a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample2b.scala b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample2b.scala index a08608029..a51983de3 100644 --- a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample2b.scala +++ b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/dropdown/DropdownSample2b.scala @@ -7,7 +7,7 @@ import scala.swing.{BoxPanel, FlowPanel, Label, MainFrame, Orientation, SimpleSw object DropdownSample2b extends SimpleSwingApplication { - def top = + def top = { new MainFrame { /* This version "artificially" introduces a Signal[List[Signal[String]] to illustrate higher @@ -77,4 +77,5 @@ object DropdownSample2b extends SimpleSwingApplication { } } } + } } diff --git a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/millgame/versions/signals/MillGame.scala b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/millgame/versions/signals/MillGame.scala index 9c988bdf6..7b4d489da 100644 --- a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/millgame/versions/signals/MillGame.scala +++ b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/millgame/versions/signals/MillGame.scala @@ -94,7 +94,7 @@ class MillGame { remainCount.transform(currentCount => currentCount.updated(player, currentCount(player) - 1)) } - def playerInput(i: SlotIndex): Boolean = + def playerInput(i: SlotIndex): Boolean = { state match { case PlaceStone(player) => @@ -146,4 +146,5 @@ class MillGame { case _ => false } + } } diff --git a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/reader/gui/GUI.scala b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/reader/gui/GUI.scala index 70a70e3a3..2f87448d1 100644 --- a/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/reader/gui/GUI.scala +++ b/Modules/Examples/Misc JVM/src/main/scala/ex201x/reswingexamples/reader/gui/GUI.scala @@ -26,7 +26,7 @@ class GUI( val refreshCheckbox = new ReCheckBox("auto refresh", selected = true) def refreshAllowed = refreshCheckbox.selected - def top = + def top = { new MainFrame { val quitAction = swing.Action("Quit") { quit() } val urlDialogAction = swing.Action("Add url") { @@ -135,4 +135,5 @@ class GUI( location = new Point((screenSize.width - framewidth) / 2, (screenSize.height - frameheight) / 2) } } + } } diff --git a/Modules/LoRe Compiler Plugin/examples/src/main/scala/loreCompilerPlugin/sourceExamples.scala b/Modules/LoRe Compiler Plugin/examples/src/main/scala/loreCompilerPlugin/sourceExamples.scala index 9d71d25e2..aeb315974 100644 --- a/Modules/LoRe Compiler Plugin/examples/src/main/scala/loreCompilerPlugin/sourceExamples.scala +++ b/Modules/LoRe Compiler Plugin/examples/src/main/scala/loreCompilerPlugin/sourceExamples.scala @@ -4,7 +4,7 @@ import lore.dsl.* import reactives.default.Var as Source object sourceExamplesObject: - def sourceExamplesFunction(): Unit = + def sourceExamplesFunction(): Unit = { // ========= Non-Source Values to use in below tests ========= val integerLiteral: Int = 1 val integerExpression1: Int = 1 + 2 @@ -76,5 +76,6 @@ object sourceExamplesObject: val boolReferenceNumeralBinaryOpSource1: Source[Boolean] = Source(integerLiteral >= integerLiteral + 1) val boolReferenceNumeralBinaryOpSource2: Source[Boolean] = Source(1 != integerLiteral) val boolReferenceNumeralBinaryOpSource3: Source[Boolean] = Source(integerLiteral <= 2) + } end sourceExamplesFunction end sourceExamplesObject diff --git a/Modules/LoRe Compiler Plugin/src/main/scala/loreCompilerPlugin/CompilerPlugin.scala b/Modules/LoRe Compiler Plugin/src/main/scala/loreCompilerPlugin/CompilerPlugin.scala index 01536364c..f09044488 100644 --- a/Modules/LoRe Compiler Plugin/src/main/scala/loreCompilerPlugin/CompilerPlugin.scala +++ b/Modules/LoRe Compiler Plugin/src/main/scala/loreCompilerPlugin/CompilerPlugin.scala @@ -85,7 +85,7 @@ class LoRePhase extends PluginPhase: */ private def buildLoreRhsTerm(tree: tpd.LazyTree, indentLevel: Integer = 0, operandSide: String = "")(using Context - ): Term = + ): Term = { tree match case Literal(Constant(num: Int)) => // Basic int values like 0 or 1 logRhsInfo(indentLevel, operandSide, "literal integer value", num.toString) @@ -345,9 +345,10 @@ class LoRePhase extends PluginPhase: s"${"\t".repeat(indentLevel)}Unsupported RHS form used:\n${"\t".repeat(indentLevel)}$tree" ) TVar("") + } end buildLoreRhsTerm - override def transformValDef(tree: tpd.ValDef)(using ctx: Context): tpd.Tree = + override def transformValDef(tree: tpd.ValDef)(using ctx: Context): tpd.Tree = { var newLoreTerm: Option[Term] = None // Placeholder, value is defined in below individual cases to avoid code dupe tree match @@ -414,5 +415,6 @@ class LoRePhase extends PluginPhase: val newList: List[Term] = List(loreTerm) loreTerms = loreTerms.updated((tree.source, ctx.owner), newList) tree // Return the original tree to further compiler phases + } end transformValDef end LoRePhase diff --git a/Modules/Lore/shared/src/main/scala/lore/backends/Util.scala b/Modules/Lore/shared/src/main/scala/lore/backends/Util.scala index 0bfeeb701..b635f6363 100644 --- a/Modules/Lore/shared/src/main/scala/lore/backends/Util.scala +++ b/Modules/Lore/shared/src/main/scala/lore/backends/Util.scala @@ -116,7 +116,7 @@ def traverseFromNode[A <: Term]( ): A = { // apply transformer to start node val transformed = transformer(node) - val result = + val result = { // if node has children, traverse transformed match { // basic terms @@ -254,6 +254,7 @@ def traverseFromNode[A <: Term]( // TFalse | TString(_) | TViperImport(_) => // transformed } + } try result.asInstanceOf[A] catch { case c: ClassCastException => diff --git a/Modules/Lore/shared/src/main/scala/lore/optics/Optics.scala b/Modules/Lore/shared/src/main/scala/lore/optics/Optics.scala index 4c3b63733..ab0068aee 100644 --- a/Modules/Lore/shared/src/main/scala/lore/optics/Optics.scala +++ b/Modules/Lore/shared/src/main/scala/lore/optics/Optics.scala @@ -143,10 +143,10 @@ val Subtree: Traversal[Term, Term] = } } -val children: Fold[Term, Term] = +val children: Fold[Term, Term] = { new Fold[Term, Term] { - def foldMap[M: Monoid](f: Term => M)(t: Term): M = + def foldMap[M: Monoid](f: Term => M)(t: Term): M = { t match { case _: (TViperImport | TArgT | TVar | TTypeAl | TNum | TTrue | TFalse | TString) => @@ -192,7 +192,9 @@ val children: Fold[Term, Term] = case TFunC(name, args, sourcePos) => Monoid[M].combineAll(args.toList.map(f)) } + } } +} // new Traversal[Term, Term] { // def modifyA[F[_]: Monad](f: Term => F[Term])(s: Term): F[Term] = diff --git a/Modules/RDTs/src/main/scala/rdts/datatypes/experiments/protocols/MultiPaxos.scala b/Modules/RDTs/src/main/scala/rdts/datatypes/experiments/protocols/MultiPaxos.scala index c0696693e..0c2161169 100644 --- a/Modules/RDTs/src/main/scala/rdts/datatypes/experiments/protocols/MultiPaxos.scala +++ b/Modules/RDTs/src/main/scala/rdts/datatypes/experiments/protocols/MultiPaxos.scala @@ -51,7 +51,7 @@ case class MultiPaxos[A]( )) ) - def upkeep(using LocalUid, Participants): MultiPaxos[A] = + def upkeep(using LocalUid, Participants): MultiPaxos[A] = { // perform upkeep in Paxos val deltaPaxos = currentPaxos.upkeep() val newPaxos = currentPaxos.merge(deltaPaxos) @@ -110,6 +110,7 @@ case class MultiPaxos[A]( case MultipaxosPhase.Idle => // nothing to do MultiPaxos() + } object MultiPaxos: given [A]: Bottom[MultiPaxosRound[A]] = Bottom.provide(MultiPaxosRound()) diff --git a/Modules/Reactives/shared/src/main/scala/reactives/scheduler/CalculusLike.scala b/Modules/Reactives/shared/src/main/scala/reactives/scheduler/CalculusLike.scala index a1a6c4e4d..2adf58f56 100644 --- a/Modules/Reactives/shared/src/main/scala/reactives/scheduler/CalculusLike.scala +++ b/Modules/Reactives/shared/src/main/scala/reactives/scheduler/CalculusLike.scala @@ -92,7 +92,7 @@ object CalculusLike { override def forceNewTransaction[R]( initialWrites: Set[ReSource.of[State]], admissionPhase: AdmissionTicket[State] => R - ): R = + ): R = { synchronized { // some broken user code may start a new transaction during an ongoing one // this is not supported by this propagation algorithm, @@ -139,6 +139,7 @@ object CalculusLike { idle = true } } + } override private[reactives] def singleReadValueOnce[A](reactive: ReadAs.of[State, A]): A = reactive.read(reactive.state.value) } diff --git a/Modules/Reactives/shared/src/main/scala/reactives/scheduler/TopoBundle.scala b/Modules/Reactives/shared/src/main/scala/reactives/scheduler/TopoBundle.scala index efec8d33f..29c00e61b 100644 --- a/Modules/Reactives/shared/src/main/scala/reactives/scheduler/TopoBundle.scala +++ b/Modules/Reactives/shared/src/main/scala/reactives/scheduler/TopoBundle.scala @@ -101,12 +101,12 @@ trait TopoBundle { def beforeCleanupHook(all: Seq[ReSource], initialWrites: Set[ReSource]): Unit = () - override def forceNewTransaction[R](initialWrites: Set[ReSource], admissionPhase: AdmissionTicket[State] => R): R = + override def forceNewTransaction[R](initialWrites: Set[ReSource], admissionPhase: AdmissionTicket[State] => R): R = { synchronized { if !idle then throw new IllegalStateException("Scheduler is not reentrant") idle = false val afterCommitObservers: ListBuffer[Observation] = ListBuffer.empty - val res = + val res = { try { val creation = new TopoInitializer(afterCommitObservers) val transaction = TopoTransaction(creation) @@ -154,9 +154,11 @@ trait TopoBundle { } finally { idle = true } + } afterCommitObservers.foreach(_.execute()) res } + } override private[reactives] def singleReadValueOnce[A](reactive: ReadAs.of[State, A]): A = { reactive.read(reactive.state.value) diff --git a/Modules/Replication/jvm/src/main/scala/lofi_acl/sync/acl/monotonic/FilteringAntiEntropy.scala b/Modules/Replication/jvm/src/main/scala/lofi_acl/sync/acl/monotonic/FilteringAntiEntropy.scala index 62939b409..750ff5d3b 100644 --- a/Modules/Replication/jvm/src/main/scala/lofi_acl/sync/acl/monotonic/FilteringAntiEntropy.scala +++ b/Modules/Replication/jvm/src/main/scala/lofi_acl/sync/acl/monotonic/FilteringAntiEntropy.scala @@ -434,7 +434,7 @@ class FilteringAntiEntropy[RDT]( private val antiEntropyThread = new Thread { private val rand = Random() - override def run(): Unit = + override def run(): Unit = { while !stopped do { try { // Execute every 1 to 3 seconds, avoiding synchronization of these requests among replicas. @@ -480,6 +480,7 @@ class FilteringAntiEntropy[RDT]( val _ = connectionManager.send(remote, msg) } } + } } antiEntropyThread.start() }