Skip to content

Commit

Permalink
Address feedback on initial migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jvican committed Nov 16, 2018
1 parent e9f5878 commit e5a999a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
8 changes: 2 additions & 6 deletions frontend/src/main/scala/bloop/bsp/BloopBspServices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,8 @@ final class BloopBspServices(
projects.iterator.map {
case (target, project) =>
val sources = project.sources.map { s =>
val uri = s.toBspUri
val bspUri = bsp.Uri(s.toBspSourceUri)

// TODO(jvican): Allow bloop to know what sources are generated or not
bsp.SourceItem(bspUri, false)
// TODO(jvican): Don't default on false for generated, add this info to JSON fields
bsp.SourceItem(bsp.Uri(s.toBspSourceUri), false)
}
bsp.SourcesItem(target, sources)
}.toList
Expand Down Expand Up @@ -463,7 +460,6 @@ final class BloopBspServices(
val response = bsp.DependencySourcesResult(
projects.iterator.map {
case (target, project) =>
//val sources = project.sources.iterator.map(s => bsp.Uri(s.toBspUri)).toList
val sourceJars = project.resolution.toList.flatMap { res =>
res.modules.flatMap { m =>
m.artifacts.iterator
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main/scala/bloop/logging/BspServerLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ final class BspServerLogger private (
bsp.TaskStartParams(
taskId,
Some(now),
Some(s"Starting compilation of project '${project.name}'"),
Some(s"Compiling '${project.name}'"),
Some(bsp.TaskDataKind.CompileTask),
Some(json)
)
Expand Down Expand Up @@ -171,7 +171,7 @@ final class BspServerLogger private (
bsp.TaskFinishParams(
taskId,
Some(now),
Some(s"Finished compilation of project '${project.name}'"),
Some(s"Compiled '${project.name}'"),
code,
Some(bsp.TaskDataKind.CompileReport),
Some(json)
Expand Down
17 changes: 5 additions & 12 deletions frontend/src/main/scala/bloop/reporter/BspProjectReporter.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bloop.reporter

import java.io.File
import java.util.concurrent.ConcurrentHashMap

import bloop.data.Project
import bloop.io.AbsolutePath
Expand All @@ -11,6 +10,7 @@ import ch.epfl.scala.bsp
import sbt.util.InterfaceUtil
import xsbti.compile.CompileAnalysis

import scala.collection.concurrent.TrieMap
import scala.collection.mutable

final class BspProjectReporter(
Expand All @@ -25,22 +25,15 @@ final class BspProjectReporter(

/** A thread-safe map containing files with reported problems (from this cycle and
* previous ones, such as buffered warnings from previously compiled source files). */
private val filesWithProblems = new ConcurrentHashMap[File, Boolean]()
private val filesWithProblems = TrieMap.empty[File, Boolean]

/** Log a problem in a thread-safe manner. */
override protected def logFull(problem: Problem): Unit = {
sbt.util.InterfaceUtil.toOption(problem.position.sourceFile()) match {
case Some(file) =>
// If it's the first diagnostic for this file, set clear to true
var sent: Boolean = false
filesWithProblems.computeIfAbsent(file, f => {
sent = true
logger.diagnostic(project, problem, true)
true
})

// If diagnostic wasn't sent in previous thunk, send it now as the clear already happened
if (sent) () else logger.diagnostic(project, problem, false)
val clear = filesWithProblems.putIfAbsent(file, true).isEmpty
logger.diagnostic(project, problem, clear)
case None => logger.diagnostic(project, problem, false)
}
}
Expand Down Expand Up @@ -75,7 +68,7 @@ final class BspProjectReporter(
previouslyReportedProblems.foreach { problem =>
InterfaceUtil.toOption(problem.position().sourceFile).foreach { source =>
// Do nothing if problem maps to a file with problems, assume it's already reported
if (filesWithProblems.containsKey(source)) ()
if (filesWithProblems.contains(source)) ()
else {
// Log no diagnostic if there was an error in a file that now has no problems
if (problem.severity() == xsbti.Severity.Error) logger.noDiagnostic(project, source)
Expand Down

0 comments on commit e5a999a

Please sign in to comment.