diff --git a/src/main/kotlin/b/language/server/BDocumentService.kt b/src/main/kotlin/b/language/server/BDocumentService.kt index a855090740691543bec38bacb84f537a00497c52..490e7e117f28b2fe38491db139d4d19584d5310d 100644 --- a/src/main/kotlin/b/language/server/BDocumentService.kt +++ b/src/main/kotlin/b/language/server/BDocumentService.kt @@ -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) } } diff --git a/src/main/kotlin/b/language/server/proBMangement/ProBCommandLineAccess.kt b/src/main/kotlin/b/language/server/proBMangement/ProBCommandLineAccess.kt index bd34568fadb8db891f9b5272cabf28f770deb028..a75f679e22a6e47da742ac747ac7e9fa0982b975 100644 --- a/src/main/kotlin/b/language/server/proBMangement/ProBCommandLineAccess.kt +++ b/src/main/kotlin/b/language/server/proBMangement/ProBCommandLineAccess.kt @@ -1,6 +1,5 @@ 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 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") }