Skip to content
Merged
Changes from all commits
Commits
File filter

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 @@ -71,36 +71,4 @@ object PreprocessedSource {
ScopePath.fromPath(path)
def directivesPositions: None.type = None
}

private def index(s: PreprocessedSource): Int =
s match {
case _: NoSourceCode => 0
case _: InMemory => 1
case _: OnDisk => 2
}

implicit val ordering: Ordering[PreprocessedSource] =
new Ordering[PreprocessedSource] {
def compare(a: PreprocessedSource, b: PreprocessedSource): Int = {
val aIdx = index(a)
val bIdx = index(b)
val idxCmp = aIdx.compare(bIdx)
if (idxCmp == 0)
(a, b) match {
case (a0: NoSourceCode, b0: NoSourceCode) =>
a0.path.toString.compareTo(b0.path.toString)
case (a0: InMemory, b0: InMemory) =>
(a0.reportingPath, b0.reportingPath) match {
case (Left(ap), Left(bp)) => ap.compareTo(bp)
case (Left(_), Right(_)) => -1
case (Right(ap), Right(bp)) => ap.toString.compareTo(bp.toString)
case (Right(_), Left(_)) => 1
}
case (a0: OnDisk, b0: OnDisk) => a0.path.toString.compareTo(b0.path.toString)
case _ => ???
}
else idxCmp
}
}

}