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 20, 2023
1 parent 505e58c commit 7cdcccf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 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
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class FileDecoderProviderSbtLspSuite
result =>
FileDecoderProviderLspSuite.filterSections(
result,
Set("Target", "Scala Version", "Base Directory", "Source Directories"),
Set("Target", "Scala Version", "Base Directory", "Sources"),
),
)

Expand Down Expand Up @@ -1207,9 +1207,9 @@ object FileDecoderProviderLspSuite {
|Base Directory
| file:@workspace/a/
|
|Source Directories
| @workspace/a/src/main/java
| @workspace/a/src/main/scala
| @workspace/a/src/main/scala-3
| @workspace/a/target/scala-${V.scala3}/src_managed/main (generated)""".stripMargin
|Sources
| @workspace/a/src/main/java/* (empty)
| @workspace/a/src/main/scala-3/* (empty)
| @workspace/a/src/main/scala/*
| @workspace/a/target/scala-${V.scala3}/src_managed/main/* (generated)""".stripMargin
}

0 comments on commit 7cdcccf

Please sign in to comment.