@@ -24,6 +24,8 @@ import scala.annotation.{ threadUnsafe => tu, tailrec }
24
24
import scala .PartialFunction .condOpt
25
25
26
26
import dotty .tools .dotc .{semanticdb => s }
27
+ import dotty .tools .io .AbstractFile
28
+ import dotty .tools .io .JarArchive
27
29
28
30
/** Extract symbol references and uses to semanticdb files.
29
31
* See https://scalameta.org/docs/semanticdb/specification.html#symbol-1
@@ -38,7 +40,8 @@ class ExtractSemanticDB extends Phase:
38
40
override val description : String = ExtractSemanticDB .description
39
41
40
42
override def isRunnable (using Context ) =
41
- super .isRunnable && ctx.settings.Xsemanticdb .value
43
+ super .isRunnable && ctx.settings.Xsemanticdb .value &&
44
+ ! ExtractSemanticDB .semanticdbTarget.isInstanceOf [JarArchive ]
42
45
43
46
// Check not needed since it does not transform trees
44
47
override def isCheckable : Boolean = false
@@ -473,21 +476,20 @@ object ExtractSemanticDB:
473
476
val name : String = " extractSemanticDB"
474
477
val description : String = " extract info into .semanticdb files"
475
478
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
+
476
484
def write (
477
485
source : SourceFile ,
478
486
occurrences : List [SymbolOccurrence ],
479
487
symbolInfos : List [SymbolInformation ],
480
488
synthetics : List [Synthetic ],
481
489
)(using Context ): Unit =
482
490
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
- )
489
491
val relPath = SourceFile .relativePath(source, ctx.settings.sourceroot.value)
490
- val outpath = semanticdbTarget
492
+ val outpath = absolutePath( this . semanticdbTarget.jpath)
491
493
.resolve(" META-INF" )
492
494
.resolve(" semanticdb" )
493
495
.resolve(relPath)
0 commit comments