diff --git a/.vscode/settings.json b/.vscode/settings.json index 436b91041ec3748fa819e6ce48219f02cdb42c84..417f25a8992e697bc38965905d06d5b3541da8ae 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,5 +7,5 @@ "source.fixAll.eslint": true }, "languageServer.wdChecks": false, - "languageServer.probHome": "/home/sebastian/prb_prolog/probcli.sh" + "languageServer.probHome": "/home/sebastian/prob_prolog/probcli" } \ No newline at end of file diff --git a/server/src/errorHandler.ts b/server/src/errorHandler.ts index 1abc44dce6112fe29821fe2f8536b791b2a8eb8c..10af895c81446f51ac391dd3332806b0aa300d01 100644 --- a/server/src/errorHandler.ts +++ b/server/src/errorHandler.ts @@ -98,7 +98,7 @@ export function matchErrors(infos: Set<NDJSON>, file?: TextDocument | undefined) } }, message: content.message, - source: 'prob_prolog', + source: content.file, }; diff --git a/server/src/server.ts b/server/src/server.ts index 47c2b0f2b67a42dc84cd6cc96780a3ee0d9f856a..89ad54f06f9404cbb631dacb3deeb45cf32e81dd 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -22,6 +22,8 @@ import * as fs from 'fs'; import { NDJSON, readErrors, matchErrors } from './errorHandler'; import * as wordComplition from './wordCompletion' import * as path from 'path'; +import * as URL from 'url' +//import * as uri2path from 'file-uri-to-path' @@ -196,19 +198,43 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> { let diagnostics: Array<Diagnostic> = new Array() if(result.size != 0) { + let mainFileWritten : boolean = false; for (let entry of result) { if (entry[0] == textDocument.uri) { diagnostics = matchErrors(entry[1], textDocument) } else { diagnostics = matchErrors(entry[1]) } + connection.sendDiagnostics({ uri: entry[0], diagnostics }); + + /** + * TL;DR we need to cast here to clean the main file + * + * This is a little bit of a mess here: Problem the paths in the _error.json a system relevant + * and system centered e.g. /home/sebastian... + * + * The URI from the textdocument is domain centered e.g. file///home/sebastian in order to deal + * with remote files like serverXYZ///home/michael + * + * However the extension.ts can deal with system centric paths and uris, but we need a comparision + * so we have to cast here... + */ + if(URI.parse(entry[0]).toString() == textDocument.uri){ + mainFileWritten = true + } + } + + if(mainFileWritten == false){ + // The main file has no errors, we need to reset it... + diagnostics = new Array() + connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); + } } else{ connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); } - }, function (err) { connection.sendNotification("parse_error_prob", "there are things wrong with the parse results " + err) }); @@ -218,9 +244,7 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> { { connection.sendNotification("path_error_prob", "could not call/reach probcli "+ command) } - - console.log(command) - + }) }