@@ -7,6 +7,7 @@ import common.sandbox.SandboxUtil
77import net .sourceforge .argparse4j .impl .{Arguments => ArgumentsImpl }
88import net .sourceforge .argparse4j .inf .{Argument , ArgumentParser , ArgumentType , Namespace }
99import java .util .{Collections , List as JList }
10+ import scala .annotation .nowarn
1011import scala .collection .mutable .Buffer
1112import scala .jdk .CollectionConverters .*
1213import java .io .File
@@ -61,22 +62,23 @@ object Analysis {
6162}
6263
6364object CommonArguments {
64- private val scala2SemanticDbTargetRootRegex = """ -P:semanticdb:targetroot:(.*)""" .r
65- private val scala3SemanticDbTargetRootRegex = """ -semanticdb-target:(.*)""" .r
66-
67- private def adjustCompilerOptions (workDir : Path , options : List [String ]) = {
68- def adjustStringPath (path : String ) =
69- SandboxUtil .getSandboxPath(workDir, Paths .get(path)).toString
70-
71- options.flatMap {
72- case scala2SemanticDbTargetRootRegex(path) =>
73- List (s " -P:semanticdb:sourceroot: ${workDir.toString}" , s " -P:semanticdb:targetroot: ${adjustStringPath(path)}" )
74-
75- case scala3SemanticDbTargetRootRegex(path) =>
76- List (s " -semanticdb-target: ${adjustStringPath(path)}" , s " -sourceroot: ${workDir.toString}" )
77-
78- case option => List (option)
65+ private val pathPlaceholderRegex = """ \$\{path\}""" .r
66+ private def adjustCompilerOptions (workDir : Path , options : List [String ]) = options.map { option =>
67+ val i = option.lastIndexOf(' ' )
68+ val withPathReplaced = if (i == - 1 ) {
69+ option
70+ } else {
71+ val template = option.slice(0 , i)
72+ val path = option.slice(i + 1 , option.length)
73+
74+ template.replace(
75+ " ${path}" : @ nowarn(" cat=lint-missing-interpolator" ),
76+ SandboxUtil .getSandboxPath(workDir, Paths .get(path)).toString,
77+ )
7978 }
79+
80+ withPathReplaced
81+ .replace(" ${workDir}" : @ nowarn(" cat=lint-missing-interpolator" ), workDir.toString)
8082 }
8183
8284 /**
0 commit comments