Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormatWriter: FormatLocations.iterate to foreach #3606

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading