Skip to content
Snippets Groups Projects
Commit 2a466665 authored by SeeBasTStick's avatar SeeBasTStick
Browse files

fixed heavy bug concerning errors without span info would not shown as result

parent a2f921f0
Branches
Tags
No related merge requests found
......@@ -10,7 +10,7 @@ import java.util.concurrent.Future
fun main() {
println("opening connection and waiting ...")
val socket = ServerSocket(55556)
val socket = ServerSocket(55555)
val channel = socket.accept()
println("accepted connection from ${channel.inetAddress}")
startServer(channel.getInputStream(), channel.getOutputStream())
......
......@@ -16,6 +16,7 @@ import de.prob.scripting.ModelTranslationError
import de.prob.statespace.AnimationSelector
import de.prob.statespace.StateSpace
import de.prob.statespace.Trace
import kotlinx.coroutines.flow.flowViaChannel
import org.eclipse.lsp4j.Diagnostic
import org.eclipse.lsp4j.MessageType
import java.io.IOException
......@@ -44,14 +45,15 @@ class ProBKernel @Inject constructor(private val injector : Injector,
val factory = injector.getInstance(FactoryProvider.factoryClassFromExtension(path.substringAfterLast(".")))
val informationListener = InformationListener()
val informationListener = InformationListener(path)
animator.addWarningListener(informationListener)
val parseErrors = mutableListOf<Diagnostic>()
Communicator.sendDebugMessage("loading new machine", MessageType.Info)
val errors = mutableListOf<ErrorItem>()
val strictProblems = loadMachine(
{ stateSpace : StateSpace ->
{
stateSpace : StateSpace ->
try {
factory.extract(path).loadIntoStateSpace(stateSpace)
} catch (e: IOException) {
......@@ -59,14 +61,14 @@ class ProBKernel @Inject constructor(private val injector : Injector,
} catch (e: ModelTranslationError) {
communicator.sendDebugMessage("ModelTranslationError ${e.message}", MessageType.Info)
} catch (e : ProBError){
parseErrors.addAll(convertErrorItems(e.errors))
errors.addAll(e.errors)
}
Trace(stateSpace)
}, settings)
}, settings, path)
communicator.sendDebugMessage("returning from kernel", MessageType.Info)
communicator.sendDebugMessage("returning from kernel problems are ${strictProblems.toString()}", MessageType.Info)
return listOf(informationListener.getInformation(), parseErrors, strictProblems).flatten()
return listOf(informationListener.getInformation(), strictProblems, convertErrorItems(errors, path)).flatten()
}
/**
......@@ -74,28 +76,37 @@ class ProBKernel @Inject constructor(private val injector : Injector,
* @param newTraceCreator a anonymous function dealing with the state space
* @param settings the settings to be applied
*/
private fun loadMachine(newTraceCreator :java.util.function.Function<StateSpace, Trace>, settings: ProBSettings): List<Diagnostic> {
private fun loadMachine(newTraceCreator :java.util.function.Function<StateSpace, Trace>, settings: ProBSettings,
path : String): List<Diagnostic> {
communicator.sendDebugMessage("creating new state space", MessageType.Info)
val newStateSpace = animator.createStateSpace()
communicator.sendDebugMessage("setting preferences", MessageType.Info)
newStateSpace.changePreferences(prepareAdditionalSettings(settings))
val resultLint = mutableListOf<ErrorItem>() // see java doc of prepareAdditionalSettings
val errors = mutableListOf<ErrorItem>()
try {
communicator.sendDebugMessage("changing animation", MessageType.Info)
animationSelector.changeCurrentAnimation(newTraceCreator.apply(newStateSpace))
communicator.sendDebugMessage("done", MessageType.Info)
communicator.sendDebugMessage("executing optional steps", MessageType.Info)
executeAdditionalOptions(settings)
if (settings.strictChecks) {
resultLint.addAll(newStateSpace.performExtendedStaticChecks())
errors.addAll(newStateSpace.performExtendedStaticChecks())
}
communicator.sendDebugMessage("finished evaluation", MessageType.Info)
}catch (e: RuntimeException) {
communicator.sendDebugMessage("something bad happened, statespace was killed", MessageType.Warning)
newStateSpace.kill()
throw e
}
return convertErrorItems(resultLint)
communicator.sendDebugMessage("processing errors", MessageType.Info)
return convertErrorItems(errors, path)
}
......@@ -135,9 +146,14 @@ class ProBKernel @Inject constructor(private val injector : Injector,
if(proBSettings.performanceHints) {
settings["STRICT_CLASH_CHECKING"] = "TRUE"
settings["TYPE_CHECK_DEFINITIONS"] = "TRUE"
}else{
settings["STRICT_CLASH_CHECKING"] = "TRUE"
settings["TYPE_CHECK_DEFINITIONS"] = "TRUE"
}
if (proBSettings.strictChecks) {
settings["PERFORMANCE_INFO"] = "TRUE"
}else{
settings["PERFORMANCE_INFO"] = "TRUE"
}
return settings
}
......
......@@ -49,7 +49,7 @@ class ProBKernelManager(private val communicator : CommunicatorInterface) : ProB
return if(probNewHome != probHome)
{
if(probNewHome == "DEFAULT"){ //Use default prob
System.setProperty("prob.home", "DEFAULT")
System.setProperty("prob.home", "null")
kernel = setup()
probHome = probNewHome
true
......
......@@ -6,8 +6,8 @@ import org.eclipse.lsp4j.DiagnosticSeverity
import org.eclipse.lsp4j.Position
import org.eclipse.lsp4j.Range
fun convertErrorItems(errorItems: List<ErrorItem>) : List<Diagnostic>{
return errorItems.toList().map { errorItem ->
fun convertErrorItems(errorItems: List<ErrorItem>, currentLoadedFile : String) : List<Diagnostic>{
return errorItems.map { errorItem ->
errorItem.locations.map { location ->
Diagnostic(Range(
Position(location.startLine - 1, location.startColumn),
......@@ -15,6 +15,13 @@ fun convertErrorItems(errorItems: List<ErrorItem>) : List<Diagnostic>{
errorItem.message,
getErrorItemType(errorItem.type),
location.filename)
}.ifEmpty { //Fallback when errors from prob do not have position infos
listOf(Diagnostic(Range(
Position(0,0),
Position(0,0)),
errorItem.message,
getErrorItemType(errorItem.type),
currentLoadedFile))
}
}.flatten()
}
......@@ -30,9 +37,9 @@ fun getErrorItemType(errorItem: ErrorItem.Type) : DiagnosticSeverity{
ErrorItem.Type.INTERNAL_ERROR -> {
DiagnosticSeverity.Error
}
ErrorItem.Type.MESSAGE -> {
/* ErrorItem.Type.MESSAGE -> {
DiagnosticSeverity.Information
}
}*/
else -> {
DiagnosticSeverity.Error
}
......
package b.language.server.proBMangement.prob
import de.prob.animator.IInformationListener
import de.prob.animator.IWarningListener
import de.prob.animator.domainobjects.ErrorItem
import org.eclipse.lsp4j.Diagnostic
import org.eclipse.lsp4j.DiagnosticSeverity
/**
* Custom collector to collect warnings from prob kernel
*/
class InformationListener : IInformationListener {
class InformationListener(val fallbackPath : String) : IWarningListener {
private val warningList : ArrayList<ErrorItem> = arrayListOf()
override fun warningsOccurred(warnings: MutableList<ErrorItem>?) {
warningList.addAll(warnings!!.toList())
}
fun getInformation() : List<Diagnostic>{
return convertErrorItems(warningList)
return convertErrorItems(warningList, fallbackPath)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment