protected virtual SpanBuilder UpdateSpan(Span target, TextChange normalizedChange) { string newContent = normalizedChange.ApplyChange(target); SpanBuilder newSpan = new SpanBuilder(target); newSpan.ClearSymbols(); foreach (ISymbol sym in Tokenizer(newContent)) { sym.OffsetStart(target.Start); newSpan.Accept(sym); } if (target.Next != null) { SourceLocation newEnd = SourceLocationTracker.CalculateNewLocation(target.Start, newContent); target.Next.ChangeStart(newEnd); } return newSpan; }
private PartialParseResult TryAcceptChange(Span target, TextChange change, PartialParseResult acceptResult = PartialParseResult.Accepted) { string content = change.ApplyChange(target); if (StartsWithKeyword(content)) { return PartialParseResult.Rejected | PartialParseResult.SpanContextChanged; } return acceptResult; }
public void ApplyChangeWithReplacedTextReturnsNewContentWithChangeApplied() { // Arrange var newBuffer = new StringTextBuffer("abcdefg"); var oldBuffer = new StringTextBuffer(""); var textChange = new TextChange(1, 1, oldBuffer, 2, newBuffer); // Act string text = textChange.ApplyChange("abcdefg", 1); // Assert Assert.Equal("bcbcdefg", text); }
public void ApplyChangeWithInsertedTextReturnsNewContentWithChangeApplied() { // Arrange var newBuffer = new StringTextBuffer("test"); var oldBuffer = new StringTextBuffer(""); var textChange = new TextChange(0, 0, oldBuffer, 3, newBuffer); // Act string text = textChange.ApplyChange("abcd", 0); // Assert Assert.Equal("tesabcd", text); }
private void UpdateContent(TextChange change) { // Update the span's content Content = change.ApplyChange(this); ClearCachedStartPoints(Next); }