All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.anaplan.engineering.vdmanimation.api.AnimationCoverage.kt Maven / Gradle / Ivy

There is a newer version: 0.4.0.alpha.2
Show newest version
package com.anaplan.engineering.vdmanimation.api

data class AnimationCoverage(
        val files: List
) {
    fun combine(other: AnimationCoverage): AnimationCoverage {
        val textsInThis = this.files.map { it.text }
        val textsInOther = other.files.map { it.text }
        val filesJustInThis = this.files.filter { !textsInOther.contains(it.text) }
        val filesJustInOther = other.files.filter { !textsInThis.contains(it.text) }
        val combinedResults = (files - filesJustInThis).map { thisFile ->
            val otherFile = other.files.find { it.text == thisFile.text }
                    ?: throw IllegalStateException()
            val coverage = mutableMapOf()
            coverage.putAll(thisFile.coverage)
            otherFile.coverage.forEach { (location, count) ->
                coverage[location] = count + (coverage[location] ?: 0)
            }
            FileCoverage(thisFile.moduleName, thisFile.text, coverage)
        }
        return AnimationCoverage(
                filesJustInThis + filesJustInOther + combinedResults
        )
    }

}

data class FileCoverage(
        val moduleName: String,
        val text: String,
        val coverage: Map
)

data class Location(
        val startLine: Int,
        val startPos: Int,
        val endLine: Int,
        val endPos: Int
)





© 2015 - 2025 Weber Informatics LLC | Privacy Policy