Microsoft.R.Editor.Tree.TextChangeAnalyzer.DetermineChangeType C# (CSharp) Method

DetermineChangeType() public static method

public static DetermineChangeType ( TextChangeContext change ) : void
change TextChangeContext
return void
        public static void DetermineChangeType(TextChangeContext change) {
            change.PendingChanges.TextChangeType |= CheckChangeInsideComment(change);
            if (change.PendingChanges.TextChangeType == TextChangeType.Comment) {
                return;
            } else if (change.PendingChanges.TextChangeType == TextChangeType.Trivial) {
                IAstNode node;
                PositionType positionType;

                change.PendingChanges.TextChangeType |= CheckChangeInsideString(change, out node, out positionType);
                if (change.PendingChanges.TextChangeType == TextChangeType.Token) {
                    return;
                } else if (node != null && change.PendingChanges.TextChangeType == TextChangeType.Trivial) {
                    change.PendingChanges.TextChangeType |= CheckWhiteSpaceChange(change, node, positionType);
                    if (change.PendingChanges.TextChangeType == TextChangeType.Trivial) {
                        return;
                    }
                }
            }

            change.PendingChanges.TextChangeType = TextChangeType.Structure;
            change.PendingChanges.FullParseRequired = true;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Text buffer change event handler. Performs analysis of the change.
        /// If change is trivial, such as change in whitespace (excluding line
        /// breaks that in R may be sensistive), simply applies the changes
        /// by shifting tree elements. If some elements get deleted or otherwise
        /// damaged, removes them from the tree right away. Non-trivial changes
        /// are queued for background parsing which starts on next on idle.
        /// Methond must be called on a main thread only, typically from an event
        /// handler that receives text buffer change events.
        /// </summary>
        internal void OnTextChanges(IReadOnlyCollection <TextChangeEventArgs> textChanges)
        {
            if (Thread.CurrentThread.ManagedThreadId != _ownerThreadId)
            {
                throw new ThreadStateException("Method should only be called on the main thread");
            }

            _editorTree.FireOnUpdatesPending(textChanges);
            if (UpdatesSuspended)
            {
                this.TextBufferChangedSinceSuspend = true;
                _pendingChanges.FullParseRequired  = true;
            }
            else
            {
                foreach (TextChangeEventArgs change in textChanges)
                {
                    _lastChangeTime = DateTime.UtcNow;
                    var context = new TextChangeContext(_editorTree, change, _pendingChanges);

                    // No need to analyze changes if full parse is already pending
                    if (!_pendingChanges.FullParseRequired)
                    {
                        TextChangeAnalyzer.DetermineChangeType(context);
                    }

                    ProcessChange(context);
                }
            }
        }
All Usage Examples Of Microsoft.R.Editor.Tree.TextChangeAnalyzer::DetermineChangeType