mirror of https://github.com/sbt/sbt.git
Merge pull request #6730 from eed3si9n/wip/build-server-reporter
[1.6.x] Fixes fake position handling, take 2
This commit is contained in:
commit
cf3d286499
|
|
@ -80,11 +80,17 @@ final class BuildServerReporterImpl(
|
||||||
private lazy val exchange = StandardMain.exchange
|
private lazy val exchange = StandardMain.exchange
|
||||||
private val problemsByFile = mutable.Map[Path, Vector[Diagnostic]]()
|
private val problemsByFile = mutable.Map[Path, Vector[Diagnostic]]()
|
||||||
|
|
||||||
|
// sometimes the compiler returns a fake position such as <macro>
|
||||||
|
// on Windows, this causes InvalidPathException (see #5994 and #6720)
|
||||||
|
private def toSafePath(ref: VirtualFileRef): Option[Path] =
|
||||||
|
if (ref.id().contains("<")) None
|
||||||
|
else Some(converter.toPath(ref))
|
||||||
|
|
||||||
override def sendSuccessReport(analysis: CompileAnalysis): Unit = {
|
override def sendSuccessReport(analysis: CompileAnalysis): Unit = {
|
||||||
for {
|
for {
|
||||||
(source, infos) <- analysis.readSourceInfos.getAllSourceInfos.asScala
|
(source, infos) <- analysis.readSourceInfos.getAllSourceInfos.asScala
|
||||||
|
filePath <- toSafePath(source)
|
||||||
} {
|
} {
|
||||||
val filePath = converter.toPath(source)
|
|
||||||
val diagnostics = infos.getReportedProblems.toSeq.flatMap(toDiagnostic)
|
val diagnostics = infos.getReportedProblems.toSeq.flatMap(toDiagnostic)
|
||||||
val params = PublishDiagnosticsParams(
|
val params = PublishDiagnosticsParams(
|
||||||
textDocument = TextDocumentIdentifier(filePath.toUri),
|
textDocument = TextDocumentIdentifier(filePath.toUri),
|
||||||
|
|
@ -98,8 +104,10 @@ final class BuildServerReporterImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
override def sendFailureReport(sources: Array[VirtualFile]): Unit = {
|
override def sendFailureReport(sources: Array[VirtualFile]): Unit = {
|
||||||
for (source <- sources) {
|
for {
|
||||||
val filePath = converter.toPath(source)
|
source <- sources
|
||||||
|
filePath <- toSafePath(source)
|
||||||
|
} {
|
||||||
val diagnostics = problemsByFile.getOrElse(filePath, Vector())
|
val diagnostics = problemsByFile.getOrElse(filePath, Vector())
|
||||||
val params = PublishDiagnosticsParams(
|
val params = PublishDiagnosticsParams(
|
||||||
textDocument = TextDocumentIdentifier(filePath.toUri),
|
textDocument = TextDocumentIdentifier(filePath.toUri),
|
||||||
|
|
@ -116,8 +124,8 @@ final class BuildServerReporterImpl(
|
||||||
for {
|
for {
|
||||||
id <- problem.position.sourcePath.toOption
|
id <- problem.position.sourcePath.toOption
|
||||||
diagnostic <- toDiagnostic(problem)
|
diagnostic <- toDiagnostic(problem)
|
||||||
|
filePath <- toSafePath(VirtualFileRef.of(id))
|
||||||
} {
|
} {
|
||||||
val filePath = converter.toPath(VirtualFileRef.of(id))
|
|
||||||
problemsByFile(filePath) = problemsByFile.getOrElse(filePath, Vector()) :+ diagnostic
|
problemsByFile(filePath) = problemsByFile.getOrElse(filePath, Vector()) :+ diagnostic
|
||||||
val params = PublishDiagnosticsParams(
|
val params = PublishDiagnosticsParams(
|
||||||
TextDocumentIdentifier(filePath.toUri),
|
TextDocumentIdentifier(filePath.toUri),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue