-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split: keep 2 instances of FileLine, for debugging
- Loading branch information
Showing
5 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FileLineStack.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.scalafmt.internal | ||
|
||
import org.scalameta.FileLine | ||
|
||
class FileLineStack private ( | ||
val fileLineHead: FileLine, | ||
val fileLineLast: FileLine, | ||
) extends Ordered[FileLineStack] { | ||
override def toString: String = s"$fileLineHead->$fileLineLast" | ||
|
||
def forThisLine(implicit | ||
file: sourcecode.File, | ||
line: sourcecode.Line, | ||
): FileLineStack = new FileLineStack( | ||
fileLineHead = fileLineHead, | ||
fileLineLast = FileLine.generate, | ||
) | ||
|
||
override def compare(that: FileLineStack): Int = Integer | ||
.compare(this.fileLineHead.line.value, that.fileLineHead.line.value) | ||
} | ||
|
||
object FileLineStack { | ||
implicit def generate(implicit | ||
file: sourcecode.File, | ||
line: sourcecode.Line, | ||
fileLineHead: FileLine, | ||
): FileLineStack = new FileLineStack(fileLineHead, FileLine.generate) | ||
|
||
def nextLine(implicit fl: FileLine): FileLine = { | ||
val line = fl.line | ||
new FileLine(fl.file, line.copy(value = line.value + 1)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters