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
Tags
No related merge requests found
...@@ -8,6 +8,7 @@ import b.language.server.proBMangement.probCli.ProBCommandLineAccess ...@@ -8,6 +8,7 @@ import b.language.server.proBMangement.probCli.ProBCommandLineAccess
import org.eclipse.lsp4j.* import org.eclipse.lsp4j.*
import org.eclipse.lsp4j.services.TextDocumentService import org.eclipse.lsp4j.services.TextDocumentService
import java.io.IOException import java.io.IOException
import java.net.URI
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
class BDocumentService(private val server: Server, private val communicator: CommunicatorInterface) : TextDocumentService { 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 ...@@ -57,14 +58,17 @@ class BDocumentService(private val server: Server, private val communicator: Com
try{ try{
val diagnostics: List<Diagnostic> = prob.checkDocument(currentUri, settings) val diagnostics: List<Diagnostic> = prob.checkDocument(currentUri, settings)
communicator.sendDebugMessage("created diagnostics $diagnostics", MessageType.Info)
communicator.publishDiagnostics(PublishDiagnosticsParams(currentUri, diagnostics)) val sortedDiagnostic = diagnostics.groupBy { it.source }
communicator.showMessage("Evaluation done - ${diagnostics.size} problem(s)", MessageType.Log) sortedDiagnostic.forEach { entry -> communicator.publishDiagnostics(entry.key, entry.value)}
val filesWithProblems = diagnostics.map { diagnostic -> diagnostic.source } communicator.showMessage("Evaluation done: ${diagnostics.size} problem(s)", MessageType.Log)
val filesWithProblems = sortedDiagnostic.keys.toList()
val invalidFiles = calculateToInvalidate(currentUri, filesWithProblems) 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) communicator.sendDebugMessage("invalidating old files $invalidFiles", MessageType.Info)
issueTracker[currentUri] = filesWithProblems.toSet() issueTracker[currentUri] = filesWithProblems.toSet()
}catch (e : PathCouldNotBeCreatedException){ }catch (e : PathCouldNotBeCreatedException){
communicator.sendDebugMessage("error path could not be created", MessageType.Info) communicator.sendDebugMessage("error path could not be created", MessageType.Info)
communicator.showMessage(e.message!!, MessageType.Error) communicator.showMessage(e.message!!, MessageType.Error)
......
package b.language.server.communication package b.language.server.communication
import org.eclipse.lsp4j.Diagnostic
import org.eclipse.lsp4j.MessageParams import org.eclipse.lsp4j.MessageParams
import org.eclipse.lsp4j.MessageType import org.eclipse.lsp4j.MessageType
import org.eclipse.lsp4j.PublishDiagnosticsParams import org.eclipse.lsp4j.PublishDiagnosticsParams
...@@ -22,8 +23,8 @@ object Communicator : CommunicatorInterface { ...@@ -22,8 +23,8 @@ object Communicator : CommunicatorInterface {
* *
* @param diagnostics object containing the Diagnostics * @param diagnostics object containing the Diagnostics
*/ */
override fun publishDiagnostics(diagnostics: PublishDiagnosticsParams) { override fun publishDiagnostics(target :String, diagnostics : List<Diagnostic>) {
client.publishDiagnostics(diagnostics) client.publishDiagnostics(PublishDiagnosticsParams(target, diagnostics))
} }
/** /**
......
package b.language.server.communication package b.language.server.communication
import org.eclipse.lsp4j.Diagnostic
import org.eclipse.lsp4j.MessageType import org.eclipse.lsp4j.MessageType
import org.eclipse.lsp4j.PublishDiagnosticsParams import org.eclipse.lsp4j.PublishDiagnosticsParams
...@@ -13,7 +14,7 @@ interface CommunicatorInterface { ...@@ -13,7 +14,7 @@ interface CommunicatorInterface {
* *
* @param diagnostics object containing the Diagnostics * @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 * 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