Skip to content

Commit

Permalink
Add a function to load a project from multiple sources (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaelmBleidd authored Dec 26, 2024
1 parent 61ad160 commit fd7df17
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions jacodb-ets/src/main/kotlin/org/jacodb/ets/utils/LoadEtsFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,27 @@ fun loadEtsProjectFromIR(
projectFilesPath: Path,
sdkFilesPath: Path?,
): EtsScene {
val walker = { irFolder: Path ->
irFolder.walk()
.filter { it.extension == "json" }
.map {
it.inputStream().use { stream ->
val etsFileDto = EtsFileDto.loadFromJson(stream)
convertToEtsFile(etsFileDto)
}
}
.toList()
}

val projectFiles = walker(projectFilesPath)
val sdkFiles = sdkFilesPath?.let { walker(it) }.orEmpty()

return EtsScene(projectFiles, sdkFiles)
}

fun loadEtsProjectFromMultipleIR(input: List<Path>, sdkPaths: List<Path>): EtsScene {
val projectFiles = input.flatMap(walker)
val sdkFiles = sdkPaths.flatMap(walker)

return EtsScene(projectFiles, sdkFiles)
}

private val walker = { irFolder: Path ->
irFolder.walk()
.filter { it.extension == "json" }
.map {
it.inputStream().use { stream ->
val etsFileDto = EtsFileDto.loadFromJson(stream)
convertToEtsFile(etsFileDto)
}
}
.toList()
}

0 comments on commit fd7df17

Please sign in to comment.