Rename IR* -> RazorIR*

This commit is contained in:
Ryan Nowak 2016-11-01 15:39:07 -07:00 committed by N. Taylor Mullen
parent d40f6d3151
commit d42a4c84a1
12 changed files with 95 additions and 95 deletions

View File

@ -6,17 +6,17 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
internal class DefaultIRBuilder : IRBuilder internal class DefaultRazorIRBuilder : RazorIRBuilder
{ {
private readonly List<IRNode> _stack; private readonly List<RazorIRNode> _stack;
private int _depth; private int _depth;
public DefaultIRBuilder() public DefaultRazorIRBuilder()
{ {
_stack = new List<IRNode>(); _stack = new List<RazorIRNode>();
} }
public override IRNode Current public override RazorIRNode Current
{ {
get get
{ {
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
} }
} }
public override void Add(IRNode node) public override void Add(RazorIRNode node)
{ {
if (node == null) if (node == null)
{ {
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
Pop(); Pop();
} }
public override IRNode Pop() public override RazorIRNode Pop()
{ {
if (_depth == 0) if (_depth == 0)
{ {
@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
return node; return node;
} }
public override void Push(IRNode node) public override void Push(RazorIRNode node)
{ {
if (node == null) if (node == null)
{ {

View File

@ -1,23 +0,0 @@
// 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.Intermediate
{
public abstract class IRBuilder
{
public static IRBuilder Document()
{
var builder = new DefaultIRBuilder();
builder.Push(new IRDocument());
return builder;
}
public abstract IRNode Current { get; }
public abstract void Add(IRNode node);
public abstract void Push(IRNode node);
public abstract IRNode Pop();
}
}

View File

@ -1,20 +0,0 @@
// 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.
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{
public abstract class IRNode
{
internal static readonly IRNode[] EmptyArray = new IRNode[0];
public abstract IList<IRNode> Children { get; }
public abstract IRNode Parent { get; set; }
public abstract void Accept(IRNodeVisitor visitor);
public abstract TResult Accept<TResult>(IRNodeVisitor<TResult> visitor);
}
}

View File

@ -0,0 +1,23 @@
// 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.Intermediate
{
public abstract class RazorIRBuilder
{
public static RazorIRBuilder Document()
{
var builder = new DefaultRazorIRBuilder();
builder.Push(new RazorIRDocument());
return builder;
}
public abstract RazorIRNode Current { get; }
public abstract void Add(RazorIRNode node);
public abstract void Push(RazorIRNode node);
public abstract RazorIRNode Pop();
}
}

View File

@ -5,25 +5,25 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
public sealed class IRDocument : IRNode public sealed class RazorIRDocument : RazorIRNode
{ {
// Only allow creation of documents through the builder API because // Only allow creation of documents through the builder API because
// they can't be nested. // they can't be nested.
internal IRDocument() internal RazorIRDocument()
{ {
Children = new List<IRNode>(); Children = new List<RazorIRNode>();
} }
public override IList<IRNode> Children { get; } public override IList<RazorIRNode> Children { get; }
public override IRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
public override void Accept(IRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {
visitor.VisitDocument(this); visitor.VisitDocument(this);
} }
public override TResult Accept<TResult>(IRNodeVisitor<TResult> visitor) public override TResult Accept<TResult>(RazorIRNodeVisitor<TResult> visitor)
{ {
return visitor.VisitDocument(this); return visitor.VisitDocument(this);
} }

View File

@ -0,0 +1,20 @@
// 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.
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{
public abstract class RazorIRNode
{
internal static readonly RazorIRNode[] EmptyArray = new RazorIRNode[0];
public abstract IList<RazorIRNode> Children { get; }
public abstract RazorIRNode Parent { get; set; }
public abstract void Accept(RazorIRNodeVisitor visitor);
public abstract TResult Accept<TResult>(RazorIRNodeVisitor<TResult> visitor);
}
}

View File

@ -3,18 +3,18 @@
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
public abstract class IRNodeVisitor public abstract class RazorIRNodeVisitor
{ {
public virtual void Visit(IRNode node) public virtual void Visit(RazorIRNode node)
{ {
node.Accept(this); node.Accept(this);
} }
public virtual void VisitDefault(IRNode node) public virtual void VisitDefault(RazorIRNode node)
{ {
} }
public virtual void VisitDocument(IRDocument node) public virtual void VisitDocument(RazorIRDocument node)
{ {
VisitDefault(node); VisitDefault(node);
} }

View File

@ -3,19 +3,19 @@
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
public abstract class IRNodeVisitor<TResult> public abstract class RazorIRNodeVisitor<TResult>
{ {
public virtual TResult Visit(IRNode node) public virtual TResult Visit(RazorIRNode node)
{ {
return node.Accept(this); return node.Accept(this);
} }
public virtual TResult VisitDefault(IRNode node) public virtual TResult VisitDefault(RazorIRNode node)
{ {
return default(TResult); return default(TResult);
} }
public virtual TResult VisitDocument(IRDocument node) public virtual TResult VisitDocument(RazorIRDocument node)
{ {
return VisitDefault(node); return VisitDefault(node);
} }

View File

@ -3,9 +3,9 @@
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
public abstract class IRNodeWalker : IRNodeVisitor public abstract class RazorIRNodeWalker : RazorIRNodeVisitor
{ {
public override void VisitDefault(IRNode node) public override void VisitDefault(RazorIRNode node)
{ {
var children = node.Children; var children = node.Children;
for (var i = 0; i < node.Children.Count; i++) for (var i = 0; i < node.Children.Count; i++)

View File

@ -8,13 +8,13 @@ using Xunit;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
public class DefaultIRBuilderTest public class DefaultRazorIRBuilderTest
{ {
[Fact] [Fact]
public void Ctor_CreatesEmptyBuilder() public void Ctor_CreatesEmptyBuilder()
{ {
// Arrange & Act // Arrange & Act
var builder = new DefaultIRBuilder(); var builder = new DefaultRazorIRBuilder();
var current = builder.Current; var current = builder.Current;
// Assert // Assert
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public void Push_WhenEmpty_AddsNode() public void Push_WhenEmpty_AddsNode()
{ {
// Arrange // Arrange
var builder = new DefaultIRBuilder(); var builder = new DefaultRazorIRBuilder();
var node = new BasicIRNode(); var node = new BasicIRNode();
// Act // Act
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public void Push_WhenNonEmpty_SetsUpParentAndChild() public void Push_WhenNonEmpty_SetsUpParentAndChild()
{ {
// Arrange // Arrange
var builder = new DefaultIRBuilder(); var builder = new DefaultRazorIRBuilder();
var parent = new BasicIRNode(); var parent = new BasicIRNode();
builder.Push(parent); builder.Push(parent);
@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public void Pop_ThrowsWhenEmpty() public void Pop_ThrowsWhenEmpty()
{ {
// Arrange // Arrange
var builder = new DefaultIRBuilder(); var builder = new DefaultRazorIRBuilder();
// Act & Assert // Act & Assert
ExceptionAssert.Throws<InvalidOperationException>( ExceptionAssert.Throws<InvalidOperationException>(
@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public void Pop_SingleNodeDepth_RemovesAndReturnsNode() public void Pop_SingleNodeDepth_RemovesAndReturnsNode()
{ {
// Arrange // Arrange
var builder = new DefaultIRBuilder(); var builder = new DefaultRazorIRBuilder();
var node = new BasicIRNode(); var node = new BasicIRNode();
builder.Push(node); builder.Push(node);
@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public void Pop_MultipleNodeDepth_RemovesAndReturnsNode() public void Pop_MultipleNodeDepth_RemovesAndReturnsNode()
{ {
// Arrange // Arrange
var builder = new DefaultIRBuilder(); var builder = new DefaultRazorIRBuilder();
var parent = new BasicIRNode(); var parent = new BasicIRNode();
builder.Push(parent); builder.Push(parent);
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public void Add_DoesPushAndPop() public void Add_DoesPushAndPop()
{ {
// Arrange // Arrange
var builder = new DefaultIRBuilder(); var builder = new DefaultRazorIRBuilder();
var parent = new BasicIRNode(); var parent = new BasicIRNode();
builder.Push(parent); builder.Push(parent);
@ -125,18 +125,18 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
Assert.Collection(parent.Children, n => Assert.Same(node, n)); Assert.Collection(parent.Children, n => Assert.Same(node, n));
} }
private class BasicIRNode : IRNode private class BasicIRNode : RazorIRNode
{ {
public override IList<IRNode> Children { get; } = new List<IRNode>(); public override IList<RazorIRNode> Children { get; } = new List<RazorIRNode>();
public override IRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
public override void Accept(IRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override TResult Accept<TResult>(IRNodeVisitor<TResult> visitor) public override TResult Accept<TResult>(RazorIRNodeVisitor<TResult> visitor)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -5,16 +5,16 @@ using Xunit;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
public class IRBuilderTest public class RazorIRBuilderTest
{ {
[Fact] [Fact]
public void Document_CreatesDocumentNode() public void Document_CreatesDocumentNode()
{ {
// Arrange & Act // Arrange & Act
var builder = IRBuilder.Document(); var builder = RazorIRBuilder.Document();
// Assert // Assert
Assert.IsType<IRDocument>(builder.Current); Assert.IsType<RazorIRDocument>(builder.Current);
} }
} }
} }

View File

@ -7,7 +7,7 @@ using Xunit;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
public class IRNodeWalkerTest public class RazorIRNodeWalkerTest
{ {
[Fact] [Fact]
public void IRNodeWalker_Visit_TraversesEntireGraph() public void IRNodeWalker_Visit_TraversesEntireGraph()
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
// Arrange // Arrange
var walker = new DerivedIRNodeWalker(); var walker = new DerivedIRNodeWalker();
var nodes = new IRNode[] var nodes = new RazorIRNode[]
{ {
new BasicIRNode("Root"), new BasicIRNode("Root"),
new BasicIRNode("Root->A"), new BasicIRNode("Root->A"),
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
new BasicIRNode("Root->C"), new BasicIRNode("Root->C"),
}; };
var builder = new DefaultIRBuilder(); var builder = new DefaultRazorIRBuilder();
builder.Push(nodes[0]); builder.Push(nodes[0]);
builder.Add(nodes[1]); builder.Add(nodes[1]);
builder.Push(nodes[2]); builder.Push(nodes[2]);
@ -43,11 +43,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
Assert.Equal(nodes, walker.Visited.ToArray()); Assert.Equal(nodes, walker.Visited.ToArray());
} }
private class DerivedIRNodeWalker : IRNodeWalker private class DerivedIRNodeWalker : RazorIRNodeWalker
{ {
public List<IRNode> Visited { get; } = new List<IRNode>(); public List<RazorIRNode> Visited { get; } = new List<RazorIRNode>();
public override void VisitDefault(IRNode node) public override void VisitDefault(RazorIRNode node)
{ {
Visited.Add(node); Visited.Add(node);
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
} }
private class BasicIRNode : IRNode private class BasicIRNode : RazorIRNode
{ {
public BasicIRNode(string name) public BasicIRNode(string name)
{ {
@ -70,16 +70,16 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public string Name { get; } public string Name { get; }
public override IList<IRNode> Children { get; } = new List<IRNode>(); public override IList<RazorIRNode> Children { get; } = new List<RazorIRNode>();
public override IRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
public override void Accept(IRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {
((DerivedIRNodeWalker)visitor).VisitBasic(this); ((DerivedIRNodeWalker)visitor).VisitBasic(this);
} }
public override TResult Accept<TResult>(IRNodeVisitor<TResult> visitor) public override TResult Accept<TResult>(RazorIRNodeVisitor<TResult> visitor)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }