Skip to content

Commit

Permalink
Reformat with scalafmt 3.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
scala-steward committed Jan 23, 2022
1 parent 87a6b60 commit bdd6a0d
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ object Binding extends JSBinding:
def apply[A](a: A)(using Applicative[DefaultFuture]): Binding[A] =
CovariantStreamT.pure(a)

def empty[A](using Applicative[DefaultFuture]): Binding[A] = StreamT.empty[DefaultFuture, A]
def empty[A](using Applicative[DefaultFuture]): Binding[A] =
StreamT.empty[DefaultFuture, A]

private[binding] final class Pipe[A] extends (() => Binding[A]):
private[binding] val promise = Promise[StreamT.Yield[A, Binding[A]]]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ object CovariantStreamT:
summon

extension [M[_], A](binding: CovariantStreamT[M, A])

def mergeWith(that: CovariantStreamT[M, A])(using
Nondeterminism[M]
): CovariantStreamT[M, A] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,17 @@ object PatchStreamT extends PatchStreamT.LowPriority0:
* The measurement of the [[scalaz.FingerTree]] is the size.
* @example
* Given a [[PatchStreamT]] created from an iterable,
* {{{
* {{{
* import scala.concurrent.Future
* import scalaz.std.scalaFuture.given
* val bindingSeq = PatchStreamT.fromIterable[Future, String](Seq("foo", "bar", "baz"))
* }}}
* when taking [[snapshots]],
* {{{
* }}}
* when taking [[snapshots]],
* {{{
* val snapshots = bindingSeq.snapshots
* }}}
* then it should contains an empty value and an initial value
* {{{
* }}}
* then it should contains an empty value and an initial value
* {{{
* import com.thoughtworks.dsl.keywords.Await
* import com.thoughtworks.dsl.macros.Reset.Default.*
* `*`[Future] {
Expand All @@ -342,7 +342,7 @@ object PatchStreamT extends PatchStreamT.LowPriority0:
* initial.toList should be(List("foo", "bar", "baz"))
* }
* }
* }}}
* }}}
*/
def snapshots(using
Applicative[M]
Expand Down Expand Up @@ -371,11 +371,11 @@ object PatchStreamT extends PatchStreamT.LowPriority0:
*
* @example
* Given a source [[PatchStreamT]] from an iterable,
* {{{
* {{{
* import scala.concurrent.Future
* import scalaz.std.scalaFuture.given
* val bindingSeq = PatchStreamT.fromIterable[Future, String](Seq("foo", "bar"))
* }}}
* }}}
*
* when flat-mapping it to more [[PatchStreamT]],
* {{{
Expand Down
2 changes: 1 addition & 1 deletion StreamT/js/src/main/scala/java/lang/ref/Reference.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package java.lang.ref

abstract class Reference[T] {
def get(): T
}
}
3 changes: 2 additions & 1 deletion StreamT/js/src/main/scala/java/lang/ref/WeakReference.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package java.lang.ref
import scala.scalajs.js

class WeakReference[T] private (jsWeakRef: js.WeakRef[T]) extends Reference[T]() {
class WeakReference[T] private (jsWeakRef: js.WeakRef[T])
extends Reference[T]() {
def this(referent: T) = this(new js.WeakRef[T](referent))
def get(): T = {
val referent = jsWeakRef.deref()
Expand Down
2 changes: 1 addition & 1 deletion StreamT/shared/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ libraryDependencies += "org.scalaz" %%% "scalaz-core" % "7.4.0-M10"

libraryDependencies += "com.thoughtworks.dsl" %%% "dsl" % "2.0.0-M2+265-3c2f0891"

scalacOptions += "-Ykind-projector"
scalacOptions += "-Ykind-projector"
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ private[binding] object StreamT:
export scalaz.StreamT.*

extension [M[_], A](fa: StreamT[M, A])
private[binding] def stepMap[B](f: Step[A, StreamT[M, A]] => Step[B, StreamT[M, B]])(
implicit M: Functor[M]
private[binding] def stepMap[B](
f: Step[A, StreamT[M, A]] => Step[B, StreamT[M, B]]
)(implicit
M: Functor[M]
): StreamT[M, B] = StreamT(M.map(fa.step)(f))

def memoize(implicit m: Functor[M]): StreamT[M, A] = stepMap {
Expand All @@ -50,4 +52,4 @@ private[binding] object StreamT:
case Done() =>
M.point(Done())
})
end extension
end extension
165 changes: 83 additions & 82 deletions html/src/main/scala/com/thoughtworks/binding/html/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,31 +135,83 @@ private[binding] object Macros:
,
null
)
private var isProcessingCharacters = false
private var isProcessingCharacters = false
override def characters(text: XMLString, augs: Augmentations): Unit =
if isProcessingCharacters then super.characters(text, augs)
else
isProcessingCharacters = true
try if augs == null then super.characters(text, augs)
else
val htmlEventInfo =
augs.getItem(AUGMENTATIONS).asInstanceOf[HTMLEventInfo]
val beginCharacterOffset = htmlEventInfo.getBeginCharacterOffset
val endCharacterOffset = htmlEventInfo.getEndCharacterOffset
val beginSearchResult =
partOffsets.search(beginCharacterOffset)
val endSearchResult =
partOffsets.search(endCharacterOffset)
val beginIndex = beginSearchResult.insertionPoint
val endIndex = endSearchResult.insertionPoint
if beginIndex == endIndex || (beginIndex % 2 == 0 && endIndex == beginIndex + 1) then
super.characters(text, augs)
try
if augs == null then super.characters(text, augs)
else
def partLoop(index: Int): Unit =
assert(index % 2 == 0)
endSearchResult match {
case Searching.InsertionPoint(`endIndex`)
if endIndex == index + 1 =>
val htmlEventInfo =
augs.getItem(AUGMENTATIONS).asInstanceOf[HTMLEventInfo]
val beginCharacterOffset = htmlEventInfo.getBeginCharacterOffset
val endCharacterOffset = htmlEventInfo.getEndCharacterOffset
val beginSearchResult =
partOffsets.search(beginCharacterOffset)
val endSearchResult =
partOffsets.search(endCharacterOffset)
val beginIndex = beginSearchResult.insertionPoint
val endIndex = endSearchResult.insertionPoint
if beginIndex == endIndex || (beginIndex % 2 == 0 && endIndex == beginIndex + 1)
then super.characters(text, augs)
else
def partLoop(index: Int): Unit =
assert(index % 2 == 0)
endSearchResult match {
case Searching.InsertionPoint(`endIndex`)
if endIndex == index + 1 =>
fParserConfiguration
.asInstanceOf[HTMLConfiguration]
.evaluateInputSource(
XMLInputSource(
null,
null,
null,
StringReader(
html.substring(
partOffsets(index),
endCharacterOffset
)
),
null
)
)
case _ =>
fParserConfiguration
.asInstanceOf[HTMLConfiguration]
.evaluateInputSource(
XMLInputSource(
null,
null,
null,
StringReader(
parts(index / 2)
),
null
)
)
argLoop(index + 1)
}
end partLoop

def argLoop(index: Int): Unit =
assert(index % 2 == 1)
if (endIndex > index) {
val comment = document.createComment("")
comment.setUserData(
ElementArgumentUserDataKey,
index / 2,
null
)
fCurrentNode.appendChild(comment)
partLoop(index + 1)
}
end argLoop

beginSearchResult match
case Searching.InsertionPoint(`beginIndex`)
if beginIndex % 2 == 1 =>
fParserConfiguration
.asInstanceOf[HTMLConfiguration]
.evaluateInputSource(
Expand All @@ -169,71 +221,20 @@ private[binding] object Macros:
null,
StringReader(
html.substring(
partOffsets(index),
endCharacterOffset
beginCharacterOffset,
partOffsets(beginIndex)
)
),
null
)
)
argLoop(beginIndex)
case Searching.Found(`beginIndex`) if beginIndex % 2 == 1 =>
argLoop(beginIndex)
case Searching.Found(`beginIndex`) if beginIndex % 2 == 0 =>
partLoop(beginIndex)
case _ =>
fParserConfiguration
.asInstanceOf[HTMLConfiguration]
.evaluateInputSource(
XMLInputSource(
null,
null,
null,
StringReader(
parts(index / 2)
),
null
)
)
argLoop(index + 1)
}
end partLoop

def argLoop(index: Int): Unit =
assert(index % 2 == 1)
if (endIndex > index) {
val comment = document.createComment("")
comment.setUserData(
ElementArgumentUserDataKey,
index / 2,
null
)
fCurrentNode.appendChild(comment)
partLoop(index + 1)
}
end argLoop

beginSearchResult match
case Searching.InsertionPoint(`beginIndex`)
if beginIndex % 2 == 1 =>
fParserConfiguration
.asInstanceOf[HTMLConfiguration]
.evaluateInputSource(
XMLInputSource(
null,
null,
null,
StringReader(
html.substring(
beginCharacterOffset,
partOffsets(beginIndex)
)
),
null
)
)
argLoop(beginIndex)
case Searching.Found(`beginIndex`) if beginIndex % 2 == 1 =>
argLoop(beginIndex)
case Searching.Found(`beginIndex`) if beginIndex % 2 == 0 =>
partLoop(beginIndex)
case _ =>
report.error("Unexpected text: " + text)
report.error("Unexpected text: " + text)
finally isProcessingCharacters = false
end characters
parser.parse(InputSource(StringReader(html)), fragment)
Expand Down Expand Up @@ -426,9 +427,9 @@ private[binding] object Macros:
case null =>
Nil
case attributeBindings =>
for
(qName: QName, argExprs(anyAttributeValueExpr)) <- attributeBindings
.asInstanceOf[Iterable[_]]
for (qName: QName, argExprs(anyAttributeValueExpr)) <-
attributeBindings
.asInstanceOf[Iterable[_]]
yield anyAttributeValueExpr.asTerm.tpe.asType match
case '[attributeType] =>
val attributeValueExpr =
Expand Down

0 comments on commit bdd6a0d

Please sign in to comment.