private static void ParseSrc(
            string srcPath,
            Dictionary <Uri, ParseResult> externals,
            OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer router,
            ParsedDocumentsManager parsedDocumentsManager)
        {
            router.Window.LogInfo($"Parsing Gothic.Src. This might take a while.");
            var parseResults = FastCompiler.ParseSrc(srcPath, externals);

            foreach (var parseResult in parseResults)
            {
                parsedDocumentsManager.UpdateParseResult(parseResult.Key, parseResult.Value);
            }
            router.Window.LogInfo($"Parsed {parseResults.Count} scripts");

            var diagnostics = new List <PublishDiagnosticsParams>();

            foreach (var kvp in parseResults)
            {
                if (kvp.Value.SyntaxErrors.Count > 0)
                {
                    diagnostics.Add(new PublishDiagnosticsParams
                    {
                        Uri         = kvp.Key,
                        Diagnostics = new Container <Diagnostic>(
                            kvp.Value.SyntaxErrors.Select(x => new Diagnostic
                        {
                            Severity = ParsedDocumentsManager.DiagnosticSeverityFromSyntaxError(x),
                            Message  = x.ErrorCode.Description,
                            Code     = x.ErrorCode.Code,
                            Range    = new OmniSharp.Extensions.LanguageServer.Protocol.Models.Range(
                                new Position(x.Line - 1, x.Column),
                                new Position(x.Line - 1, x.Column)
                                )
                        }))
                    });
                }
            }
            foreach (var dp in diagnostics)
            {
                router.Document.PublishDiagnostics(dp);
            }
        }
示例#2
0
 public ServerInit(OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer router)
 {
     _router = router;
 }
 public TextDocumentHandler(OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer router,
                            IInjectionWorkspace injectionWorkspace)
 {
     _router = router;
     this.injectionWorkspace = injectionWorkspace;
 }