Example #1
0
        public void ApplyChange(int pairIndex, TriviaData data)
        {
            Contract.ThrowIfNull(data);
            Contract.ThrowIfFalse(0 <= pairIndex && pairIndex < this.TokenCount - 1);

            // do reference equality check
            var sameAsOriginal = GetOriginalTriviaData(pairIndex) == data;

            if (sameAsOriginal)
            {
                _changes.TryRemove(pairIndex);
            }
            else
            {
                _changes.AddOrReplace(pairIndex, data);
            }
        }
Example #2
0
 public bool TryGet(int key, out TriviaData triviaInfo)
 {
     triviaInfo = null;
     return(_map?.TryGetValue(key, out triviaInfo) ?? false);
 }
Example #3
0
        private void AddTextChanges(List <TextChange> list, SyntaxToken token1, SyntaxToken token2, TriviaData data)
        {
            var span           = TextSpan.FromBounds(token1.RawKind == 0 ? this.TreeInfo.StartPosition : token1.Span.End, token2.RawKind == 0 ? this.TreeInfo.EndPosition : token2.SpanStart);
            var originalString = this.TreeInfo.GetTextBetween(token1, token2);

            foreach (var change in data.GetTextChanges(span))
            {
                var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
                list.Add(change.SimpleDiff(oldText));
            }
        }
Example #4
0
 public void ApplyEndOfTreeChange(TriviaData data)
 {
     Contract.ThrowIfNull(data);
     _changes.AddOrReplace(Changes.EndOfTreeKey, data);
 }