Turn strict errors off for Language Server (#10061)

Ensure strict errors are off to prevent unrecoverable errors in IDE.
Also partially reverted a change that prevented application of changes on errors (errors are still logged, as intended).
Closes #10014.
This commit is contained in:
Hubert Plociniczak 2024-05-23 22:49:08 +02:00 committed by GitHub
parent b27b5eaac7
commit 495eed45ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 26 deletions

View File

@ -295,6 +295,7 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: Level) {
RuntimeOptions.LOG_LEVEL,
Converter.toJavaLevel(logLevel).getName
)
.option(RuntimeOptions.STRICT_ERRORS, "false")
.option(RuntimeOptions.LOG_MASKING, Masking.isMaskingEnabled.toString)
.option(RuntimeOptions.EDITION_OVERRIDE, Info.currentEdition)
.option(

View File

@ -108,40 +108,48 @@ final class EnsureCompiledJob(
ctx: RuntimeContext,
logger: TruffleLogger
): Option[CompilationStatus] = {
val result = compile(module)
result match {
compile(module) match {
case Left(ex) =>
logger.log(
Level.WARNING,
s"Error while ensureCompiledModule ${module.getName}",
ex
)
Some(CompilationStatus.Failure)
case _ =>
applyEdits(new File(module.getPath)).map { changeset =>
compile(module)
.map { _ =>
// Side-effect: ensures that module's source is correctly initialized.
module.getSource()
invalidateCaches(module, changeset)
val state =
ctx.state.suggestions.getOrCreateFresh(module, module.getIr)
if (state.isIndexed) {
ctx.jobProcessor.runBackground(
AnalyzeModuleJob(module, state, module.getIr(), changeset)
)
} else {
AnalyzeModuleJob.analyzeModule(
module,
state,
module.getIr(),
changeset
)
}
runCompilationDiagnostics(module)
}
.getOrElse(CompilationStatus.Failure)
}
applyEdits(new File(module.getPath)).map { changeset =>
compile(module)
.map { _ =>
// Side-effect: ensures that module's source is correctly initialized.
module.getSource()
invalidateCaches(module, changeset)
val state =
ctx.state.suggestions.getOrCreateFresh(module, module.getIr)
if (state.isIndexed) {
ctx.jobProcessor.runBackground(
AnalyzeModuleJob(module, state, module.getIr(), changeset)
)
} else {
AnalyzeModuleJob.analyzeModule(
module,
state,
module.getIr(),
changeset
)
}
runCompilationDiagnostics(module)
}
.fold(
err => {
logger.log(
Level.WARNING,
s"Error while ensureCompiledModule ${module.getName}",
err
)
CompilationStatus.Failure
},
identity
)
}
}