diff --git a/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala b/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala index 5029720f789..a2896ae557d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala @@ -109,6 +109,8 @@ final class TargetData { javaTargetInfo.get(id) def jvmTarget(id: BuildTargetIdentifier): Option[JvmTarget] = scalaTarget(id).orElse(javaTarget(id)) + def jvmTargets(id: BuildTargetIdentifier): List[JvmTarget] = + List(scalaTarget(id), javaTarget(id)).flatten private val sourceBuildTargetsCache = new util.concurrent.ConcurrentHashMap[AbsolutePath, Option[ @@ -163,7 +165,10 @@ final class TargetData { } } yield path - if (fromDepModules.isEmpty) jvmTarget(id).flatMap(_.jarClasspath) + if (fromDepModules.isEmpty) + jvmTargets(id).map(_.jarClasspath).collectFirst { case Some(classpath) => + classpath + } else Some(fromDepModules) }