Microsoft.R.Editor.Tree.EditorTree.FireOnUpdateCompleted C# (CSharp) Method

FireOnUpdateCompleted() private method

Fires 'update end' event on the main thread context
private FireOnUpdateCompleted ( TreeUpdateType updateType ) : void
updateType TreeUpdateType
return void
        internal void FireOnUpdateCompleted(TreeUpdateType updateType) {
            if (_ownerThread != Thread.CurrentThread.ManagedThreadId) {
                Debug.Fail(_threadContextInvalidMessage);
                return;
            }
            try {
                UpdateCompleted?.Invoke(this, new TreeUpdatedEventArgs(updateType));
            } catch (Exception ex) {
                Debug.Assert(false, Invariant($"Exception thrown in a tree.UpdateCompleted event handler: {ex.Message}"));
            }
        }
    }

Usage Example

Example #1
0
        /// <summary>
        /// Handles simple (safe) changes.
        /// </summary>
        private void ProcessSimpleChange(TextChangeContext context)
        {
            bool elementsRemoved = false;

            try {
                _editorTree.AcquireWriteLock();

                elementsRemoved = DeleteAndShiftElements(context);
                UpdateTreeTextSnapshot();

                // If no elements were invalidated and full parse is not required, clear pending changes
                if (!elementsRemoved)
                {
                    ClearChanges();
                }
            } finally {
                _editorTree.ReleaseWriteLock();
            }

            if (!elementsRemoved)
            {
                if (context.ChangedNode != null || context.PendingChanges.TextChangeType == TextChangeType.Trivial)
                {
                    _editorTree.FireOnPositionsOnlyChanged();
                }

                _editorTree.FireOnUpdateCompleted(TreeUpdateType.PositionsOnly);
            }
            else
            {
                _editorTree.FireOnUpdateCompleted(TreeUpdateType.NodesRemoved);
            }

            DebugTree.VerifyTree(_editorTree);
            Debug.Assert(_editorTree.AstRoot.Children.Count > 0);
        }