Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (35 sloc) 1.38 KB
package sbt
package inc
import xsbti.Problem
import java.io.File
trait SourceInfo
{
def reportedProblems: Seq[Problem]
def unreportedProblems: Seq[Problem]
}
trait SourceInfos
{
def ++(o: SourceInfos): SourceInfos
def add(file: File, info: SourceInfo): SourceInfos
def --(files: Iterable[File]): SourceInfos
def groupBy[K](f: (File) => K): Map[K, SourceInfos]
def get(file: File): SourceInfo
def allInfos: Map[File, SourceInfo]
}
object SourceInfos
{
def empty: SourceInfos = make(Map.empty)
def make(m: Map[File, SourceInfo]): SourceInfos = new MSourceInfos(m)
val emptyInfo: SourceInfo = makeInfo(Nil, Nil)
def makeInfo(reported: Seq[Problem], unreported: Seq[Problem]): SourceInfo =
new MSourceInfo(reported, unreported)
}
private final class MSourceInfos(val allInfos: Map[File, SourceInfo]) extends SourceInfos
{
def ++(o: SourceInfos) = new MSourceInfos(allInfos ++ o.allInfos)
def --(sources: Iterable[File]) = new MSourceInfos(allInfos -- sources)
def groupBy[K](f: (File) => K): Map[K, SourceInfos] = allInfos.groupBy(item => f(item._1)) map { group => (group._1, new MSourceInfos(group._2)) }
def add(file: File, info: SourceInfo) = new MSourceInfos(allInfos + ((file, info)))
def get(file:File) = allInfos.getOrElse(file, SourceInfos.emptyInfo)
}
private final class MSourceInfo(val reportedProblems: Seq[Problem], val unreportedProblems: Seq[Problem]) extends SourceInfo
Something went wrong with that request. Please try again.