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. // 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. // 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 // Code
Statement, Statement,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
var childBlock = (Block)child; var childBlock = (Block)child;
if (childBlock.Type == BlockType.Tag) if (childBlock.Type == BlockKind.Tag)
{ {
if (TryRewriteTagHelper(childBlock, errorSink)) if (TryRewriteTagHelper(childBlock, errorSink))
{ {
@ -340,7 +340,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
var childBlock = (Block)child; 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. // 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. // 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]; 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; return null;
} }
@ -803,7 +803,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
private static void EnsureTagBlock(Block tagBlock) 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); Debug.Assert(tagBlock.Children.First() is Span);
} }

View File

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

View File

@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
protected override bool CanRewrite(Block block) 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) protected override SyntaxTreeNode RewriteBlock(BlockBuilder parent, Block block)

View File

@ -1,9 +1,9 @@
// 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. // 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, Transition,
MetaCode, MetaCode,

View File

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

View File

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

View File

@ -9,10 +9,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
internal class StatementBlock : Block internal class StatementBlock : Block
{ {
private const BlockType ThisBlockType = BlockType.Statement; private const BlockKind ThisBlockKind = BlockKind.Statement;
public StatementBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children) 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 internal class DirectiveBlock : Block
{ {
private const BlockType ThisBlockType = BlockType.Directive; private const BlockKind ThisBlockKind = BlockKind.Directive;
public DirectiveBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children) 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 internal class ExpressionBlock : Block
{ {
private const BlockType ThisBlockType = BlockType.Expression; private const BlockKind ThisBlockKind = BlockKind.Expression;
public ExpressionBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children) 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 internal class MarkupTagBlock : Block
{ {
private const BlockType ThisBlockType = BlockType.Tag; private const BlockKind ThisBlockKind = BlockKind.Tag;
public MarkupTagBlock(params SyntaxTreeNode[] children) public MarkupTagBlock(params SyntaxTreeNode[] children)
: base(ThisBlockType, children, ParentChunkGenerator.Null) : base(ThisBlockKind, children, ParentChunkGenerator.Null)
{ {
} }
} }
internal class MarkupBlock : Block internal class MarkupBlock : Block
{ {
private const BlockType ThisBlockType = BlockType.Markup; private const BlockKind ThisBlockKind = BlockKind.Markup;
public MarkupBlock( public MarkupBlock(
BlockType blockType, BlockKind BlockKind,
IParentChunkGenerator chunkGenerator, IParentChunkGenerator chunkGenerator,
IReadOnlyList<SyntaxTreeNode> children) IReadOnlyList<SyntaxTreeNode> children)
: base(blockType, children, chunkGenerator) : base(BlockKind, children, chunkGenerator)
{ {
} }
public MarkupBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children) 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 internal class TemplateBlock : Block
{ {
private const BlockType ThisBlockType = BlockType.Template; private const BlockKind ThisBlockKind = BlockKind.Template;
public TemplateBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children) 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 internal class CommentBlock : Block
{ {
private const BlockType ThisBlockType = BlockType.Comment; private const BlockKind ThisBlockKind = BlockKind.Comment;
public CommentBlock(IParentChunkGenerator chunkGenerator, IReadOnlyList<SyntaxTreeNode> children) 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) { SingleSpanBlockTest(@"if(foo) {
// bar } "" baz ' // bar } "" baz '
zoop(); zoop();
}", BlockType.Statement, SpanKind.Code); }", BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
@"if(foo) { @"if(foo) {
/* bar } "" */ ' baz } ' /* bar } "" */ ' baz } '
zoop(); zoop();
}", BlockType.Statement, SpanKind.Code); }", BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", "for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", "foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", "while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", "using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
} }
@ -123,7 +123,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }", "if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code); SpanKind.Code);
} }
@ -132,14 +132,14 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }", "if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code); SpanKind.Code);
} }
[Fact] [Fact]
public void ParseBlockAllowsEmptyBlockStatement() public void ParseBlockAllowsEmptyBlockStatement()
{ {
SingleSpanBlockTest("if(false) { }", BlockType.Statement, SpanKind.Code); SingleSpanBlockTest("if(false) { }", BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }", "if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }", "if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }", "if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code); SpanKind.Code);
} }
@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
SingleSpanBlockTest(@"if(foo) { bar(); } SingleSpanBlockTest(@"if(foo) { bar(); }
// Foo // Foo
// Bar // Bar
else { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); else { baz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
} }
[Fact] [Fact]
@ -220,7 +220,7 @@ else { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Accept
SingleSpanBlockTest(@"if(foo) { bar(); } else if(bar) { baz(); } SingleSpanBlockTest(@"if(foo) { bar(); } else if(bar) { baz(); }
// Foo // Foo
// Bar // Bar
else { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); else { biz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
} }
[Fact] [Fact]
@ -229,7 +229,7 @@ else { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Accept
SingleSpanBlockTest(@"if(foo) { bar(); } SingleSpanBlockTest(@"if(foo) { bar(); }
// Foo // Foo
// Bar // Bar
else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code); else if(bar) { baz(); }", BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -243,7 +243,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
}"; }";
const string document = ifStatement + elseIfBranch; const string document = ifStatement + elseIfBranch;
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code); SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -256,7 +256,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
Debug.WriteLine(@""bar } baz""); Debug.WriteLine(@""bar } baz"");
}"; }";
const string document = ifStatement + elseIfBranch + elseIfBranch + elseIfBranch + elseIfBranch; const string document = ifStatement + elseIfBranch + elseIfBranch + elseIfBranch + elseIfBranch;
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code); SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -271,7 +271,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
const string elseBranch = @" else { Debug.WriteLine(@""bar } baz""); }"; const string elseBranch = @" else { Debug.WriteLine(@""bar } baz""); }";
const string document = ifStatement + elseIfBranch + elseIfBranch + elseBranch; 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] [Fact]
@ -299,7 +299,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
Debug.WriteLine(@""foo } bar""); Debug.WriteLine(@""foo } bar"");
}"; }";
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code); SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -313,7 +313,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
const string elseIfBranch = @" else if { foo(); }"; const string elseIfBranch = @" else if { foo(); }";
const string document = ifBranch + elseIfBranch; const string document = ifBranch + elseIfBranch;
SingleSpanBlockTest(document, BlockType.Statement, SpanKind.Code); SingleSpanBlockTest(document, BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -321,7 +321,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"do { var foo = bar; } while(foo != bar);", "do { var foo = bar; } while(foo != bar);",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -329,13 +329,13 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
[Fact] [Fact]
public void ParseBlockCorrectlyParsesDoWhileBlockMissingSemicolon() 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] [Fact]
public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileCondition() public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileCondition()
{ {
SingleSpanBlockTest("do { var foo = bar; } while", BlockType.Statement, SpanKind.Code); SingleSpanBlockTest("do { var foo = bar; } while", BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -343,7 +343,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"do { var foo = bar; } while;", "do { var foo = bar; } while;",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -351,7 +351,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
[Fact] [Fact]
public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileClauseEntirely() 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] [Fact]
@ -359,7 +359,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"do { var foo = bar; } /* Foo */ /* Bar */ while(true);", "do { var foo = bar; } /* Foo */ /* Bar */ while(true);",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -370,7 +370,7 @@ else if(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest(@"do { var foo = bar; } SingleSpanBlockTest(@"do { var foo = bar; }
// Foo // Foo
// Bar // Bar
while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); while(true);", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
} }
[Fact] [Fact]
@ -413,7 +413,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
return; return;
default: default:
return; return;
}", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
} }
[Fact] [Fact]
@ -421,7 +421,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"lock(foo) { Debug.WriteLine(@\"foo } bar\"); }", "lock(foo) { Debug.WriteLine(@\"foo } bar\"); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -487,7 +487,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
[Fact] [Fact]
public void ParseBlockTerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock() public void ParseBlockTerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock()
{ {
SingleSpanBlockTest("using ", BlockType.Statement, SpanKind.Code); SingleSpanBlockTest("using ", BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -497,7 +497,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
SingleSpanBlockTest( SingleSpanBlockTest(
document, document,
document, document,
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
new RazorError( new RazorError(
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
@ -512,7 +512,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
SingleSpanBlockTest( SingleSpanBlockTest(
document, document,
document, document,
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
new RazorError( new RazorError(
LegacyResources.ParseError_BlockComment_Not_Terminated, LegacyResources.ParseError_BlockComment_Not_Terminated,
@ -531,7 +531,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
SingleSpanBlockTest( SingleSpanBlockTest(
document, document,
document, document,
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
new RazorError( new RazorError(
LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), LegacyResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'),
@ -542,7 +542,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
[Fact] [Fact]
public void ParseBlockSupportsBlockCommentBetweenTryAndFinallyClause() 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] [Fact]
@ -556,7 +556,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
{ {
SingleSpanBlockTest( SingleSpanBlockTest(
"try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }", "try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code, SpanKind.Code,
acceptedCharacters: AcceptedCharacters.None); acceptedCharacters: AcceptedCharacters.None);
} }
@ -572,7 +572,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
[Fact] [Fact]
public void ParseBlockSupportsBlockCommentBetweenTryAndCatchClause() 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] [Fact]
@ -587,7 +587,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
SingleSpanBlockTest(@"try { bar(); } SingleSpanBlockTest(@"try { bar(); }
// Foo // Foo
// Bar // Bar
finally { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); finally { baz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
} }
[Fact] [Fact]
@ -596,7 +596,7 @@ finally { baz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Acc
SingleSpanBlockTest(@"try { bar(); } catch(bar) { baz(); } SingleSpanBlockTest(@"try { bar(); } catch(bar) { baz(); }
// Foo // Foo
// Bar // Bar
finally { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None); finally { biz(); }", BlockKind.Statement, SpanKind.Code, acceptedCharacters: AcceptedCharacters.None);
} }
[Fact] [Fact]
@ -605,13 +605,13 @@ finally { biz(); }", BlockType.Statement, SpanKind.Code, acceptedCharacters: Acc
SingleSpanBlockTest(@"try { bar(); } SingleSpanBlockTest(@"try { bar(); }
// Foo // Foo
// Bar // Bar
catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code); catch(bar) { baz(); }", BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
public void ParseBlockSupportsTryStatementWithNoAdditionalClauses() public void ParseBlockSupportsTryStatementWithNoAdditionalClauses()
{ {
SingleSpanBlockTest("try { var foo = new { } }", BlockType.Statement, SpanKind.Code); SingleSpanBlockTest("try { var foo = new { } }", BlockKind.Statement, SpanKind.Code);
} }
[Fact] [Fact]
@ -633,7 +633,7 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
[Fact] [Fact]
public void ParseBlockSupportsTryStatementWithOneCatchClause() 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] [Fact]
@ -658,14 +658,14 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
SingleSpanBlockTest( SingleSpanBlockTest(
"try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " + "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 { } }", "{ var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }",
BlockType.Statement, BlockKind.Statement,
SpanKind.Code); SpanKind.Code);
} }
[Fact] [Fact]
public void ParseBlockSupportsExceptionLessCatchClauses() 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] [Fact]
@ -688,7 +688,7 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
[Fact] [Fact]
public void ParseBlockSupportsTryStatementWithFinallyClause() 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] [Fact]
@ -712,14 +712,14 @@ catch(bar) { baz(); }", BlockType.Statement, SpanKind.Code);
public void ParseBlockStopsParsingCatchClausesAfterFinallyBlock() public void ParseBlockStopsParsingCatchClausesAfterFinallyBlock()
{ {
var expectedContent = "try { var foo = new { } } finally { var foo = new { } }"; 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] [Fact]
public void ParseBlockDoesNotAllowMultipleFinallyBlocks() public void ParseBlockDoesNotAllowMultipleFinallyBlocks()
{ {
var expectedContent = "try { var foo = new { } } finally { var foo = new { } }"; 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] [Fact]

View File

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

View File

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

View File

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

View File

@ -11,9 +11,9 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
return ParseHtmlBlock(document, designTime); 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); 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 result = ParseBlock(document, designTime: false);
var builder = new BlockBuilder(); var builder = new BlockBuilder();
builder.Type = blockType; builder.Type = blockKind;
var expected = ConfigureAndAddSpanToBlock(builder, Factory.Span(spanType, spanContent, spanType == SpanKind.Markup).Accepts(acceptedCharacters)); var expected = ConfigureAndAddSpanToBlock(builder, Factory.Span(spanType, spanContent, spanType == SpanKind.Markup).Accepts(acceptedCharacters));
if (FixupSpans) if (FixupSpans)
@ -539,12 +539,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
Trace.WriteLine(string.Format(format, args)); 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 span = Factory.Span(spanType, spanContent, spanType == SpanKind.Markup).Accepts(acceptedCharacters);
var b = new BlockBuilder() var b = new BlockBuilder()
{ {
Type = blockType Type = blockKind
}; };
return ConfigureAndAddSpanToBlock(b, span); return ConfigureAndAddSpanToBlock(b, span);
} }
@ -553,13 +553,13 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
switch (block.Type) switch (block.Type)
{ {
case BlockType.Markup: case BlockKind.Markup:
span.With(new MarkupChunkGenerator()); span.With(new MarkupChunkGenerator());
break; break;
case BlockType.Statement: case BlockKind.Statement:
span.With(new StatementChunkGenerator()); span.With(new StatementChunkGenerator());
break; break;
case BlockType.Expression: case BlockKind.Expression:
block.ChunkGenerator = new ExpressionChunkGenerator(); block.ChunkGenerator = new ExpressionChunkGenerator();
span.With(new ExpressionChunkGenerator()); span.With(new ExpressionChunkGenerator());
break; break;
@ -570,7 +570,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
private class IgnoreOutputBlock : Block 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 // 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 rootBlock = Assert.IsType<Block>(document);
var child = Assert.Single(rootBlock.Children); var child = Assert.Single(rootBlock.Children);
var tagBlock = Assert.IsType<Block>(child); var tagBlock = Assert.IsType<Block>(child);
Assert.Equal(BlockType.Tag, tagBlock.Type); Assert.Equal(BlockKind.Tag, tagBlock.Type);
Assert.Empty(errorSink.Errors); Assert.Empty(errorSink.Errors);
// Act // Act