public void GetOrigninalText_SpanIsOwner_ReturnsContent_ZeroLengthSpan()
        {
            // Arrange
            var builder = new SpanBuilder(new SourceLocation(13, 0, 0));

            builder.Accept(new RawTextSymbol(new SourceLocation(13, 0, 13), "Hello, "));
            builder.Accept(new RawTextSymbol(new SourceLocation(20, 0, 20), "World"));

            var span = new Span(builder);

            var change = new SourceChange(15, 0, "heyo");

            // Act
            var result = change.GetOriginalText(span);

            // Act
            Assert.Equal(string.Empty, result);
        }
        public void GetOrigninalText_SpanIsOwner_ReturnsContent_ZeroLengthSpan()
        {
            // Arrange
            var builder = SyntaxListBuilder <SyntaxToken> .Create();

            builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "Hello, "));
            builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "World"));

            var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(null, 13);

            var change = new SourceChange(15, 0, "heyo");

            // Act
            var result = change.GetOriginalText(node);

            // Act
            Assert.Equal(string.Empty, result);
        }
        protected override PartialParseResultInternal CanAcceptChange(SyntaxNode target, SourceChange change)
        {
            if (AcceptedCharacters == AcceptedCharactersInternal.NonWhitespace)
            {
                var originalText  = change.GetOriginalText(target);
                var editedContent = change.GetEditedContent(target);

                if (!ContainsWhitespace(originalText) && !ContainsWhitespace(editedContent))
                {
                    // Did not modify whitespace, directive format should be the same.
                    // Return provisional so extensible IR/code gen pieces can see the full directive text
                    // once the user stops editing the document.
                    return(PartialParseResultInternal.Accepted | PartialParseResultInternal.Provisional);
                }
            }

            return(PartialParseResultInternal.Rejected);
        }
Esempio n. 4
0
        public void GetOrigninalText_SpanIsOwner_ReturnsContent_ZeroLengthSpan()
        {
            // Arrange
            var builder = new SpanBuilder(new SourceLocation(13, 0, 0));

            builder.Accept(SyntaxFactory.Token(SyntaxKind.Unknown, "Hello, "));
            builder.Accept(SyntaxFactory.Token(SyntaxKind.Unknown, "World"));

            var span = new Span(builder);

            var change = new SourceChange(15, 0, "heyo");

            // Act
            var result = change.GetOriginalText(span);

            // Act
            Assert.Equal(string.Empty, result);
        }