コード例 #1
0
        private void MonitorParentProcess(InitializeParams p)
        {
            // Monitor parent process
            Process parentProcess = null;

            if (p.processId.HasValue)
            {
                try {
                    parentProcess = Process.GetProcessById(p.processId.Value);
                } catch (ArgumentException) { }

                Debug.Assert(parentProcess != null, "Parent process does not exist");
                if (parentProcess != null)
                {
                    parentProcess.Exited += (s, e) => _sessionTokenSource.Cancel();
                }
            }

            if (parentProcess != null)
            {
                Task.Run(async() => {
                    while (!_sessionTokenSource.IsCancellationRequested)
                    {
                        await Task.Delay(2000);
                        if (parentProcess.HasExited)
                        {
                            _sessionTokenSource.Cancel();
                        }
                    }
                }).DoNotWait();
            }
        }
コード例 #2
0
        public InitializeResult initialize(JToken token, CancellationToken ct)
        {
            _initParams = token.ToObject <InitializeParams>();
            MonitorParentProcess(_initParams);

            return(new InitializeResult {
                capabilities = new ServerCapabilities {
                    hoverProvider = true,
                    signatureHelpProvider = new SignatureHelpOptions {
                        triggerCharacters = new[] { "(", ",", ")" }
                    },
                    completionProvider = new CompletionOptions {
                        resolveProvider = true,
                        triggerCharacters = new[] { ".", ":", "$", "<", "%" }
                    },
                    textDocumentSync = new TextDocumentSyncOptions {
                        openClose = true,
                        willSave = true,
                        change = TextDocumentSyncKind.Incremental
                    },
                    documentFormattingProvider = true,
                    documentRangeFormattingProvider = true,
                    documentOnTypeFormattingProvider = new DocumentOnTypeFormattingOptions {
                        firstTriggerCharacter = ";",
                        moreTriggerCharacter = new[] { "}", "\n" }
                    },
                    documentSymbolProvider = true,
                    executeCommandProvider = new ExecuteCommandOptions {
                        commands = Controller.Commands
                    }
                }
            });
        }