Link syntax tree Span nodes
This commit is contained in:
parent
e3d2b48b89
commit
f4e9ddad22
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||
|
|
@ -88,6 +88,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
var rootBuilder = _blockStack.Pop();
|
||||
var root = rootBuilder.Build();
|
||||
|
||||
root.LinkNodes();
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||
|
|
@ -21,9 +22,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
[Fact]
|
||||
public void ParseMethodCallsParseDocumentOnMarkupParserAndReturnsResults()
|
||||
{
|
||||
var factory = new SpanFactory();
|
||||
|
||||
// Arrange
|
||||
var factory = new SpanFactory();
|
||||
var parser = new RazorParser();
|
||||
|
||||
// Act/Assert
|
||||
|
|
@ -41,9 +41,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
[Fact]
|
||||
public void ParseMethodUsesProvidedParserListenerIfSpecified()
|
||||
{
|
||||
var factory = new SpanFactory();
|
||||
|
||||
// Arrange
|
||||
var factory = new SpanFactory();
|
||||
var parser = new RazorParser();
|
||||
|
||||
// Act
|
||||
|
|
@ -60,5 +59,28 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||
factory.Markup(" baz")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_SyntaxTreeSpansAreLinked()
|
||||
{
|
||||
// Arrange
|
||||
var factory = new SpanFactory();
|
||||
var parser = new RazorParser();
|
||||
|
||||
// Act
|
||||
var results = parser.Parse(TestRazorSourceDocument.Create("foo @bar baz"));
|
||||
|
||||
// Assert
|
||||
var spans = results.Root.Flatten().ToArray();
|
||||
for (var i = 0; i < spans.Length - 1; i++)
|
||||
{
|
||||
Assert.Same(spans[i + 1], spans[i].Next);
|
||||
}
|
||||
|
||||
for (var i = spans.Length - 1; i > 0; i--)
|
||||
{
|
||||
Assert.Same(spans[i - 1], spans[i].Previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue