Skip to content

Commit d51279e

Browse files
committed
Don't create semanticdb files when writing to JAR
1 parent 7abcde2 commit d51279e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import scala.annotation.{ threadUnsafe => tu, tailrec }
2424
import scala.PartialFunction.condOpt
2525

2626
import dotty.tools.dotc.{semanticdb => s}
27+
import dotty.tools.io.AbstractFile
28+
import dotty.tools.io.JarArchive
2729

2830
/** Extract symbol references and uses to semanticdb files.
2931
* See https://scalameta.org/docs/semanticdb/specification.html#symbol-1
@@ -38,7 +40,8 @@ class ExtractSemanticDB extends Phase:
3840
override val description: String = ExtractSemanticDB.description
3941

4042
override def isRunnable(using Context) =
41-
super.isRunnable && ctx.settings.Xsemanticdb.value
43+
super.isRunnable && ctx.settings.Xsemanticdb.value &&
44+
!ExtractSemanticDB.semanticdbTarget.isInstanceOf[JarArchive]
4245

4346
// Check not needed since it does not transform trees
4447
override def isCheckable: Boolean = false
@@ -473,21 +476,20 @@ object ExtractSemanticDB:
473476
val name: String = "extractSemanticDB"
474477
val description: String = "extract info into .semanticdb files"
475478

479+
def semanticdbTarget(using Context) =
480+
val semanticdbTargetSetting = ctx.settings.semanticdbTarget.value
481+
if semanticdbTargetSetting.isEmpty then ctx.settings.outputDir.value
482+
else AbstractFile.getDirectory(semanticdbTargetSetting)
483+
476484
def write(
477485
source: SourceFile,
478486
occurrences: List[SymbolOccurrence],
479487
symbolInfos: List[SymbolInformation],
480488
synthetics: List[Synthetic],
481489
)(using Context): Unit =
482490
def absolutePath(path: Path): Path = path.toAbsolutePath.normalize
483-
val semanticdbTarget =
484-
val semanticdbTargetSetting = ctx.settings.semanticdbTarget.value
485-
absolutePath(
486-
if semanticdbTargetSetting.isEmpty then ctx.settings.outputDir.value.jpath
487-
else Paths.get(semanticdbTargetSetting)
488-
)
489491
val relPath = SourceFile.relativePath(source, ctx.settings.sourceroot.value)
490-
val outpath = semanticdbTarget
492+
val outpath = absolutePath(this.semanticdbTarget.jpath)
491493
.resolve("META-INF")
492494
.resolve("semanticdb")
493495
.resolve(relPath)

0 commit comments

Comments
 (0)