protected override void GetChanges(TextChangeSet changeSet) { var insertPosition = _selectQuery.SelectClause.LastToken().Span.End; var text = GetInsertionText(); changeSet.InsertText(insertPosition, text); }
protected override void GetChanges(TextChangeSet changeSet) { var position = GetInsertPosition(); var text = GetTextToInsert(); changeSet.InsertText(position, text); }
public virtual SyntaxTree GetEdit() { var changeSet = new TextChangeSet(); GetChanges(changeSet); return(_syntaxTree.WithChanges(changeSet)); }
protected override void GetChanges(TextChangeSet changeSet) { var location = _node.SyntaxTree.Text.GetTextLocation(_node.Span.Start); var indent = location.Column; var columnString = BuildColumns(indent, _columnInstances); changeSet.ReplaceText(_node.Span, columnString); }
protected override void GetChanges(TextChangeSet changeSet) { var start = _recursiveKeyword.Span.Start; var end = _recursiveKeyword.FullSpan.End; var span = TextSpan.FromBounds(start, end); changeSet.DeleteText(span); }
protected override void GetChanges(TextChangeSet changeSet) { var text = _original.SyntaxTree.Text; var expressionText = text.GetText(_expression.Span); var lowerBoundText = text.GetText(_lowerBound.Span); var upperBoundText = text.GetText(_uppperBound.Span); var newText = $"{expressionText} BETWEEN {lowerBoundText} AND {upperBoundText}"; changeSet.ReplaceText(_original.Span, newText); }
public void TextChangeSet_AddsInsertion() { var changeSet = new TextChangeSet(); changeSet.InsertText(42, "abc"); var change = Assert.Single(changeSet); Assert.Equal(new TextSpan(42, 0), change.Span); Assert.Equal("abc", change.NewText); }
public void TextChangeSet_AddsReplacement() { var changeSet = new TextChangeSet(); changeSet.ReplaceText(new TextSpan(4, 2), "abc"); var change = Assert.Single(changeSet); Assert.Equal(new TextSpan(4, 2), change.Span); Assert.Equal("abc", change.NewText); }
public void TextChangeSet_AddsDeletion() { var changeSet = new TextChangeSet(); changeSet.DeleteText(new TextSpan(4, 2)); var change = Assert.Single(changeSet); Assert.Equal(new TextSpan(4, 2), change.Span); Assert.Equal(string.Empty, change.NewText); }
public void TextChangeSet_DisallowsIntersectingChanges() { var changeSet = new TextChangeSet(); changeSet.DeleteText(new TextSpan(4, 2)); var ex = Assert.Throws <InvalidOperationException>(() => { changeSet.InsertText(5, "abc"); }); Assert.Equal("Cannot apply change '[5,5) => {abc}' because it intersects with another pending change.", ex.Message); }
protected override void GetChanges(TextChangeSet changeSet) { var operatorSpan = _node.OperatorToken.Span; var leftSpan = _node.Left.Span; var rightSpan = _node.Right.Span; var text = _node.SyntaxTree.Text; var left = text.GetText(leftSpan); var right = text.GetText(rightSpan); changeSet.ReplaceText(leftSpan, right); changeSet.ReplaceText(operatorSpan, _swappedOperatorText); changeSet.ReplaceText(rightSpan, left); }
protected override void GetChanges(TextChangeSet changeSet) { var modifier = _node.Modifier; if (modifier == null) { changeSet.InsertText(_node.Span.End, @" DESC"); } else { var newKeyword = modifier.Kind == SyntaxKind.AscKeyword ? @"DESC" : @"ASC"; changeSet.ReplaceText(modifier.Span, newKeyword); } }
public void TextChangeSet_ReturnsChangesInExecutionOrder() { var changeSet = new TextChangeSet(); changeSet.ReplaceText(new TextSpan(10, 2), "xyz"); changeSet.InsertText(1, "ab"); changeSet.DeleteText(new TextSpan(4, 2)); var expectedChanges = new[] { new TextChange(new TextSpan(10, 2), "xyz"), new TextChange(new TextSpan(1, 0), "ab"), new TextChange(new TextSpan(4, 2), string.Empty), }; Assert.Equal(expectedChanges, changeSet); }
protected override void GetChanges(TextChangeSet changeSet) { var newText = _isEquals ? @" IS NULL" : @" IS NOT NULL"; var useLeft = IsNullLiteral(_node.Right); if (useLeft) { var replacementSpan = TextSpan.FromBounds(_node.Left.Span.End, _node.Span.End); changeSet.ReplaceText(replacementSpan, newText); } else { var removalSpan = TextSpan.FromBounds(_node.Span.Start, _node.Right.Span.Start); changeSet.DeleteText(removalSpan); changeSet.InsertText(_node.Right.Span.End, newText); } }
protected override void GetChanges(TextChangeSet changeSet) { var previousToken = _node.FirstToken().GetPreviousToken(); var nextToken = _node.LastToken().GetNextToken(); var isFirst = previousToken.Kind == SyntaxKind.WithKeyword; var isLast = nextToken.Kind != SyntaxKind.CommaToken; var isSingle = isFirst && isLast; var removePreviousToken = isLast; var removeNextToken = !isLast; var start = removePreviousToken ? previousToken.Span.Start : _node.FullSpan.Start; var end = removeNextToken ? nextToken.FullSpan.End : isSingle ? nextToken.Span.Start : _node.Span.End; var span = TextSpan.FromBounds(start, end); changeSet.DeleteText(span); }
protected override void GetChanges(TextChangeSet changeSet) { changeSet.DeleteText(_expression.LeftParenthesis.Span); changeSet.DeleteText(_expression.RightParenthesis.Span); }
protected override void GetChanges(TextChangeSet changeSet) { changeSet.ReplaceText(_selector.Span, _columnReference); }
protected override void GetChanges(TextChangeSet changeSet) { changeSet.ReplaceText(_columnListSpan, @"*"); }
protected override void GetChanges(TextChangeSet changeSet) { changeSet.InsertText(_keyword.Span.Start, GetKeywordText() + @" "); }
protected virtual void GetChanges(TextChangeSet changeSet) { }
protected override void GetChanges(TextChangeSet changeSet) { changeSet.ReplaceText(_token.Span, _token.ValueText); }
protected override void GetChanges(TextChangeSet changeSet) { changeSet.InsertText(_node.Span.End, @" ASC"); }
protected override void GetChanges(TextChangeSet changeSet) { var span = TextSpan.FromBounds(_node.ColumnSelector.Span.End, _node.Modifier.Span.End); changeSet.DeleteText(span); }
protected override void GetChanges(TextChangeSet changeSet) { var position = _node.Span.End; changeSet.InsertText(position, @"()"); }
protected override void GetChanges(TextChangeSet changeSet) { changeSet.InsertText(_node.Name.Span.Start, @"AS "); }
protected override void GetChanges(TextChangeSet changeSet) { var name = SyntaxFacts.GetValidIdentifier(_symbol.TableInstance.Name); changeSet.InsertText(_node.Span.Start, name + @"."); }