diff --git a/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala b/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala index 6e2631634f9..35f4e367377 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala @@ -2,25 +2,18 @@ package scala.meta.internal.metals import java.nio.charset.Charset import java.util.Collections -import java.util.concurrent.atomic.AtomicReference import scala.util.Success import scala.util.Try import scala.meta.internal.builds.SbtBuildTool -import scala.meta.internal.metals.Messages._ import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.mtags.MD5 import scala.meta.internal.mtags.Semanticdbs import scala.meta.internal.mtags.TextDocumentLookup import scala.meta.internal.{semanticdb => s} import scala.meta.io.AbsolutePath -import org.eclipse.lsp4j.DiagnosticSeverity -import org.eclipse.lsp4j.PublishDiagnosticsParams -import org.eclipse.{lsp4j => l} - /** * Produces SemanticDBs on-demand by using the presentation compiler. * @@ -34,9 +27,7 @@ final class InteractiveSemanticdbs( workspace: AbsolutePath, buildTargets: BuildTargets, charset: Charset, - client: MetalsLanguageClient, tables: Tables, - statusBar: StatusBar, compilers: () => Compilers, clientConfig: ClientConfiguration, semanticdbIndexer: () => SemanticdbIndexer, @@ -45,7 +36,6 @@ final class InteractiveSemanticdbs( ) extends Cancelable with Semanticdbs { - private val activeDocument = new AtomicReference[Option[String]](None) private val textDocumentCache = Collections.synchronizedMap( new java.util.HashMap[AbsolutePath, s.TextDocument]() ) @@ -134,42 +124,6 @@ final class InteractiveSemanticdbs( } } - /** - * Unpublish diagnostics for un-focused dependency source, if any, and publish diagnostics - * for the currently focused source, if any. - */ - def didFocus(path: AbsolutePath): Unit = { - activeDocument.get().foreach { uri => - client.publishDiagnostics( - new PublishDiagnosticsParams(uri, Collections.emptyList()) - ) - } - if (path.isDependencySource(workspace)) { - textDocument(path).toOption.foreach { doc => - val uri = path.toURI.toString() - activeDocument.set(Some(uri)) - val diagnostics = for { - diag <- doc.diagnostics - if diag.severity.isError - range <- diag.range - } yield { - // Use INFO instead of ERROR severity because these diagnostics are published for readonly - // files of external dependencies so the user cannot fix them. - val severity = DiagnosticSeverity.Information - new l.Diagnostic(range.toLsp, diag.message, severity, "scala") - } - if (diagnostics.nonEmpty) { - statusBar.addMessage(partialNavigation(clientConfig.icons)) - client.publishDiagnostics( - new PublishDiagnosticsParams(uri, diagnostics.asJava) - ) - } - } - } else { - activeDocument.set(None) - } - } - private def compile(source: AbsolutePath, text: String): s.TextDocument = { if (source.isJavaFilename) javaInteractiveSemanticdb.fold(s.TextDocument())( diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala index c220d3859ff..ce44dd3efce 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala @@ -364,9 +364,7 @@ class MetalsLspService( folder, buildTargets, charset, - languageClient, tables, - statusBar, () => compilers, clientConfig, () => semanticDBIndexer, @@ -1076,11 +1074,7 @@ class MetalsLspService( } yield () if (path.isDependencySource(folder)) { - CancelTokens { _ => - // publish diagnostics - interactiveSemanticdbs.didFocus(path) - () - } + CompletableFuture.completedFuture(()) } else { buildServerPromise.future.flatMap { _ => def load(): Future[Unit] = { @@ -1135,8 +1129,6 @@ class MetalsLspService( buildTargets .inverseSources(path) .foreach(focusedDocumentBuildTarget.set) - // unpublish diagnostic for dependencies - interactiveSemanticdbs.didFocus(path) // Don't trigger compilation on didFocus events under cascade compilation // because save events already trigger compile in inverse dependencies. if (path.isDependencySource(folder)) {