Skip to content
Snippets Groups Projects
Commit 492e4980 authored by SeeBasTStick's avatar SeeBasTStick
Browse files

moved from process exceution to process builder

output of executions should no longer fail to poor string formatting
OS which block until output/error is read are now supported
Added improved debugging support
parent 861f1095
Branches
Tags
No related merge requests found
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
...@@ -35,7 +35,7 @@ class BDocumentService(private val server: Server, private val communicator: Com ...@@ -35,7 +35,7 @@ class BDocumentService(private val server: Server, private val communicator: Com
*/ */
override fun didSave(params: DidSaveTextDocumentParams?) { override fun didSave(params: DidSaveTextDocumentParams?) {
communicator.sendDebugMessage("document ${params!!.textDocument.uri} was saved", MessageType.Info) communicator.bufferDebugMessage("document ${params!!.textDocument.uri} was saved", MessageType.Info)
val currentUri = params.textDocument.uri val currentUri = params.textDocument.uri
checkDocument(currentUri) checkDocument(currentUri)
...@@ -48,7 +48,7 @@ class BDocumentService(private val server: Server, private val communicator: Com ...@@ -48,7 +48,7 @@ class BDocumentService(private val server: Server, private val communicator: Com
fun checkDocument(currentUri : String){ fun checkDocument(currentUri : String){
val clientSettings = server.getDocumentSettings(currentUri) val clientSettings = server.getDocumentSettings(currentUri)
communicator.sendDebugMessage("waiting for document settings", MessageType.Info) communicator.bufferDebugMessage("waiting for document settings", MessageType.Info)
clientSettings.thenAccept{ settings -> clientSettings.thenAccept{ settings ->
communicator.setDebugMode(settings.debugMode) communicator.setDebugMode(settings.debugMode)
...@@ -108,7 +108,7 @@ class BDocumentService(private val server: Server, private val communicator: Com ...@@ -108,7 +108,7 @@ class BDocumentService(private val server: Server, private val communicator: Com
* Registration Options: TextDocumentChangeRegistrationOptions * Registration Options: TextDocumentChangeRegistrationOptions
*/ */
override fun didChange(params: DidChangeTextDocumentParams?) { override fun didChange(params: DidChangeTextDocumentParams?) {
communicator.sendDebugMessage("document ${params!!.textDocument.uri} was changed", MessageType.Info) communicator.bufferDebugMessage("document ${params!!.textDocument.uri} was changed", MessageType.Info)
val currentUri = params.textDocument.uri val currentUri = params.textDocument.uri
checkDocument(currentUri) checkDocument(currentUri)
} }
......
...@@ -16,7 +16,7 @@ class BWorkspaceService(private val server : Server) : WorkspaceService { ...@@ -16,7 +16,7 @@ class BWorkspaceService(private val server : Server) : WorkspaceService {
* the client detects changes to file watched by the language client. * the client detects changes to file watched by the language client.
*/ */
override fun didChangeWatchedFiles(params: DidChangeWatchedFilesParams?) { override fun didChangeWatchedFiles(params: DidChangeWatchedFilesParams?) {
Communicator.sendDebugMessage("----------changed watched files", MessageType.Info) Communicator.bufferDebugMessage("changed watched files", MessageType.Info)
// Not needed // Not needed
} }
...@@ -26,7 +26,7 @@ class BWorkspaceService(private val server : Server) : WorkspaceService { ...@@ -26,7 +26,7 @@ class BWorkspaceService(private val server : Server) : WorkspaceService {
* configuration settings. * configuration settings.
*/ */
override fun didChangeConfiguration(params: DidChangeConfigurationParams?) { override fun didChangeConfiguration(params: DidChangeConfigurationParams?) {
Communicator.sendDebugMessage("received change in configuration settings", MessageType.Info) Communicator.bufferDebugMessage("received change in configuration settings", MessageType.Info)
if(server.configurationAbility) { if(server.configurationAbility) {
server.documentSettings.clear() server.documentSettings.clear()
}else{ }else{
......
...@@ -83,7 +83,7 @@ class Server : LanguageServer{ ...@@ -83,7 +83,7 @@ class Server : LanguageServer{
* @return settings of the document requested * @return settings of the document requested
*/ */
fun getDocumentSettings(uri : String) : CompletableFuture<Settings> { fun getDocumentSettings(uri : String) : CompletableFuture<Settings> {
Communicator.sendDebugMessage("received configuration Data of the document $uri", MessageType.Info) Communicator.bufferDebugMessage("received configuration data of the document $uri", MessageType.Info)
return if(!configurationAbility){ return if(!configurationAbility){
val returnValue = CompletableFuture<Settings>() val returnValue = CompletableFuture<Settings>()
returnValue.complete(globalSettings) returnValue.complete(globalSettings)
......
...@@ -15,6 +15,7 @@ object Communicator : CommunicatorInterface { ...@@ -15,6 +15,7 @@ object Communicator : CommunicatorInterface {
lateinit var client : LanguageClient lateinit var client : LanguageClient
private var debugMode : Boolean = true private var debugMode : Boolean = true
private val storedMessages = mutableListOf<Pair<String, MessageType>>()
/** /**
* Sends the diagnostics * Sends the diagnostics
...@@ -32,7 +33,13 @@ object Communicator : CommunicatorInterface { ...@@ -32,7 +33,13 @@ object Communicator : CommunicatorInterface {
* @param severity the Severity of the message (Error/Info/Warning) * @param severity the Severity of the message (Error/Info/Warning)
*/ */
override fun sendDebugMessage(message: String, severity: MessageType) { override fun sendDebugMessage(message: String, severity: MessageType) {
if(debugMode) { if(debugMode) {
if(storedMessages.isNotEmpty()) {
storedMessages.toList().forEach { element -> client.logMessage(MessageParams(element.second, element.first)) }
storedMessages.clear()
}
client.logMessage(MessageParams(severity, message)) client.logMessage(MessageParams(severity, message))
} }
...@@ -57,4 +64,17 @@ object Communicator : CommunicatorInterface { ...@@ -57,4 +64,17 @@ object Communicator : CommunicatorInterface {
override fun setDebugMode(mode : Boolean){ override fun setDebugMode(mode : Boolean){
debugMode = mode debugMode = mode
} }
/**
* Can be used to store a messages until a "sendDebugMessage" command is sent. The messages will be sent as FIFO
* @param message the message to send
* @param severity tne message severity
*/
override fun bufferDebugMessage(message: String, severity: MessageType) {
if(debugMode) {
storedMessages.add(Pair(message, severity))
}
}
} }
\ No newline at end of file
...@@ -38,4 +38,12 @@ interface CommunicatorInterface { ...@@ -38,4 +38,12 @@ interface CommunicatorInterface {
* @param mode the new state of the debug mode * @param mode the new state of the debug mode
*/ */
fun setDebugMode(mode : Boolean) fun setDebugMode(mode : Boolean)
/**
* Can be used to store a messages until a "sendDebugMessage" command is sent. The messages will be sent as FIFO
* @param message the message to send
* @param severity tne message severity
*/
fun bufferDebugMessage(message : String, severity: MessageType)
} }
\ No newline at end of file
...@@ -64,7 +64,8 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte ...@@ -64,7 +64,8 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte
val typeCheckDefinitions = "TYPE_CHECK_DEFINITIONS" val typeCheckDefinitions = "TYPE_CHECK_DEFINITIONS"
val lint = "-lint" val lint = "-lint"
val tRUE = "TRUE" val tRUE = "TRUE"
val performanceHints = "PERFORMANCE_INFO" val performanceHints = "" +
"PERFORMANCE_INFO"
val command = mutableListOf<String>() val command = mutableListOf<String>()
...@@ -113,7 +114,7 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte ...@@ -113,7 +114,7 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte
.redirectError(ProcessBuilder.Redirect.PIPE) .redirectError(ProcessBuilder.Redirect.PIPE)
}catch (e : IllegalArgumentException){ }catch (e : IllegalArgumentException){
communicator.sendDebugMessage("illigal argument exception", MessageType.Info) communicator.sendDebugMessage("illegal argument exception", MessageType.Info)
} }
return ProcessBuilder() return ProcessBuilder()
} }
...@@ -144,16 +145,14 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte ...@@ -144,16 +145,14 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte
val process: Process = command.start() val process: Process = command.start()
// val output = InputStreamReader(process.inputStream)
// val error = InputStreamReader(process.errorStream)
val outputAsString = readFromStream(process.inputStream) val outputAsString = readFromStream(process.inputStream)
readFromStream(process.errorStream) readFromStream(process.errorStream) //just void error
// 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.waitFor() val exitStatus = process.waitFor()
communicator.sendDebugMessage("output of execution + ${exitStatus}", MessageType.Info) communicator.sendDebugMessage("exit status of execution: $exitStatus", MessageType.Info)
if(!outputAsString.contains("ProB Command Line Interface")){ if(!outputAsString.contains("ProB Command Line Interface")){
throw CommandCouldNotBeExecutedException("Error when trying to call probcli with command $command") 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