in intellij-plugin-structure/structure-intellij/src/main/java/com/jetbrains/plugin/structure/intellij/plugin/Classpath.kt [29:46]
fun mergeWith(other: Classpath): Classpath {
if (other.entries.isEmpty()) return this
if (this.entries.isEmpty()) return other
val pathToEntry = mutableMapOf<Path, ClasspathEntry>()
for (cpEntry in this.entries + other.entries) {
val path = cpEntry.path
val existingCpEntry = pathToEntry[path]
if (existingCpEntry == null) {
pathToEntry[path] = cpEntry
} else if (existingCpEntry.origin == IMPLICIT && cpEntry.origin != IMPLICIT) {
pathToEntry[path] = cpEntry
}
}
return Classpath(pathToEntry.values.toList())
}