Skip to content

Commit

Permalink
Adjust SemanticDB targe root paths using a regex
Browse files Browse the repository at this point in the history
Matching on string interpolation is terribly slow.
  • Loading branch information
Jaden Peterson committed Oct 19, 2024
1 parent 8e09788 commit 802673a
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ object Analysis {
}

object CommonArguments {
private val scala2SemanticDbTargetRootRegex = """-P:semanticdb:targetroot:(.*)""".r
private val scala3SemanticDbTargetRootRegex = """-semanticdb-target:(.*)""".r

private def adjustCompilerOptions(workDir: Path, options: List[String]) = {
def adjustStringPath(path: String) = SandboxUtil.getSandboxPath(workDir, Paths.get(path)).toString
def adjustStringPath(path: String) =
SandboxUtil.getSandboxPath(workDir, Paths.get(path)).toString

options.flatMap {
case s"-P:semanticdb:targetroot:$path" =>
case scala2SemanticDbTargetRootRegex(path) =>
List(s"-P:semanticdb:sourceroot:${workDir.toString}", s"-P:semanticdb:targetroot:${adjustStringPath(path)}")

case s"-semanticdb-target:$path" =>
case scala3SemanticDbTargetRootRegex(path) =>
List(s"-semanticdb-target:${adjustStringPath(path)}", s"-sourceroot:${workDir.toString}")

case option => List(option)
Expand Down

0 comments on commit 802673a

Please sign in to comment.