Skip to content
Snippets Groups Projects
Commit 0776dbb0 authored by SeeBasTStick's avatar SeeBasTStick
Browse files

fixed bug where errors from sub files were wrongly shown in the main file

parent 1880b66c
Branches
No related tags found
Loading
......@@ -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)
......
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))
}
/**
......
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment