void compileAndSubmitErrors(DocumentUri document, string text) { var documentPath = UpdateBuffer(document, text); bool foundError = false; try { var co = new PragmaScript.CompilerOptionsBuild { inputFilename = document.GetFileSystemPath(), buildExecuteable = false, lib_path = new List <string>(), libs = new List <string>(), include_dirs = new List <string> { includeDirectory } }; var(rootScope, tc) = compiler.Compile(co); buffers.Annotate(documentPath, rootScope, tc); } catch (CompilerError error) { var process = System.Diagnostics.Process.GetCurrentProcess(); var diag = new Diagnostic { Message = $"{process.ProcessName}::{process.Id}: " + error.message, Severity = DiagnosticSeverity.Error, Range = new OmniSharp.Extensions.LanguageServer.Protocol.Models.Range(new Position(error.token.Line - 1, error.token.Pos - 1), new Position(error.token.Line - 1, error.token.Pos - 1 + error.token.length)), }; DocumentUri uri; if (error.token == Token.Undefined) { uri = document; } else { uri = DocumentUri.FromFileSystemPath(error.token.filename); } router.TextDocument.PublishDiagnostics(new PublishDiagnosticsParams { Diagnostics = new List <Diagnostic> { diag }, Uri = uri, }); foundError = true; } catch (Exception) { foundError = true; } if (!foundError) { router.TextDocument.PublishDiagnostics(new PublishDiagnosticsParams { Diagnostics = new List <Diagnostic> { }, Uri = document, }); } }