mirror of https://github.com/sbt/sbt.git
Merge pull request #6367 from eed3si9n/wip/pos-sourcefile
Make sure to also pass absolute sourceFile to sourceMappers, take 2
This commit is contained in:
commit
571005efa0
|
|
@ -94,7 +94,6 @@ import xsbti.{ FileConverter, Position }
|
||||||
import scala.annotation.nowarn
|
import scala.annotation.nowarn
|
||||||
import scala.collection.immutable.ListMap
|
import scala.collection.immutable.ListMap
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import scala.util.Try
|
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
import scala.xml.NodeSeq
|
import scala.xml.NodeSeq
|
||||||
|
|
||||||
|
|
@ -470,16 +469,16 @@ object Defaults extends BuildCommon {
|
||||||
)
|
)
|
||||||
|
|
||||||
private[sbt] def toAbsoluteSource(fc: FileConverter)(pos: Position): Position = {
|
private[sbt] def toAbsoluteSource(fc: FileConverter)(pos: Position): Position = {
|
||||||
def isValid(path: String): Boolean = {
|
val newPath: Option[NioPath] = pos
|
||||||
Try(Paths.get(path)).map(_ => true).getOrElse(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
val newPath: Option[String] = pos
|
|
||||||
.sourcePath()
|
.sourcePath()
|
||||||
.asScala
|
.asScala
|
||||||
.filter(isValid)
|
.flatMap { path =>
|
||||||
.map { path =>
|
try {
|
||||||
fc.toPath(VirtualFileRef.of(path)).toAbsolutePath.toString
|
Some(fc.toPath(VirtualFileRef.of(path)))
|
||||||
|
} catch {
|
||||||
|
// catch all to trap wierd path injected by compiler, users, or plugins
|
||||||
|
case NonFatal(_) => None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newPath
|
newPath
|
||||||
|
|
@ -495,9 +494,14 @@ object Defaults extends BuildCommon {
|
||||||
|
|
||||||
override def pointerSpace(): Optional[String] = pos.pointerSpace()
|
override def pointerSpace(): Optional[String] = pos.pointerSpace()
|
||||||
|
|
||||||
override def sourcePath(): Optional[String] = Optional.of(path)
|
override def sourcePath(): Optional[String] = Optional.of(path.toAbsolutePath.toString)
|
||||||
|
|
||||||
override def sourceFile(): Optional[File] = pos.sourceFile()
|
override def sourceFile(): Optional[File] =
|
||||||
|
(try {
|
||||||
|
Some(path.toFile.getAbsoluteFile)
|
||||||
|
} catch {
|
||||||
|
case NonFatal(_) => None
|
||||||
|
}).toOptional
|
||||||
|
|
||||||
override def startOffset(): Optional[Integer] = pos.startOffset()
|
override def startOffset(): Optional[Integer] = pos.startOffset()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue