diff --git a/src/main/kotlin/b/language/server/BDocumentService.kt b/src/main/kotlin/b/language/server/BDocumentService.kt index 94c82a60f7e57702bfd74bc7913ce12eee98bbfb..065066c6a2cf862beb9be97aa8192c4090c7f360 100644 --- a/src/main/kotlin/b/language/server/BDocumentService.kt +++ b/src/main/kotlin/b/language/server/BDocumentService.kt @@ -8,6 +8,7 @@ import b.language.server.proBMangement.probCli.ProBCommandLineAccess import org.eclipse.lsp4j.* import org.eclipse.lsp4j.services.TextDocumentService import java.io.IOException +import java.net.URI import java.util.concurrent.ConcurrentHashMap class BDocumentService(private val server: Server, private val communicator: CommunicatorInterface) : TextDocumentService { @@ -57,14 +58,17 @@ class BDocumentService(private val server: Server, private val communicator: Com try{ val diagnostics: List<Diagnostic> = prob.checkDocument(currentUri, settings) - communicator.sendDebugMessage("created diagnostics $diagnostics", MessageType.Info) - communicator.publishDiagnostics(PublishDiagnosticsParams(currentUri, diagnostics)) - communicator.showMessage("Evaluation done - ${diagnostics.size} problem(s)", MessageType.Log) - val filesWithProblems = diagnostics.map { diagnostic -> diagnostic.source } + + val sortedDiagnostic = diagnostics.groupBy { it.source } + sortedDiagnostic.forEach { entry -> communicator.publishDiagnostics(entry.key, entry.value)} + communicator.showMessage("Evaluation done: ${diagnostics.size} problem(s)", MessageType.Log) + + val filesWithProblems = sortedDiagnostic.keys.toList() val invalidFiles = calculateToInvalidate(currentUri, filesWithProblems) - invalidFiles.forEach{uri -> communicator.publishDiagnostics(PublishDiagnosticsParams(uri, listOf()))} + invalidFiles.forEach{uri -> communicator.publishDiagnostics(uri, listOf())} communicator.sendDebugMessage("invalidating old files $invalidFiles", MessageType.Info) issueTracker[currentUri] = filesWithProblems.toSet() + }catch (e : PathCouldNotBeCreatedException){ communicator.sendDebugMessage("error path could not be created", MessageType.Info) communicator.showMessage(e.message!!, MessageType.Error) diff --git a/src/main/kotlin/b/language/server/communication/Communicator.kt b/src/main/kotlin/b/language/server/communication/Communicator.kt index 3472e80878a9aef41fc3843a241f21afb818049d..1d7e97c3983082a30d949e5377f1113056818d06 100644 --- a/src/main/kotlin/b/language/server/communication/Communicator.kt +++ b/src/main/kotlin/b/language/server/communication/Communicator.kt @@ -1,5 +1,6 @@ package b.language.server.communication +import org.eclipse.lsp4j.Diagnostic import org.eclipse.lsp4j.MessageParams import org.eclipse.lsp4j.MessageType import org.eclipse.lsp4j.PublishDiagnosticsParams @@ -22,8 +23,8 @@ object Communicator : CommunicatorInterface { * * @param diagnostics object containing the Diagnostics */ - override fun publishDiagnostics(diagnostics: PublishDiagnosticsParams) { - client.publishDiagnostics(diagnostics) + override fun publishDiagnostics(target :String, diagnostics : List<Diagnostic>) { + client.publishDiagnostics(PublishDiagnosticsParams(target, diagnostics)) } /** diff --git a/src/main/kotlin/b/language/server/communication/CommunicatorInterface.kt b/src/main/kotlin/b/language/server/communication/CommunicatorInterface.kt index 850b781fd566cc31a82d95c04d7c5ee932f9e6d6..64967c770c5b553f193601c384d2379850e36169 100644 --- a/src/main/kotlin/b/language/server/communication/CommunicatorInterface.kt +++ b/src/main/kotlin/b/language/server/communication/CommunicatorInterface.kt @@ -1,5 +1,6 @@ package b.language.server.communication +import org.eclipse.lsp4j.Diagnostic import org.eclipse.lsp4j.MessageType import org.eclipse.lsp4j.PublishDiagnosticsParams @@ -13,7 +14,7 @@ interface CommunicatorInterface { * * @param diagnostics object containing the Diagnostics */ - fun publishDiagnostics(diagnostics : PublishDiagnosticsParams) + fun publishDiagnostics(target :String, diagnostics : List<Diagnostic>) /** * Sends a debug message resulting in a output channel message