This are mechanical API Cleanup issues.
This commit is contained in:
parent
870b264039
commit
ab98c5d837
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
internal class DefaultDocumentClassifierPass : DocumentClassifierPassBase
|
||||
{
|
||||
public override int Order => RazorIRPass.DefaultFeatureOrder;
|
||||
public override int Order => DefaultFeatureOrder;
|
||||
|
||||
protected override string DocumentKind => "default";
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
public class DefaultInstrumentationPass : RazorIRPassBase, IRazorIROptimizationPass
|
||||
{
|
||||
public override int Order => RazorIRPass.DefaultFeatureOrder;
|
||||
public override int Order => DefaultFeatureOrder;
|
||||
|
||||
public override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIRNode irDocument)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
internal class DirectiveRemovalIROptimizationPass : RazorIRPassBase, IRazorIROptimizationPass
|
||||
{
|
||||
public override int Order => RazorIRPass.DefaultFeatureOrder + 50;
|
||||
public override int Order => DefaultFeatureOrder + 50;
|
||||
|
||||
public override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIRNode irDocument)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -131,7 +131,18 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public override void VisitUsingStatement(UsingStatementIRNode node)
|
||||
{
|
||||
_namespace.AddAfter<UsingStatementIRNode>(node);
|
||||
var children = _namespace.Current.Children;
|
||||
var i = children.Count - 1;
|
||||
for (; i >= 0; i--)
|
||||
{
|
||||
var child = children[i];
|
||||
if (child is UsingStatementIRNode)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_namespace.Insert(i + 1, node);
|
||||
}
|
||||
|
||||
public override void VisitDeclareTagHelperFields(DeclareTagHelperFieldsIRNode node)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class AddPreallocatedTagHelperHtmlAttributeIRNode : ExtensionIRNode
|
||||
public sealed class AddPreallocatedTagHelperHtmlAttributeIRNode : ExtensionIRNode
|
||||
{
|
||||
public override IList<RazorIRNode> Children { get; } = EmptyArray;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class AddTagHelperHtmlAttributeIRNode : RazorIRNode
|
||||
public sealed class AddTagHelperHtmlAttributeIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class CSharpAttributeValueIRNode : RazorIRNode
|
||||
public sealed class CSharpAttributeValueIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class CSharpExpressionIRNode : RazorIRNode
|
||||
public sealed class CSharpExpressionIRNode : RazorIRNode
|
||||
{
|
||||
private ItemCollection _annotations;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class CSharpStatementIRNode : RazorIRNode
|
||||
public sealed class CSharpStatementIRNode : RazorIRNode
|
||||
{
|
||||
private ItemCollection _annotations;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using System.Text;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class ChecksumIRNode : RazorIRNode
|
||||
public sealed class ChecksumIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class CreateTagHelperIRNode : RazorIRNode
|
||||
public sealed class CreateTagHelperIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class DeclarePreallocatedTagHelperAttributeIRNode : ExtensionIRNode
|
||||
public sealed class DeclarePreallocatedTagHelperAttributeIRNode : ExtensionIRNode
|
||||
{
|
||||
public override IList<RazorIRNode> Children { get; } = EmptyArray;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class DeclarePreallocatedTagHelperHtmlAttributeIRNode : ExtensionIRNode
|
||||
public sealed class DeclarePreallocatedTagHelperHtmlAttributeIRNode : ExtensionIRNode
|
||||
{
|
||||
public override IList<RazorIRNode> Children { get; } = EmptyArray;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class DeclareTagHelperFieldsIRNode : RazorIRNode
|
||||
public sealed class DeclareTagHelperFieldsIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
internal class DesignTimeDirectiveIRNode : ExtensionIRNode
|
||||
internal sealed class DesignTimeDirectiveIRNode : ExtensionIRNode
|
||||
{
|
||||
public override IList<RazorIRNode> Children { get; } = new List<RazorIRNode>();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class DirectiveIRNode : RazorIRNode
|
||||
public sealed class DirectiveIRNode : RazorIRNode
|
||||
{
|
||||
private ItemCollection _annotations;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class DirectiveTokenIRNode : RazorIRNode
|
||||
public sealed class DirectiveTokenIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class ExecuteTagHelpersIRNode : RazorIRNode
|
||||
public sealed class ExecuteTagHelpersIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class HtmlAttributeIRNode : RazorIRNode
|
||||
public sealed class HtmlAttributeIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class HtmlAttributeValueIRNode : RazorIRNode
|
||||
public sealed class HtmlAttributeValueIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +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.Language.Intermediate
|
||||
{
|
||||
public interface IExtensionIRNodeVisitor<TNode, TResult> where TNode : ExtensionIRNode
|
||||
{
|
||||
TResult VisitExtension(TNode node);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class NamespaceDeclarationIRNode : RazorIRNode
|
||||
public sealed class NamespaceDeclarationIRNode : RazorIRNode
|
||||
{
|
||||
private ItemCollection _annotations;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +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.Language.Intermediate
|
||||
{
|
||||
public static class RazorIRBuilderExtensions
|
||||
{
|
||||
public static void AddAfter<TNode>(this RazorIRBuilder builder, RazorIRNode node)
|
||||
where TNode : RazorIRNode
|
||||
{
|
||||
var children = builder.Current.Children;
|
||||
var i = children.Count - 1;
|
||||
for (; i >= 0; i--)
|
||||
{
|
||||
var child = children[i];
|
||||
if (child is TNode || child.GetType() == node.GetType())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
builder.Insert(i + 1, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class SetPreallocatedTagHelperPropertyIRNode : ExtensionIRNode
|
||||
public sealed class SetPreallocatedTagHelperPropertyIRNode : ExtensionIRNode
|
||||
{
|
||||
public override IList<RazorIRNode> Children { get; } = EmptyArray;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Language.Legacy;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class SetTagHelperPropertyIRNode : RazorIRNode
|
||||
public sealed class SetTagHelperPropertyIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class TagHelperIRNode : RazorIRNode
|
||||
public sealed class TagHelperIRNode : RazorIRNode
|
||||
{
|
||||
private ItemCollection _annotations;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class TemplateIRNode : ExtensionIRNode
|
||||
public sealed class TemplateIRNode : ExtensionIRNode
|
||||
{
|
||||
public override IList<RazorIRNode> Children { get; } = new List<RazorIRNode>();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class UsingStatementIRNode : RazorIRNode
|
||||
public sealed class UsingStatementIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations => ReadonlyItemCollection.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +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.Language
|
||||
{
|
||||
public static class RazorIRPass
|
||||
{
|
||||
/// <summary>
|
||||
/// The default implementation of the <see cref="IRazorEngineFeature"/>s that run in a
|
||||
/// <see cref="IRazorEnginePhase"/> will use this value for its Order property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This value is chosen in such a way that the default implementation runs after the other
|
||||
/// custom <see cref="IRazorEngineFeature"/> implementations for a particular <see cref="IRazorEnginePhase"/>.
|
||||
/// </remarks>
|
||||
public static readonly int DefaultFeatureOrder = 1000;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,16 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
public abstract class RazorIRPassBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The default implementation of the <see cref="IRazorEngineFeature"/>s that run in a
|
||||
/// <see cref="IRazorEnginePhase"/> will use this value for its Order property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This value is chosen in such a way that the default implementation runs after the other
|
||||
/// custom <see cref="IRazorEngineFeature"/> implementations for a particular <see cref="IRazorEnginePhase"/>.
|
||||
/// </remarks>
|
||||
public static readonly int DefaultFeatureOrder = 1000;
|
||||
|
||||
private RazorEngine _engine;
|
||||
|
||||
public RazorEngine Engine
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
internal class RazorPreallocatedTagHelperAttributeOptimizationPass : RazorIRPassBase, IRazorIROptimizationPass
|
||||
{
|
||||
public override int Order => RazorIRPass.DefaultFeatureOrder;
|
||||
public override int Order => DefaultFeatureOrder;
|
||||
|
||||
public override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIRNode irDocument)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
private class TestDocumentClassifierPass : DocumentClassifierPassBase
|
||||
{
|
||||
public override int Order => RazorIRPass.DefaultFeatureOrder;
|
||||
public override int Order => RazorIRPassBase.DefaultFeatureOrder;
|
||||
|
||||
public bool ShouldMatch { get; set; } = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,123 +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;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Razor.Language.Legacy;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public class RazorIRBuilderExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void AddAfter_EmptyList()
|
||||
{
|
||||
// Arrange
|
||||
var builder = RazorIRBuilder.Document();
|
||||
|
||||
var node = new BasicIRNode3();
|
||||
|
||||
// Act
|
||||
builder.AddAfter<BasicIRNode>(node);
|
||||
|
||||
// Assert
|
||||
Assert.Collection(builder.Current.Children, n => Assert.Same(node, n));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddAfter_AfterMatch()
|
||||
{
|
||||
// Arrange
|
||||
var builder = RazorIRBuilder.Document();
|
||||
builder.Add(new BasicIRNode());
|
||||
builder.Add(new BasicIRNode());
|
||||
builder.Add(new BasicIRNode3());
|
||||
|
||||
var node = new BasicIRNode3();
|
||||
|
||||
// Act
|
||||
builder.AddAfter<BasicIRNode>(node);
|
||||
|
||||
// Assert
|
||||
Assert.Collection(
|
||||
builder.Current.Children,
|
||||
n => Assert.IsType<BasicIRNode>(n),
|
||||
n => Assert.IsType<BasicIRNode>(n),
|
||||
n => Assert.IsType<BasicIRNode3>(n),
|
||||
n => Assert.Same(node, n));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddAfter_AfterMatch_Noncontinuous()
|
||||
{
|
||||
// Arrange
|
||||
var builder = RazorIRBuilder.Document();
|
||||
builder.Add(new BasicIRNode());
|
||||
builder.Add(new BasicIRNode2());
|
||||
builder.Add(new BasicIRNode());
|
||||
|
||||
var node = new BasicIRNode3();
|
||||
|
||||
// Act
|
||||
builder.AddAfter<BasicIRNode>(node);
|
||||
|
||||
// Assert
|
||||
Assert.Collection(
|
||||
builder.Current.Children,
|
||||
n => Assert.IsType<BasicIRNode>(n),
|
||||
n => Assert.IsType<BasicIRNode2>(n),
|
||||
n => Assert.IsType<BasicIRNode>(n),
|
||||
n => Assert.Same(node, n));
|
||||
}
|
||||
|
||||
private class BasicIRNode : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations { get; } = new DefaultItemCollection();
|
||||
|
||||
public override IList<RazorIRNode> Children { get; } = new List<RazorIRNode>();
|
||||
|
||||
public override RazorIRNode Parent { get; set; }
|
||||
|
||||
public override SourceSpan? Source { get; set; }
|
||||
|
||||
public override void Accept(RazorIRNodeVisitor visitor)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private class BasicIRNode2 : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations { get; } = new DefaultItemCollection();
|
||||
|
||||
public override IList<RazorIRNode> Children { get; } = new List<RazorIRNode>();
|
||||
|
||||
public override RazorIRNode Parent { get; set; }
|
||||
|
||||
public override SourceSpan? Source { get; set; }
|
||||
|
||||
public override void Accept(RazorIRNodeVisitor visitor)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private class BasicIRNode3 : RazorIRNode
|
||||
{
|
||||
public override ItemCollection Annotations { get; } = new DefaultItemCollection();
|
||||
|
||||
public override IList<RazorIRNode> Children { get; } = new List<RazorIRNode>();
|
||||
|
||||
public override RazorIRNode Parent { get; set; }
|
||||
|
||||
public override SourceSpan? Source { get; set; }
|
||||
|
||||
public override void Accept(RazorIRNodeVisitor visitor)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue