Skip to content
Snippets Groups Projects
Commit 659ece85 authored by SeeBasTStick's avatar SeeBasTStick
Browse files

fixed bug where error from failing probcli (due to wrong path) was not shown

parent 8b1af340
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import b.language.server.proBMangement.ProBCommandLineAccess
import b.language.server.proBMangement.ProBInterface
import org.eclipse.lsp4j.*
import org.eclipse.lsp4j.services.TextDocumentService
import java.io.IOException
import java.util.concurrent.ConcurrentHashMap
class BDocumentService(private val server: Server, private val communicator: CommunicatorInterface) : TextDocumentService {
......@@ -64,8 +65,13 @@ class BDocumentService(private val server: Server, private val communicator: Com
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)
}catch (e : CommandCouldNotBeExecutedException){
communicator.sendDebugMessage("command could not be executed", MessageType.Info)
communicator.showMessage(e.message!!, MessageType.Error)
}catch (e : IOException){
communicator.sendDebugMessage("command could not be executed", MessageType.Info)
communicator.showMessage(e.message!!, MessageType.Error)
}
}
......
package b.language.server.proBMangement
import b.language.server.communication.Communicator
import b.language.server.communication.CommunicatorInterface
import b.language.server.dataStorage.Problem
import b.language.server.dataStorage.Settings
......@@ -90,7 +89,7 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte
* @return success of the action
*/
fun createFolder(errorDict : File, errorPath: File) : Boolean{
communicator.sendDebugMessage("creating errorDict $errorDict and errorFile $errorPath", MessageType.Info)
communicator.sendDebugMessage("creating -----huhu----- errorDict $errorDict and errorFile $errorPath", MessageType.Info)
errorDict.mkdirs()
FileWriter(errorPath, false).close()
return errorDict.exists() && errorPath.exists()
......@@ -99,15 +98,20 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte
/**
* Executes the given command
* @param command to execute
* @throws CommandCouldNotBeExecutedException the command failed to reach probcli
* @throws CommandCouldNotBeExecutedException probcli failed to execute the given command
* @throws IOException failed to reach probcli
*/
fun performActionOnDocument(command : String) {
val process: Process = Runtime.getRuntime().exec(command)
val output : InputStream = process.inputStream
process.waitFor() //we must wait here to ensure correct behavior when reading an error
// process.waitFor() //we must wait here to ensure correct behavior when reading an error
val exitStatus = process.onExit()
val outputAsString = String(output.readAllBytes())
communicator.sendDebugMessage("output of execution + ${exitStatus.isCompletedExceptionally}", MessageType.Info)
if(!outputAsString.contains("ProB Command Line Interface")){
throw CommandCouldNotBeExecutedException("Error when trying to call probcli with command $command")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment