Skip to content

Commit

Permalink
bugfix: Disable best effort compilation by default
Browse files Browse the repository at this point in the history
Looks like sometimes best effort artifacts are being produced despite the fact that compilation finished succesfully. I think this actually causes downstream module to fail the compilation.

I've put it into server config mostly because I don't really want users to have to tinker with that. Once it works it should be enabled always.
  • Loading branch information
tgodzik committed Aug 1, 2024
1 parent c744a47 commit 4194d67
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,12 @@ object BuildServerConnection {
Cancelable(() => listening.cancel(false))
val result =
try {
BuildServerConnection.initialize(projectRoot, server, serverName)
BuildServerConnection.initialize(
projectRoot,
server,
serverName,
config,
)
} catch {
case e: TimeoutException =>
conn.cancelables.foreach(_.cancel())
Expand Down Expand Up @@ -705,12 +710,13 @@ object BuildServerConnection {
workspace: AbsolutePath,
server: MetalsBuildServer,
serverName: String,
config: MetalsServerConfig,
): InitializeBuildResult = {
val extraParams = BspExtraBuildParams(
BuildInfo.javaSemanticdbVersion,
BuildInfo.scalametaVersion,
BuildInfo.supportedScala2Versions.asJava,
true,
config.enableBestEffort,
)

val capabilities = new BuildClientCapabilities(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ final case class MetalsServerConfig(
.filter(_.forall(Character.isDigit(_)))
.map(_.toInt)
.getOrElse(60),
enableBestEffort: Boolean = MetalsServerConfig.binaryOption(
"metals.enable-best-effort",
default = false,
),
) {
override def toString: String =
List[String](
Expand All @@ -143,6 +147,7 @@ final case class MetalsServerConfig(
s"build-server-ping-interval=${pingInterval}",
s"worksheet-timeout=$worksheetTimeout",
s"debug-server-start-timeout=$debugServerStartTimeout",
s"enable-best-effort=$enableBestEffort",
).mkString("MetalsServerConfig(\n ", ",\n ", "\n)")
}
object MetalsServerConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package tests.`best-effort`

import scala.meta.internal.metals.MetalsServerConfig

import tests.BaseNonCompilingLspSuite

class BestEffortCompilationSuite
extends BaseNonCompilingLspSuite("best-effort-compilation") {
val scalaVersion = "3.5.0-RC1"

override def serverConfig: MetalsServerConfig =
super.serverConfig.copy(enableBestEffort = true)

override val scalaVersionConfig = s"\"scalaVersion\": \"${scalaVersion}\""
override val saveAfterChanges: Boolean = true
override val scala3Diagnostics: Boolean = true
Expand Down

0 comments on commit 4194d67

Please sign in to comment.