public override void DidChangeTextDocument(DidChangeTextDocumentParams @params) { _analyzerCreationTask.Wait(); var openedFile = _openFiles.GetDocument(@params.textDocument.uri); openedFile.DidChangeTextDocument(@params, doc => EnqueueItem(doc, enqueueForAnalysis: @params._enqueueForAnalysis ?? true)); }
public override void DidChangeTextDocument(DidChangeTextDocumentParams @params) { ThrowIfDisposed(); var openedFile = _editorFiles.GetDocument(@params.textDocument.uri); openedFile.DidChangeTextDocument(@params, doc => EnqueueItem(doc, enqueueForAnalysis: @params._enqueueForAnalysis ?? true)); }
public override void DidChangeTextDocument(DidChangeTextDocumentParams @params) { ThrowIfDisposed(); var openedFile = _editorFiles.GetDocument(@params.textDocument.uri); openedFile.DidChangeTextDocument(@params, true); }
public void DidChangeTextDocument(DidChangeTextDocumentParams @params, Action <IDocument> enqueueAction) { var changes = @params.contentChanges; if (changes == null || changes.Length == 0) { return; } var uri = @params.textDocument.uri; var doc = _server.ProjectFiles.GetEntry(uri) as IDocument; if (doc == null) { return; } try { var part = _server.ProjectFiles.GetPart(uri); _server.TraceMessage($"Received changes for {uri}"); var docVersion = Math.Max(doc.GetDocumentVersion(part), 0); var fromVersion = Math.Max(@params.textDocument.version - 1 ?? docVersion, 0); if (fromVersion > docVersion && @params.contentChanges?.Any(c => c.range == null) != true) { // Expected from version hasn't been seen yet, and there are no resets in this // change, so enqueue it for later. _server.TraceMessage($"Deferring changes for {uri} until version {fromVersion} is seen"); lock (_pendingChanges) { _pendingChanges.Add(@params); } return; } var toVersion = @params.textDocument.version ?? (fromVersion + changes.Length); doc.UpdateDocument(part, new DocumentChangeSet( fromVersion, toVersion, changes.Select(c => new DocumentChange { ReplacedSpan = c.range.GetValueOrDefault(), WholeBuffer = !c.range.HasValue, InsertedText = c.text }) )); DidChangeTextDocumentParams?next = null; lock (_pendingChanges) { var notExpired = _pendingChanges .Where(p => p.textDocument.version.GetValueOrDefault() >= toVersion) .OrderBy(p => p.textDocument.version.GetValueOrDefault()) .ToArray(); _pendingChanges.Clear(); if (notExpired.Any()) { next = notExpired.First(); _pendingChanges.AddRange(notExpired.Skip(1)); } } if (next.HasValue) { DidChangeTextDocument(next.Value, null); } } finally { if (enqueueAction != null) { _server.TraceMessage($"Applied changes to {uri}"); enqueueAction(doc); } } }
public virtual void DidChangeTextDocument(DidChangeTextDocumentParams @params) { }
public virtual async Task DidChangeTextDocument(DidChangeTextDocumentParams @params) { }
public override async Task DidChangeTextDocument(DidChangeTextDocumentParams @params) { var changes = @params.contentChanges; if (changes == null) { return; } var uri = @params.textDocument.uri; var entry = GetEntry(uri); int part = GetPart(uri); TraceMessage($"Received changes for {uri}"); if (entry is IDocument doc) { int docVersion = Math.Max(doc.GetDocumentVersion(part), 0); int fromVersion = Math.Max(@params.textDocument.version - 1 ?? docVersion, 0); List <DidChangeTextDocumentParams> pending; if (fromVersion > docVersion && @params.contentChanges?.Any(c => c.range == null) != true) { // Expected from version hasn't been seen yet, and there are no resets in this // change, so enqueue it for later. LogMessage(MessageType.Log, $"Deferring changes for {uri} until version {fromVersion} is seen"); pending = _pendingChanges.GetOrAdd(uri, _ => new List <DidChangeTextDocumentParams>()); lock (pending) { pending.Add(@params); } return; } int toVersion = @params.textDocument.version ?? (fromVersion + changes.Length); doc.UpdateDocument(part, new DocumentChangeSet( fromVersion, toVersion, changes.Select(c => new DocumentChange { ReplacedSpan = c.range.GetValueOrDefault(), WholeBuffer = !c.range.HasValue, InsertedText = c.text }) )); if (_pendingChanges.TryGetValue(uri, out pending) && pending != null) { DidChangeTextDocumentParams?next = null; lock (pending) { var notExpired = pending.Where(p => p.textDocument.version.GetValueOrDefault() >= toVersion).OrderBy(p => p.textDocument.version.GetValueOrDefault()).ToArray(); if (notExpired.Any()) { pending.Clear(); next = notExpired.First(); pending.AddRange(notExpired.Skip(1)); } else { _pendingChanges.TryRemove(uri, out _); } } if (next.HasValue) { await DidChangeTextDocument(next.Value); return; } } TraceMessage($"Applied changes to {uri}"); EnqueueItem(doc); } }
public virtual Task DidChangeTextDocument(DidChangeTextDocumentParams @params) => Task.CompletedTask;