Skip to content

Commit

Permalink
FormatWriter: FormatLocations.iterate to foreach
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Aug 11, 2023
1 parent 3dcc7d5 commit c56ec1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FormatWriter(formatOps: FormatOps) {
val locations = getFormatLocations(state)
styleMap.init.runner.event(FormatEvent.Written(locations))

locations.iterate.foreach { entry =>
locations.foreach { entry =>
val location = entry.curr
implicit val style: ScalafmtConfig = location.style
val formatToken = location.formatToken
Expand Down Expand Up @@ -424,9 +424,9 @@ class FormatWriter(formatOps: FormatOps) {

val tokenAligns: Map[Int, Int] = alignmentTokens

def iterate: Iterator[Entry] = {
def foreach(f: Entry => Unit): Unit = {
val iterator = Iterator.range(0, locations.length).map(new Entry(_))
iterator.filter(_.curr.isNotRemoved)
iterator.filter(_.curr.isNotRemoved).foreach(f)
}

private def getAlign(tok: FormatToken, alignOffset: Int = 0): Int =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ trait HasTests extends FormatAssertions {

def getFormatOutput(debug: Debug): Array[FormatOutput] = {
val builder = mutable.ArrayBuilder.make[FormatOutput]
debug.locations.iterate.foreach { entry =>
debug.locations.foreach { entry =>
val token = entry.curr.formatToken
builder += FormatOutput(
token.left.syntax + entry.getWhitespace(0),
Expand Down

0 comments on commit c56ec1e

Please sign in to comment.