コード例 #1
0
 private static async Task DidChange(
     TestLspServer testLspServer,
     LSP.DidChangeTextDocumentParams didChangeParams
     )
 {
     await testLspServer.ExecuteRequestAsync <LSP.DidChangeTextDocumentParams, object>(
         Methods.TextDocumentDidChangeName,
         didChangeParams,
         new LSP.ClientCapabilities(),
         null,
         CancellationToken.None
         );
 }
コード例 #2
0
        private async Task OnReplDidChangeTextDocumentAsync(ITextSnapshot before, ITextSnapshot after, IEnumerable <ITextChange> textChanges)
        {
            var contentChanges = new List <LSP.TextDocumentContentChangeEvent>();

            // The changes in textChanges all apply to the same original document state. The changes sent to the
            // server are expected to apply to the state as of the previous change in the list. To prevent the
            // changes from affecting one another we reverse the list.
            foreach (var textChange in textChanges.Reverse())
            {
                var changeEvent = new LSP.TextDocumentContentChangeEvent {
                    Text  = textChange.NewText,
                    Range = new LSP.Range {
                        Start = new LSP.Position {
                            Line      = before.GetLineNumberFromPosition(textChange.OldSpan.Start) + _previousCellsLineCount,
                            Character = textChange.OldSpan.Start - before.GetLineFromPosition(textChange.OldSpan.Start).Start.Position
                        },
                        End = new LSP.Position {
                            Line      = before.GetLineNumberFromPosition(textChange.OldSpan.End) + _previousCellsLineCount,
                            Character = textChange.OldSpan.End - before.GetLineFromPosition(textChange.OldSpan.End).Start.Position
                        },
                    },
                    RangeLength = textChange.OldSpan.Length
                };

                contentChanges.Add(changeEvent);
            }

            _version++;

            var changesOnlyParam = new LSP.DidChangeTextDocumentParams {
                ContentChanges = contentChanges.ToArray(),
                TextDocument   = new LSP.VersionedTextDocumentIdentifier {
                    Version = _version,
                    Uri     = new Uri(Path.GetFullPath(_tempFilePath)),
                }
            };

            await _client.InvokeTextDocumentDidChangeAsync(changesOnlyParam);
        }
コード例 #3
0
ファイル: PythonLanguageClient.cs プロジェクト: int19h/PTVS
 public Task InvokeTextDocumentDidChangeAsync(LSP.DidChangeTextDocumentParams request)
 => NotifyWithParametersAsync("textDocument/didChange", request);
コード例 #4
0
 private static async Task DidChange(RequestExecutionQueue queue, Solution solution, LSP.DidChangeTextDocumentParams didChangeParams)
 {
     await GetLanguageServer(solution).ExecuteRequestAsync <LSP.DidChangeTextDocumentParams, object>(queue, Methods.TextDocumentDidChangeName,
                                                                                                     didChangeParams, new LSP.ClientCapabilities(), null, CancellationToken.None);
 }