Skip to content

Commit

Permalink
Read packagePrefix from ScalaBuildTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszwawrzyk committed Mar 6, 2020
1 parent a41689a commit f8244b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private[resolver] object BspResolverDescriptors {
basePath: Option[File],
output: Option[File],
testOutput: Option[File],
packagePrefix: Option[String],
sourceDirs: Seq[SourceDirectory],
testSourceDirs: Seq[SourceDirectory],
resourceDirs: Seq[SourceDirectory],
Expand Down
13 changes: 11 additions & 2 deletions bsp/src/org/jetbrains/bsp/project/resolver/BspResolverLogic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ private[resolver] object BspResolverLogic {
}
}

val packagePrefix = targetData
.filter(_ => target.getDataKind == BuildTargetDataKind.SCALA)
.flatMap(extractScalaSdkData)
.flatMap(target => Option(target.getPackagePrefix))

val moduleDescriptionData = createModuleDescriptionData(
Seq(target), tags, moduleBase, outputPath, sourceRoots, resourceRoots,
Seq(target), tags, moduleBase, outputPath, packagePrefix, sourceRoots, resourceRoots,
classPathWithoutDependencyOutputs, dependencySourceDirs)

if (tags.contains(BuildTargetTag.NO_IDE)) None
Expand All @@ -237,6 +242,7 @@ private[resolver] object BspResolverLogic {
tags: Seq[String],
moduleBase: Option[File],
outputPath: Option[File],
packagePrefix: Option[String],
sourceRoots: Seq[SourceDirectory],
resourceRoots: Seq[SourceDirectory],
classPath: Seq[File],
Expand All @@ -260,6 +266,7 @@ private[resolver] object BspResolverLogic {
Seq.empty, Seq.empty,
moduleBase,
None, None,
packagePrefix,
Seq.empty, Seq.empty,
Seq.empty, Seq.empty,
Seq.empty, Seq.empty,
Expand Down Expand Up @@ -331,6 +338,7 @@ private[resolver] object BspResolverLogic {
val targetTestDependencies = mergeBTIs(dataCombined.targetTestDependencies, dataNext.targetTestDependencies)
val output = dataCombined.output.orElse(dataNext.output)
val testOutput = dataCombined.testOutput.orElse(dataNext.testOutput)
val packagePrefix = dataCombined.packagePrefix.orElse(dataNext.packagePrefix)
val sourceDirs = mergeSourceDirs(dataCombined.sourceDirs, dataNext.sourceDirs)
val resourceDirs = mergeSourceDirs(dataCombined.resourceDirs, dataNext.resourceDirs)
val testResourceDirs = mergeSourceDirs(dataCombined.testResourceDirs, dataNext.testResourceDirs)
Expand All @@ -344,6 +352,7 @@ private[resolver] object BspResolverLogic {
dataCombined.id, dataCombined.name,
targets, targetDependencies, targetTestDependencies, dataCombined.basePath,
output, testOutput,
packagePrefix,
sourceDirs, testSourceDirs,
resourceDirs, testResourceDirs,
classPath, classPathSources,
Expand Down Expand Up @@ -512,7 +521,7 @@ private[resolver] object BspResolverLogic {

allSourceRoots.map { case (sourceType, root) =>
val data = getContentRoot(root.directory, moduleBase)
data.storePath(sourceType, root.directory.getCanonicalPath)
data.storePath(sourceType, root.directory.getCanonicalPath, moduleDescriptionData.packagePrefix.orNull)
data
}.foreach { data =>
// because we map on a set, `data` is deduplicated before creating content root data nodes. thus each node is only added once
Expand Down

0 comments on commit f8244b6

Please sign in to comment.