Skip to content

Commit

Permalink
refactor: differentiate between files and directories in sources
Browse files Browse the repository at this point in the history
So I noticed that when using the "Show build target info" feature while
using scala-cli it would show individual files under the "Source
Directories". I know it's a bit of a nit, but I thought it might be
nicer to rename this to "Sources" and then do a better job at indicating
which are files, which are directories, and which ones don't exist. If
we agree this is better I can fix the related tests as well.
  • Loading branch information
ckipp01 committed Oct 19, 2023
1 parent 505e58c commit 8927f10
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class BuildTargetInfo(buildTargets: BuildTargets) {
"Base Directory",
List(URIEncoderDecoder.decode(info.baseDirectory)),
)
output ++= getSection("Source Directories", getSources(info))
output ++= getSection("Sources", getSources(info))
})

val scalaClassesDir = scalaInfo.map(_.classDirectory)
Expand Down Expand Up @@ -222,9 +222,12 @@ class BuildTargetInfo(buildTargets: BuildTargets) {
buildTargets.sourceItemsToBuildTargets
.filter(_._2.iterator.asScala.contains(target.getId()))
.toList
.map { case (path, _) =>
val generated = buildTargets.checkIfGeneratedDir(path)
s"$path${if (generated) " (generated)" else ""}"
.map {
case (path, _) if buildTargets.checkIfGeneratedDir(path) =>
s"${path}/* (generated)"
case (path, _) if path.isDirectory => s"${path}/*"
case (path, _) if !path.exists => s"${path}/* (empty)"
case (path, _) => path.toString()
}
.sorted
}
Expand Down

0 comments on commit 8927f10

Please sign in to comment.