From e5a999a98ef21c0bd3221969a2ca1e6a959b823f Mon Sep 17 00:00:00 2001 From: Jorge Vicente Cantero Date: Sat, 17 Nov 2018 00:14:54 +0100 Subject: [PATCH] Address feedback on initial migration --- .../main/scala/bloop/bsp/BloopBspServices.scala | 8 ++------ .../scala/bloop/logging/BspServerLogger.scala | 4 ++-- .../bloop/reporter/BspProjectReporter.scala | 17 +++++------------ 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/frontend/src/main/scala/bloop/bsp/BloopBspServices.scala b/frontend/src/main/scala/bloop/bsp/BloopBspServices.scala index 96689116dd..79febd1d8f 100644 --- a/frontend/src/main/scala/bloop/bsp/BloopBspServices.scala +++ b/frontend/src/main/scala/bloop/bsp/BloopBspServices.scala @@ -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 @@ -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 diff --git a/frontend/src/main/scala/bloop/logging/BspServerLogger.scala b/frontend/src/main/scala/bloop/logging/BspServerLogger.scala index c95fa705d6..5cac405dcc 100644 --- a/frontend/src/main/scala/bloop/logging/BspServerLogger.scala +++ b/frontend/src/main/scala/bloop/logging/BspServerLogger.scala @@ -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) ) @@ -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) diff --git a/frontend/src/main/scala/bloop/reporter/BspProjectReporter.scala b/frontend/src/main/scala/bloop/reporter/BspProjectReporter.scala index 07676005a9..c54108dfb4 100644 --- a/frontend/src/main/scala/bloop/reporter/BspProjectReporter.scala +++ b/frontend/src/main/scala/bloop/reporter/BspProjectReporter.scala @@ -1,7 +1,6 @@ package bloop.reporter import java.io.File -import java.util.concurrent.ConcurrentHashMap import bloop.data.Project import bloop.io.AbsolutePath @@ -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( @@ -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) } } @@ -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)