Skip to content

Commit

Permalink
bugfix: BuildTargetInfo for mill-build
Browse files Browse the repository at this point in the history
mill-build build target display name ends with `/` and build target info for it was not displayed.
  • Loading branch information
jkciesluk authored and tgodzik committed Nov 13, 2023
1 parent 00fdcf1 commit c68474d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import ch.epfl.scala.bsp4j.BuildTargetIdentifier

class BuildTargetInfo(buildTargets: BuildTargets) {

def buildTargetDetails(targetName: String): String = {
def buildTargetDetails(targetName: String, uri: String): String = {
buildTargets.all
.filter(_.getDisplayName == targetName)
.map(_.getId())
.headOption
.map(buildTargetDetail)
.find(_.getDisplayName == targetName)
.orElse(buildTargets.all.find(_.getId.getUri.toString == uri))
.map(target => buildTargetDetail(target.getId()))
.getOrElse(s"Build target $targetName not found")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,12 @@ final class FileDecoderProvider(
.toAbsolutePathSafe
.map { path =>
val targetName = path.filename.stripSuffix(".metals-buildtarget")
new BuildTargetInfo(buildTargets).buildTargetDetails(targetName)
// display name for mill-build is `mill-build/` and `mill-build/mill-build/` for meta builds
val withoutSuffix = uri.toString().stripSuffix("/.metals-buildtarget")
new BuildTargetInfo(buildTargets).buildTargetDetails(
targetName,
withoutSuffix,
)
}
.getOrElse(s"Error transforming $uri to path")
DecoderResponse.success(uri, text)
Expand Down

0 comments on commit c68474d

Please sign in to comment.