public LanguageServer(Stream sender, Stream reader, List <DiagnosticsInfo> initialDiagnostics = null)
        {
            var jsonRpcTraceSource = LogUtils.CreateTraceSource();

            this.target            = new LanguageServerTarget(this, jsonRpcTraceSource);
            this.messageHandler    = new HeaderDelimitedMessageHandler(sender, reader);
            this.rpc               = new JsonRpc(this.messageHandler, this.target);
            this.rpc.Disconnected += OnRpcDisconnected;

            this.rpc.ActivityTracingStrategy = new CorrelationManagerTracingStrategy()
            {
                TraceSource = jsonRpcTraceSource,
            };
            this.rpc.TraceSource = jsonRpcTraceSource;

            ((JsonMessageFormatter)this.messageHandler.Formatter).JsonSerializer.Converters.Add(new VSExtensionConverter <TextDocumentIdentifier, VSTextDocumentIdentifier>());

            this.rpc.StartListening();

            this.diagnostics        = initialDiagnostics;
            this.diagnosticsResults = new Dictionary <VSTextDocumentIdentifier, int>();

            this.FoldingRanges = Array.Empty <FoldingRange>();
            this.Symbols       = Array.Empty <VSSymbolInformation>();

            this.target.OnInitializeCompletion += OnTargetInitializeCompletion;
            this.target.OnInitialized          += OnTargetInitialized;
        }
示例#2
0
        public LanguageServer(Stream sender, Stream reader, Dictionary <string, DiagnosticSeverity> initialDiagnostics = null)
        {
            this.target            = new LanguageServerTarget(this);
            this.rpc               = JsonRpc.Attach(sender, reader, this.target);
            this.rpc.Disconnected += OnRpcDisconnected;
            this.diagnostics       = initialDiagnostics;

            this.target.Initialized += OnInitialized;
        }