mirror of https://github.com/sbt/sbt.git
Enable semanticdb with Dotty
This commit is contained in:
parent
31dc975ec7
commit
4a02292b6f
|
|
@ -13,6 +13,7 @@ import sbt.internal.SysProp
|
||||||
import sbt.librarymanagement.syntax._
|
import sbt.librarymanagement.syntax._
|
||||||
import sbt.librarymanagement.CrossVersion
|
import sbt.librarymanagement.CrossVersion
|
||||||
import Project.inConfig
|
import Project.inConfig
|
||||||
|
import sbt.internal.inc.ScalaInstance
|
||||||
|
|
||||||
object SemanticdbPlugin extends AutoPlugin {
|
object SemanticdbPlugin extends AutoPlugin {
|
||||||
override def requires = JvmPlugin
|
override def requires = JvmPlugin
|
||||||
|
|
@ -21,7 +22,7 @@ object SemanticdbPlugin extends AutoPlugin {
|
||||||
override lazy val globalSettings: Seq[Def.Setting[_]] = Seq(
|
override lazy val globalSettings: Seq[Def.Setting[_]] = Seq(
|
||||||
semanticdbEnabled := SysProp.semanticdb,
|
semanticdbEnabled := SysProp.semanticdb,
|
||||||
semanticdbIncludeInJar := false,
|
semanticdbIncludeInJar := false,
|
||||||
semanticdbOptions := List("-Yrangepos"),
|
semanticdbOptions := List(),
|
||||||
semanticdbVersion := "4.3.20"
|
semanticdbVersion := "4.3.20"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -33,7 +34,8 @@ object SemanticdbPlugin extends AutoPlugin {
|
||||||
allDependencies ++= {
|
allDependencies ++= {
|
||||||
val sdb = semanticdbEnabled.value
|
val sdb = semanticdbEnabled.value
|
||||||
val m = semanticdbCompilerPlugin.value
|
val m = semanticdbCompilerPlugin.value
|
||||||
if (sdb) List(Build0.compilerPlugin(m))
|
val sv = scalaVersion.value
|
||||||
|
if (sdb && !ScalaInstance.isDotty(sv)) List(Build0.compilerPlugin(m))
|
||||||
else Nil
|
else Nil
|
||||||
}
|
}
|
||||||
) ++ inConfig(Compile)(configurationSettings) ++ inConfig(Test)(configurationSettings)
|
) ++ inConfig(Compile)(configurationSettings) ++ inConfig(Test)(configurationSettings)
|
||||||
|
|
@ -43,8 +45,13 @@ object SemanticdbPlugin extends AutoPlugin {
|
||||||
val old = scalacOptions.value
|
val old = scalacOptions.value
|
||||||
val sdb = semanticdbEnabled.value
|
val sdb = semanticdbEnabled.value
|
||||||
val sdbOptions = semanticdbOptions.value
|
val sdbOptions = semanticdbOptions.value
|
||||||
if (sdb) (old.toVector ++ sdbOptions.toVector).distinct
|
val sv = scalaVersion.value
|
||||||
else old
|
if (sdb) {
|
||||||
|
(
|
||||||
|
old.toVector ++ sdbOptions ++
|
||||||
|
(if (ScalaInstance.isDotty(sv)) Some("-Ysemanticdb") else None)
|
||||||
|
).distinct
|
||||||
|
} else old
|
||||||
},
|
},
|
||||||
semanticdbTargetRoot := {
|
semanticdbTargetRoot := {
|
||||||
val in = semanticdbIncludeInJar.value
|
val in = semanticdbIncludeInJar.value
|
||||||
|
|
@ -53,7 +60,9 @@ object SemanticdbPlugin extends AutoPlugin {
|
||||||
},
|
},
|
||||||
semanticdbOptions ++= {
|
semanticdbOptions ++= {
|
||||||
val tr = semanticdbTargetRoot.value
|
val tr = semanticdbTargetRoot.value
|
||||||
List(s"-P:semanticdb:targetroot:$tr")
|
val sv = scalaVersion.value
|
||||||
|
if (ScalaInstance.isDotty(sv)) List("-semanticdb-target", tr.toString)
|
||||||
|
else List(s"-P:semanticdb:targetroot:$tr", "-Yrangepos")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue