Rename BlockType -> BlockKind

Also moved BlockKind and SpanKind out of .Legacy
This commit is contained in:
Ryan Nowak 2017-03-19 11:18:40 -07:00
parent 0aee9152bd
commit acbbdf0b2c
23 changed files with 153 additions and 153 deletions

View File

@ -1,9 +1,9 @@
// 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.Evolution.Legacy
namespace Microsoft.AspNetCore.Razor.Evolution
{
internal enum BlockType
public enum BlockKind
{
// Code
Statement,

View File

@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
source.Reset();
}
protected Block(BlockType? type, IReadOnlyList<SyntaxTreeNode> children, IParentChunkGenerator generator)
protected Block(BlockKind? type, IReadOnlyList<SyntaxTreeNode> children, IParentChunkGenerator generator)
{
if (type == null)
{
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
}
public IParentChunkGenerator ChunkGenerator { get; }
public BlockType Type { get; }
public BlockKind Type { get; }
public IReadOnlyList<SyntaxTreeNode> Children { get; }

View File

@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
public IParentChunkGenerator ChunkGenerator { get; set; }
public BlockType? Type { get; set; }
public BlockKind? Type { get; set; }
public List<SyntaxTreeNode> Children { get; private set; }

View File

@ -186,7 +186,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
Span.Start = CurrentLocation;
// Unless changed, the block is a statement block
using (Context.Builder.StartBlock(BlockType.Statement))
using (Context.Builder.StartBlock(BlockKind.Statement))
{
NextToken();
@ -259,7 +259,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
if (CurrentSymbol.Type == CSharpSymbolType.LeftParenthesis)
{
Context.Builder.CurrentBlock.Type = BlockType.Expression;
Context.Builder.CurrentBlock.Type = BlockKind.Expression;
Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator();
ExplicitExpression();
return;
@ -287,7 +287,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
CurrentSymbol.Content.Length);
}
Context.Builder.CurrentBlock.Type = BlockType.Expression;
Context.Builder.CurrentBlock.Type = BlockKind.Expression;
Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator();
ImplicitExpression();
return;
@ -306,7 +306,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
}
// Invalid character
Context.Builder.CurrentBlock.Type = BlockType.Expression;
Context.Builder.CurrentBlock.Type = BlockKind.Expression;
Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator();
AddMarkerSymbolIfNecessary();
Span.ChunkGenerator = new ExpressionChunkGenerator();
@ -406,7 +406,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
private void ImplicitExpression(AcceptedCharacters acceptedCharacters)
{
Context.Builder.CurrentBlock.Type = BlockType.Expression;
Context.Builder.CurrentBlock.Type = BlockKind.Expression;
Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator();
using (PushSpanConfig(span =>
@ -553,7 +553,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
// Read whitespace, but not newlines
// If we're not inserting a marker span, we don't need to capture whitespace
if (!Context.WhiteSpaceIsSignificantToAncestorBlock &&
Context.Builder.CurrentBlock.Type != BlockType.Expression &&
Context.Builder.CurrentBlock.Type != BlockKind.Expression &&
captureWhitespaceToEndOfLine &&
!Context.DesignTimeMode &&
!IsNested)
@ -637,7 +637,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
private void Template()
{
if (Context.Builder.ActiveBlocks.Any(block => block.Type == BlockType.Template))
if (Context.Builder.ActiveBlocks.Any(block => block.Type == BlockKind.Template))
{
Context.ErrorSink.OnError(
CurrentStart,
@ -645,7 +645,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
length: 1 /* @ */);
}
Output(SpanKind.Code);
using (Context.Builder.StartBlock(BlockType.Template))
using (Context.Builder.StartBlock(BlockKind.Template))
{
Context.Builder.CurrentBlock.ChunkGenerator = new TemplateBlockChunkGenerator();
PutCurrentBack();
@ -749,7 +749,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
AcceptAndMoveNext();
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
Span.ChunkGenerator = SpanChunkGenerator.Null;
Context.Builder.CurrentBlock.Type = BlockType.Directive;
Context.Builder.CurrentBlock.Type = BlockKind.Directive;
CompleteBlock();
Output(SpanKind.MetaCode);
}
@ -758,7 +758,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
HandleKeyword(topLevel, () =>
{
Context.Builder.CurrentBlock.Type = BlockType.Expression;
Context.Builder.CurrentBlock.Type = BlockKind.Expression;
Context.Builder.CurrentBlock.ChunkGenerator = new ExpressionChunkGenerator();
ImplicitExpression();
});
@ -846,7 +846,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
private void UsingDeclaration()
{
// Set block type to directive
Context.Builder.CurrentBlock.Type = BlockType.Directive;
Context.Builder.CurrentBlock.Type = BlockKind.Directive;
var start = CurrentStart;
if (At(CSharpSymbolType.Identifier))
@ -1484,7 +1484,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
private void HandleDirective(DirectiveDescriptor descriptor)
{
Context.Builder.CurrentBlock.Type = BlockType.Directive;
Context.Builder.CurrentBlock.Type = BlockKind.Directive;
Context.Builder.CurrentBlock.ChunkGenerator = new DirectiveChunkGenerator(descriptor);
AssertDirective(descriptor.Name);
@ -1703,7 +1703,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
var keywordStartLocation = Span.Start;
// Set the block type
Context.Builder.CurrentBlock.Type = BlockType.Directive;
Context.Builder.CurrentBlock.Type = BlockKind.Directive;
var keywordLength = Span.End.AbsoluteIndex - Span.Start.AbsoluteIndex;
@ -1760,7 +1760,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
AcceptAndMoveNext();
// Set the block type
Context.Builder.CurrentBlock.Type = BlockType.Directive;
Context.Builder.CurrentBlock.Type = BlockKind.Directive;
var keywordLength = Span.End.AbsoluteIndex - Span.Start.AbsoluteIndex;

View File

@ -272,7 +272,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
using (PushSpanConfig(DefaultMarkupSpan))
{
using (Context.Builder.StartBlock(BlockType.Markup))
using (Context.Builder.StartBlock(BlockKind.Markup))
{
Span.Start = CurrentLocation;
@ -388,7 +388,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
if (!EndOfFile && !atSpecialTag)
{
// Start a Block tag. This is used to wrap things like <p> or <a class="btn"> etc.
tagBlockWrapper = Context.Builder.StartBlock(BlockType.Tag);
tagBlockWrapper = Context.Builder.StartBlock(BlockKind.Tag);
}
if (EndOfFile)
@ -767,7 +767,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
// content (if the previous attribute was malformed).
Output(SpanKind.Markup);
using (Context.Builder.StartBlock(BlockType.Markup))
using (Context.Builder.StartBlock(BlockKind.Markup))
{
Accept(whitespace);
Accept(name);
@ -782,7 +782,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
Output(SpanKind.Markup);
// Start a new markup block for the attribute
using (Context.Builder.StartBlock(BlockType.Markup))
using (Context.Builder.StartBlock(BlockKind.Markup))
{
AttributePrefix(whitespace, name, whitespaceAfterAttributeName);
}
@ -894,7 +894,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
if (NextIs(HtmlSymbolType.Transition))
{
// Wrapping this in a block so that the ConditionalAttributeCollapser doesn't rewrite it.
using (Context.Builder.StartBlock(BlockType.Markup))
using (Context.Builder.StartBlock(BlockKind.Markup))
{
Accept(prefix);
@ -920,7 +920,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
Span.ChunkGenerator = SpanChunkGenerator.Null;
// Dynamic value, start a new block and set the chunk generator
using (Context.Builder.StartBlock(BlockType.Markup))
using (Context.Builder.StartBlock(BlockKind.Markup))
{
Context.Builder.CurrentBlock.ChunkGenerator =
new DynamicAttributeBlockChunkGenerator(
@ -1178,7 +1178,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
Accept(whiteSpace);
Output(SpanKind.Markup); // Output the whitespace
using (Context.Builder.StartBlock(BlockType.Tag))
using (Context.Builder.StartBlock(BlockKind.Tag))
{
Accept(openAngle);
Accept(solidus);
@ -1267,7 +1267,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
Output(SpanKind.Markup);
using (Context.Builder.StartBlock(BlockType.Tag))
using (Context.Builder.StartBlock(BlockKind.Tag))
{
Span.EditHandler.AcceptedCharacters = endTagAcceptedCharacters;
@ -1444,7 +1444,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
using (PushSpanConfig(DefaultMarkupSpan))
{
using (Context.Builder.StartBlock(BlockType.Markup))
using (Context.Builder.StartBlock(BlockKind.Markup))
{
Span.Start = CurrentLocation;
@ -1491,7 +1491,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
Output(SpanKind.Markup);
// Start tag block
var tagBlock = Context.Builder.StartBlock(BlockType.Tag);
var tagBlock = Context.Builder.StartBlock(BlockKind.Tag);
AcceptAndMoveNext(); // Accept '<'
@ -1598,7 +1598,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
Span.Start = CurrentLocation;
using (Context.Builder.StartBlock(BlockType.Markup))
using (Context.Builder.StartBlock(BlockKind.Markup))
{
NextToken();
CaseSensitive = caseSensitive;

View File

@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
/// Starts a block of the specified type
/// </summary>
/// <param name="blockType">The type of the block to start</param>
public IDisposable StartBlock(BlockType blockType)
public IDisposable StartBlock(BlockKind blockType)
{
var builder = new BlockBuilder() { Type = blockType };
_blockStack.Push(builder);

View File

@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
Start = start;
BindingResult = bindingResult;
Attributes = new List<TagHelperAttributeNode>(attributes);
Type = BlockType.Tag;
Type = BlockKind.Tag;
ChunkGenerator = new TagHelperChunkGenerator();
}
@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
TagName = tagName;
TagMode = tagMode;
Attributes = attributes;
Type = BlockType.Tag;
Type = BlockKind.Tag;
ChunkGenerator = new TagHelperChunkGenerator();
// Children is IList, no AddRange

View File

@ -463,7 +463,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
var spanBuilder = new SpanBuilder(span);
if (parentBlock.Type == BlockType.Expression &&
if (parentBlock.Type == BlockKind.Expression &&
(spanBuilder.Kind == SpanKind.Transition ||
spanBuilder.Kind == SpanKind.MetaCode))
{

View File

@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
var childBlock = (Block)child;
if (childBlock.Type == BlockType.Tag)
if (childBlock.Type == BlockKind.Tag)
{
if (TryRewriteTagHelper(childBlock, errorSink))
{
@ -340,7 +340,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
var childBlock = (Block)child;
if (childBlock.Type != BlockType.Markup)
if (childBlock.Type != BlockKind.Markup)
{
// Anything other than markup blocks in the attribute area of tags mangles following attributes.
// It's also not supported by TagHelpers, bail early to avoid creating bad attribute value pairs.
@ -762,7 +762,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
var child = tagBlock.Children[0];
if (tagBlock.Type != BlockType.Tag || tagBlock.Children.Count == 0 || !(child is Span))
if (tagBlock.Type != BlockKind.Tag || tagBlock.Children.Count == 0 || !(child is Span))
{
return null;
}
@ -803,7 +803,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
private static void EnsureTagBlock(Block tagBlock)
{
Debug.Assert(tagBlock.Type == BlockType.Tag);
Debug.Assert(tagBlock.Type == BlockKind.Tag);
Debug.Assert(tagBlock.Children.First() is Span);
}

View File

@ -614,7 +614,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
OutputSpanBeforeRazorComment();
using (PushSpanConfig(CommentSpanConfig))
{
using (Context.Builder.StartBlock(BlockType.Comment))
using (Context.Builder.StartBlock(BlockKind.Comment))
{
Context.Builder.CurrentBlock.ChunkGenerator = new RazorCommentChunkGenerator();
var start = CurrentStart;

View File

@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
protected override bool CanRewrite(Block block)
{
return block.Type == BlockType.Expression && Parent != null;
return block.Type == BlockKind.Expression && Parent != null;
}
protected override SyntaxTreeNode RewriteBlock(BlockBuilder parent, Block block)

View File

@ -1,9 +1,9 @@
// 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.Evolution.Legacy
namespace Microsoft.AspNetCore.Razor.Evolution
{
internal enum SpanKind
public enum SpanKind
{
Transition,
MetaCode,

View File

@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
// Assert
var tag = Assert.Single(outputTree.Root.Children);
var tagBlock = Assert.IsType<Block>(tag);
Assert.Equal(BlockType.Tag, tagBlock.Type);
Assert.Equal(BlockKind.Tag, tagBlock.Type);
Assert.Equal(3, tagBlock.Children.Count);
Assert.IsType<Span>(tagBlock.Children[1]);
}

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
public void ConstructorWithBlockBuilderSetsParent()
{
// Arrange
var builder = new BlockBuilder() { Type = BlockType.Comment };
var builder = new BlockBuilder() { Type = BlockKind.Comment };
var span = new SpanBuilder(SourceLocation.Undefined) { Kind = SpanKind.Code }.Build();
builder.Children.Add(span);
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
var expected = new ExpressionChunkGenerator();
var builder = new BlockBuilder()
{
Type = BlockType.Helper,
Type = BlockKind.Helper,
ChunkGenerator = expected
};
@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
var expected = new SpanBuilder(SourceLocation.Undefined) { Kind = SpanKind.Code }.Build();
var builder = new BlockBuilder()
{
Type = BlockType.Functions
Type = BlockKind.Functions
};
builder.Children.Add(expected);

View File

@ -9,10 +9,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
internal class StatementBlock : Block
{
private const BlockType ThisBlockType = BlockType.Statement;
private const BlockKind ThisBlockKind = BlockKind.Statement;
public StatementBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children)
: base(ThisBlockType, children, chunkGenerator)
: base(ThisBlockKind, children, chunkGenerator)
{
}
@ -29,10 +29,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
internal class DirectiveBlock : Block
{
private const BlockType ThisBlockType = BlockType.Directive;
private const BlockKind ThisBlockKind = BlockKind.Directive;
public DirectiveBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children)
: base(ThisBlockType, children, chunkGenerator)
: base(ThisBlockKind, children, chunkGenerator)
{
}
@ -49,10 +49,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
internal class ExpressionBlock : Block
{
private const BlockType ThisBlockType = BlockType.Expression;
private const BlockKind ThisBlockKind = BlockKind.Expression;
public ExpressionBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children)
: base(ThisBlockType, children, chunkGenerator)
: base(ThisBlockKind, children, chunkGenerator)
{
}
@ -69,28 +69,28 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
internal class MarkupTagBlock : Block
{
private const BlockType ThisBlockType = BlockType.Tag;
private const BlockKind ThisBlockKind = BlockKind.Tag;
public MarkupTagBlock(params SyntaxTreeNode[] children)
: base(ThisBlockType, children, ParentChunkGenerator.Null)
: base(ThisBlockKind, children, ParentChunkGenerator.Null)
{
}
}
internal class MarkupBlock : Block
{
private const BlockType ThisBlockType = BlockType.Markup;
private const BlockKind ThisBlockKind = BlockKind.Markup;
public MarkupBlock(
BlockType blockType,
BlockKind BlockKind,
IParentChunkGenerator chunkGenerator,
IReadOnlyList<SyntaxTreeNode> children)
: base(blockType, children, chunkGenerator)
: base(BlockKind, children, chunkGenerator)
{
}
public MarkupBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children)
: this(ThisBlockType, chunkGenerator, children)
: this(ThisBlockKind, chunkGenerator, children)
{
}
@ -170,10 +170,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
internal class TemplateBlock : Block
{
private const BlockType ThisBlockType = BlockType.Template;
private const BlockKind ThisBlockKind = BlockKind.Template;
public TemplateBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children)
: base(ThisBlockType, children, chunkGenerator)
: base(ThisBlockKind, children, chunkGenerator)
{
}
@ -195,10 +195,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
internal class CommentBlock : Block
{
private const BlockType ThisBlockType = BlockType.Comment;
private const BlockKind ThisBlockKind = BlockKind.Comment;
public CommentBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children)
: base(ThisBlockType, children, chunkGenerator)
: base(ThisBlockKind, children, chunkGenerator)
{
}

View File

@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
SingleSpanBlockTest(@"if(foo) {
// bar } "" baz '
zoop();
}", BlockType.Statement, SpanKind.Code);
}", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
@"if(foo) {
/* bar } "" */ ' baz } '
zoop();
}", BlockType.Statement, SpanKind.Code);
}", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
@ -123,7 +123,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code);
}
@ -132,14 +132,14 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code);
}
[Fact]
public void ParseBlockAllowsEmptyBlockStatement()
{
SingleSpanBlockTest("if(false) { }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("if(false) { }", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
"if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code);
}
@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
SingleSpanBlockTest(@"if(foo) { bar(); }
// Foo
// Bar
else { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
else { baz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -220,7 +220,7 @@ else { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Accept
SingleSpanBlockTest(@"if(foo) { bar(); } else if(bar) { baz(); }
// Foo
// Bar
else { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
else { biz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -229,7 +229,7 @@ else { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Accept
SingleSpanBlockTest(@"if(foo) { bar(); }
// Foo
// Bar
else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
else if(bar) { baz(); }", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -243,7 +243,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
}";
const string document = ifStatement + elseIfBranch;
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -256,7 +256,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
Debug.WriteLine(@""bar } baz"");
}";
const string document = ifStatement + elseIfBranch + elseIfBranch + elseIfBranch + elseIfBranch;
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -271,7 +271,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
const string elseBranch = @" else { Debug.WriteLine(@""bar } baz""); }";
const string document = ifStatement + elseIfBranch + elseIfBranch + elseBranch;
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -299,7 +299,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
Debug.WriteLine(@""foo } bar"");
}";
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -313,7 +313,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
const string elseIfBranch = @" else if { foo(); }";
const string document = ifBranch + elseIfBranch;
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -321,7 +321,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
{
SingleSpanBlockTest(
"do { var foo = bar; } while(foo != bar);",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -329,13 +329,13 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
[Fact]
public void ParseBlockCorrectlyParsesDoWhileBlockMissingSemicolon()
{
SingleSpanBlockTest("do { var foo = bar; } while(foo != bar)", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("do { var foo = bar; } while(foo != bar)", BlockKind.Statement, SpanKind.Code);
}
[Fact]
public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileCondition()
{
SingleSpanBlockTest("do { var foo = bar; } while", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("do { var foo = bar; } while", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -343,7 +343,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
{
SingleSpanBlockTest(
"do { var foo = bar; } while;",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -351,7 +351,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
[Fact]
public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileClauseEntirely()
{
SingleSpanBlockTest("do { var foo = bar; } narf;", "do { var foo = bar; }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("do { var foo = bar; } narf;", "do { var foo = bar; }", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -359,7 +359,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
{
SingleSpanBlockTest(
"do { var foo = bar; } /* Foo */ /* Bar */ while(true);",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -370,7 +370,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest(@"do { var foo = bar; }
// Foo
// Bar
while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
while(true);", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -413,7 +413,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
return;
default:
return;
}", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -421,7 +421,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
{
SingleSpanBlockTest(
"lock(foo) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -487,7 +487,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
[Fact]
public void ParseBlockTerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock()
{
SingleSpanBlockTest("using ", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("using ", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -497,7 +497,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
SingleSpanBlockTest(
document,
document,
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
new RazorError(
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
@ -512,7 +512,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
SingleSpanBlockTest(
document,
document,
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
new RazorError(
LegacyResources.ParseError_BlockComment_Not_Terminated,
@ -531,7 +531,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
SingleSpanBlockTest(
document,
document,
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
new RazorError(
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
@ -542,7 +542,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
[Fact]
public void ParseBlockSupportsBlockCommentBetweenTryAndFinallyClause()
{
SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ finally { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ finally { baz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -556,7 +556,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
{
SingleSpanBlockTest(
"try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None);
}
@ -572,7 +572,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
[Fact]
public void ParseBlockSupportsBlockCommentBetweenTryAndCatchClause()
{
SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -587,7 +587,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
SingleSpanBlockTest(@"try { bar(); }
// Foo
// Bar
finally { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
finally { baz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -596,7 +596,7 @@ finally { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Acc
SingleSpanBlockTest(@"try { bar(); } catch(bar) { baz(); }
// Foo
// Bar
finally { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
finally { biz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -605,13 +605,13 @@ finally { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Acc
SingleSpanBlockTest(@"try { bar(); }
// Foo
// Bar
catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
catch(bar) { baz(); }", BlockKind.Statement, SpanKind.Code);
}
[Fact]
public void ParseBlockSupportsTryStatementWithNoAdditionalClauses()
{
SingleSpanBlockTest("try { var foo = new { } }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("try { var foo = new { } }", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -633,7 +633,7 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
[Fact]
public void ParseBlockSupportsTryStatementWithOneCatchClause()
{
SingleSpanBlockTest("try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -658,14 +658,14 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest(
"try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " +
"{ var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code);
}
[Fact]
public void ParseBlockSupportsExceptionLessCatchClauses()
{
SingleSpanBlockTest("try { var foo = new { } } catch { var foo = new { } }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest("try { var foo = new { } } catch { var foo = new { } }", BlockKind.Statement, SpanKind.Code);
}
[Fact]
@ -688,7 +688,7 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
[Fact]
public void ParseBlockSupportsTryStatementWithFinallyClause()
{
SingleSpanBlockTest("try { var foo = new { } } finally { var foo = new { } }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
SingleSpanBlockTest("try { var foo = new { } } finally { var foo = new { } }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -712,14 +712,14 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
public void ParseBlockStopsParsingCatchClausesAfterFinallyBlock()
{
var expectedContent = "try { var foo = new { } } finally { var foo = new { } }";
SingleSpanBlockTest(expectedContent + " catch(Foo Bar Baz) { }", expectedContent, BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
SingleSpanBlockTest(expectedContent + " catch(Foo Bar Baz) { }", expectedContent, BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
public void ParseBlockDoesNotAllowMultipleFinallyBlocks()
{
var expectedContent = "try { var foo = new { } } finally { var foo = new { } }";
SingleSpanBlockTest(expectedContent + " finally { }", expectedContent, BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
SingleSpanBlockTest(expectedContent + " finally { }", expectedContent, BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]

View File

@ -578,7 +578,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
+ " var p = \"foo bar baz" + Environment.NewLine
+ ";" + Environment.NewLine
+ "}",
BlockType.Statement, SpanKind.Code,
BlockKind.Statement, SpanKind.Code,
new RazorError(
LegacyResources.ParseError_Unterminated_String_Literal,
new SourceLocation(21 + Environment.NewLine.Length, 1, 12),
@ -588,7 +588,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
[Fact]
public void ParseBlockTerminatesNormalStringAtEndOfFile()
{
SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockType.Statement, SpanKind.Code,
SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockKind.Statement, SpanKind.Code,
new RazorError(
LegacyResources.ParseError_Unterminated_String_Literal,
new SourceLocation(20, 0, 20),
@ -607,7 +607,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
+ "<p>Foo</p>" + Environment.NewLine
+ "blah " + Environment.NewLine
+ "blah",
BlockType.Statement, SpanKind.Code,
BlockKind.Statement, SpanKind.Code,
new RazorError(
LegacyResources.ParseError_Unterminated_String_Literal,
new SourceLocation(20, 0, 20),
@ -684,7 +684,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
SingleSpanBlockTest(
keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ",
BlockType.Statement,
BlockKind.Statement,
SpanKind.Code,
new RazorError(
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'),

View File

@ -29,34 +29,34 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
ImplicitExpressionTest(input, expected, AcceptedCharacters.NonWhiteSpace, errors);
}
internal override void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
internal override void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
{
SingleSpanBlockTest(document, blockType, spanType, acceptedCharacters, expectedError: null);
SingleSpanBlockTest(document, blockKind, spanType, acceptedCharacters, expectedError: null);
}
internal override void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
internal override void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
{
SingleSpanBlockTest(document, spanContent, blockType, spanType, acceptedCharacters, expectedErrors: null);
SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null);
}
internal override void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, params RazorError[] expectedError)
internal override void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, params RazorError[] expectedError)
{
SingleSpanBlockTest(document, document, blockType, spanType, expectedError);
SingleSpanBlockTest(document, document, blockKind, spanType, expectedError);
}
internal override void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, params RazorError[] expectedErrors)
internal override void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, params RazorError[] expectedErrors)
{
SingleSpanBlockTest(document, spanContent, blockType, spanType, AcceptedCharacters.Any, expectedErrors ?? new RazorError[0]);
SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharacters.Any, expectedErrors ?? new RazorError[0]);
}
internal override void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedError)
internal override void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedError)
{
SingleSpanBlockTest(document, document, blockType, spanType, acceptedCharacters, expectedError);
SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError);
}
internal override void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedErrors)
internal override void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedErrors)
{
var b = CreateSimpleBlockAndSpan(spanContent, blockType, spanType, acceptedCharacters);
var b = CreateSimpleBlockAndSpan(spanContent, blockKind, spanType, acceptedCharacters);
ParseBlockTest(document, b, expectedErrors ?? new RazorError[0]);
}

View File

@ -321,7 +321,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
[Fact]
public void ParseBlockSupportsCommentAsBlock()
{
SingleSpanBlockTest("<!-- foo -->", BlockType.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None);
SingleSpanBlockTest("<!-- foo -->", BlockKind.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
@ -398,19 +398,19 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
[Fact]
public void ParseBlockProperlyBalancesCommentStartAndEndTags()
{
SingleSpanBlockTest("<!--<foo></bar>-->", BlockType.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None);
SingleSpanBlockTest("<!--<foo></bar>-->", BlockKind.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]
public void ParseBlockTerminatesAtEOFWhenParsingComment()
{
SingleSpanBlockTest("<!--<foo>", "<!--<foo>", BlockType.Markup, SpanKind.Markup);
SingleSpanBlockTest("<!--<foo>", "<!--<foo>", BlockKind.Markup, SpanKind.Markup);
}
[Fact]
public void ParseBlockOnlyTerminatesCommentOnFullEndSequence()
{
SingleSpanBlockTest("<!--<foo>--</bar>-->", BlockType.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None);
SingleSpanBlockTest("<!--<foo>--</bar>-->", BlockKind.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None);
}
[Fact]

View File

@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
[Fact]
public void ParseDocumentOutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan()
{
SingleSpanDocumentTest(" ", BlockType.Markup, SpanKind.Markup);
SingleSpanDocumentTest(" ", BlockKind.Markup, SpanKind.Markup);
}
[Fact]
@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
[Fact]
public void ParseDocumentParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered()
{
SingleSpanDocumentTest("foo baz", BlockType.Markup, SpanKind.Markup);
SingleSpanDocumentTest("foo baz", BlockKind.Markup, SpanKind.Markup);
}
[Fact]
@ -182,7 +182,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
[Fact]
public void ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText()
{
SingleSpanDocumentTest("anurse@microsoft.com", BlockType.Markup, SpanKind.Markup);
SingleSpanDocumentTest("anurse@microsoft.com", BlockKind.Markup, SpanKind.Markup);
}
[Fact]
@ -218,7 +218,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
[Fact]
public void ParseDocumentReturnsOneMarkupSegmentIfNoCodeBlocksEncountered()
{
SingleSpanDocumentTest("Foo Baz<!--Foo-->Bar<!--F> Qux", BlockType.Markup, SpanKind.Markup);
SingleSpanDocumentTest("Foo Baz<!--Foo-->Bar<!--F> Qux", BlockKind.Markup, SpanKind.Markup);
}
[Fact]

View File

@ -11,9 +11,9 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
return ParseHtmlBlock(document, designTime);
}
internal virtual void SingleSpanDocumentTest(string document, BlockType blockType, SpanKind spanType)
internal virtual void SingleSpanDocumentTest(string document, BlockKind blockKind, SpanKind spanType)
{
var b = CreateSimpleBlockAndSpan(document, blockType, spanType);
var b = CreateSimpleBlockAndSpan(document, blockKind, spanType);
ParseDocumentTest(document, b);
}
}

View File

@ -177,37 +177,37 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
}
}
internal virtual void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
internal virtual void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
{
SingleSpanBlockTest(document, blockType, spanType, acceptedCharacters, expectedError: null);
SingleSpanBlockTest(document, blockKind, spanType, acceptedCharacters, expectedError: null);
}
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
{
SingleSpanBlockTest(document, spanContent, blockType, spanType, acceptedCharacters, expectedErrors: null);
SingleSpanBlockTest(document, spanContent, blockKind, spanType, acceptedCharacters, expectedErrors: null);
}
internal virtual void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, params RazorError[] expectedError)
internal virtual void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, params RazorError[] expectedError)
{
SingleSpanBlockTest(document, document, blockType, spanType, expectedError);
SingleSpanBlockTest(document, document, blockKind, spanType, expectedError);
}
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, params RazorError[] expectedErrors)
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, params RazorError[] expectedErrors)
{
SingleSpanBlockTest(document, spanContent, blockType, spanType, AcceptedCharacters.Any, expectedErrors ?? new RazorError[0]);
SingleSpanBlockTest(document, spanContent, blockKind, spanType, AcceptedCharacters.Any, expectedErrors ?? new RazorError[0]);
}
internal virtual void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedError)
internal virtual void SingleSpanBlockTest(string document, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedError)
{
SingleSpanBlockTest(document, document, blockType, spanType, acceptedCharacters, expectedError);
SingleSpanBlockTest(document, document, blockKind, spanType, acceptedCharacters, expectedError);
}
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedErrors)
internal virtual void SingleSpanBlockTest(string document, string spanContent, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedErrors)
{
var result = ParseBlock(document, designTime: false);
var builder = new BlockBuilder();
builder.Type = blockType;
builder.Type = blockKind;
var expected = ConfigureAndAddSpanToBlock(builder, Factory.Span(spanType, spanContent, spanType == SpanKind.Markup).Accepts(acceptedCharacters));
if (FixupSpans)
@ -539,12 +539,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
Trace.WriteLine(string.Format(format, args));
}
internal virtual Block CreateSimpleBlockAndSpan(string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
internal virtual Block CreateSimpleBlockAndSpan(string spanContent, BlockKind blockKind, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any)
{
var span = Factory.Span(spanType, spanContent, spanType == SpanKind.Markup).Accepts(acceptedCharacters);
var b = new BlockBuilder()
{
Type = blockType
Type = blockKind
};
return ConfigureAndAddSpanToBlock(b, span);
}
@ -553,13 +553,13 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{
switch (block.Type)
{
case BlockType.Markup:
case BlockKind.Markup:
span.With(new MarkupChunkGenerator());
break;
case BlockType.Statement:
case BlockKind.Statement:
span.With(new StatementChunkGenerator());
break;
case BlockType.Expression:
case BlockKind.Expression:
block.ChunkGenerator = new ExpressionChunkGenerator();
span.With(new ExpressionChunkGenerator());
break;
@ -570,7 +570,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
private class IgnoreOutputBlock : Block
{
public IgnoreOutputBlock() : base(BlockType.Template, new SyntaxTreeNode[0], null) { }
public IgnoreOutputBlock() : base(BlockKind.Template, new SyntaxTreeNode[0], null) { }
}
// Corrects the parents and previous/next information for spans

View File

@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
var rootBlock = Assert.IsType<Block>(document);
var child = Assert.Single(rootBlock.Children);
var tagBlock = Assert.IsType<Block>(child);
Assert.Equal(BlockType.Tag, tagBlock.Type);
Assert.Equal(BlockKind.Tag, tagBlock.Type);
Assert.Empty(errorSink.Errors);
// Act