Skip to content
Snippets Groups Projects
Commit ea837ba6 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 2a96e47d
No related branches found
No related tags found
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
*/
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
checkDocument(currentUri)
......@@ -48,7 +48,7 @@ class BDocumentService(private val server: Server, private val communicator: Com
fun checkDocument(currentUri : String){
val clientSettings = server.getDocumentSettings(currentUri)
communicator.sendDebugMessage("waiting for document settings", MessageType.Info)
communicator.bufferDebugMessage("waiting for document settings", MessageType.Info)
clientSettings.thenAccept{ settings ->
communicator.setDebugMode(settings.debugMode)
......@@ -108,7 +108,7 @@ class BDocumentService(private val server: Server, private val communicator: Com
* Registration Options: TextDocumentChangeRegistrationOptions
*/
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
checkDocument(currentUri)
}
......
......@@ -16,7 +16,7 @@ class BWorkspaceService(private val server : Server) : WorkspaceService {
* the client detects changes to file watched by the language client.
*/
override fun didChangeWatchedFiles(params: DidChangeWatchedFilesParams?) {
Communicator.sendDebugMessage("----------changed watched files", MessageType.Info)
Communicator.bufferDebugMessage("changed watched files", MessageType.Info)
// Not needed
}
......@@ -26,7 +26,7 @@ class BWorkspaceService(private val server : Server) : WorkspaceService {
* configuration settings.
*/
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) {
server.documentSettings.clear()
}else{
......
......@@ -83,7 +83,7 @@ class Server : LanguageServer{
* @return settings of the document requested
*/
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){
val returnValue = CompletableFuture<Settings>()
returnValue.complete(globalSettings)
......
......@@ -15,6 +15,7 @@ object Communicator : CommunicatorInterface {
lateinit var client : LanguageClient
private var debugMode : Boolean = true
private val storedMessages = mutableListOf<Pair<String, MessageType>>()
/**
* Sends the diagnostics
......@@ -32,7 +33,13 @@ object Communicator : CommunicatorInterface {
* @param severity the Severity of the message (Error/Info/Warning)
*/
override fun sendDebugMessage(message: String, severity: MessageType) {
if(debugMode) {
if(storedMessages.isNotEmpty()) {
storedMessages.toList().forEach { element -> client.logMessage(MessageParams(element.second, element.first)) }
storedMessages.clear()
}
client.logMessage(MessageParams(severity, message))
}
......@@ -57,4 +64,17 @@ object Communicator : CommunicatorInterface {
override fun setDebugMode(mode : Boolean){
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 {
* @param mode the new state of the debug mode
*/
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
val typeCheckDefinitions = "TYPE_CHECK_DEFINITIONS"
val lint = "-lint"
val tRUE = "TRUE"
val performanceHints = "PERFORMANCE_INFO"
val performanceHints = "" +
"PERFORMANCE_INFO"
val command = mutableListOf<String>()
......@@ -113,7 +114,7 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte
.redirectError(ProcessBuilder.Redirect.PIPE)
}catch (e : IllegalArgumentException){
communicator.sendDebugMessage("illigal argument exception", MessageType.Info)
communicator.sendDebugMessage("illegal argument exception", MessageType.Info)
}
return ProcessBuilder()
}
......@@ -144,16 +145,14 @@ class ProBCommandLineAccess(val communicator : CommunicatorInterface) : ProBInte
val process: Process = command.start()
// val output = InputStreamReader(process.inputStream)
// val error = InputStreamReader(process.errorStream)
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
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")){
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