diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BindLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BindLoweringPass.cs index c03cb3e707..34fdd2d26c 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BindLoweringPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BindLoweringPass.cs @@ -262,7 +262,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } }; - if (parent is HtmlElementIntermediateNode) + if (parent is MarkupElementIntermediateNode) { var valueNode = new HtmlAttributeIntermediateNode() { @@ -303,7 +303,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } else { - var valueNode = new ComponentAttributeExtensionNode(node) + var valueNode = new ComponentAttributeIntermediateNode(node) { AttributeName = valueAttributeName, BoundAttribute = valueAttribute, // Might be null if it doesn't match a component attribute @@ -319,7 +319,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components valueNode.Children[0].Children.Add(valueExpressionTokens[i]); } - var changeNode = new ComponentAttributeExtensionNode(node) + var changeNode = new ComponentAttributeIntermediateNode(node) { AttributeName = changeAttributeName, BoundAttribute = changeAttribute, // Might be null if it doesn't match a component attribute @@ -412,7 +412,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components changeAttributeName = node.TagHelper.GetChangeAttributeName() ?? changeAttributeName; // We expect 0-1 components per-node. - var componentTagHelper = (parent as ComponentExtensionNode)?.Component; + var componentTagHelper = (parent as ComponentIntermediateNode)?.Component; if (componentTagHelper == null) { // If it's not a component node then there isn't too much else to figure out. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorDesignTimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorDesignTimeNodeWriter.cs index 963ea24f44..753c220e87 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorDesignTimeNodeWriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorDesignTimeNodeWriter.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components private static readonly string DesignTimeVariable = "__o"; - public override void WriteHtmlBlock(CodeRenderingContext context, HtmlBlockIntermediateNode node) + public override void WriteHtmlBlock(CodeRenderingContext context, MarkupBlockIntermediateNode node) { if (context == null) { @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components // Do nothing } - public override void WriteHtmlElement(CodeRenderingContext context, HtmlElementIntermediateNode node) + public override void WriteHtmlElement(CodeRenderingContext context, MarkupElementIntermediateNode node) { if (context == null) { @@ -329,7 +329,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components .WriteParameterSeparator(); } - public override void WriteComponent(CodeRenderingContext context, ComponentExtensionNode node) + public override void WriteComponent(CodeRenderingContext context, ComponentIntermediateNode node) { if (context == null) { @@ -459,7 +459,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } } - public override void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeExtensionNode node) + public override void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeIntermediateNode node) { if (context == null) { @@ -483,7 +483,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components context.CodeWriter.WriteLine(); } - private void WriteComponentAttributeInnards(CodeRenderingContext context, ComponentAttributeExtensionNode node, bool canTypeCheck) + private void WriteComponentAttributeInnards(CodeRenderingContext context, ComponentAttributeIntermediateNode node, bool canTypeCheck) { // We limit component attributes to simple cases. However there is still a lot of complexity // to handle here, since there are a few different cases for how an attribute might be structured. @@ -567,12 +567,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } } - bool NeedsTypeCheck(ComponentAttributeExtensionNode n) + bool NeedsTypeCheck(ComponentAttributeIntermediateNode n) { return n.BoundAttribute != null && !n.BoundAttribute.IsWeaklyTyped(); } - IReadOnlyList GetCSharpTokens(ComponentAttributeExtensionNode attribute) + IReadOnlyList GetCSharpTokens(ComponentAttributeIntermediateNode attribute) { // We generally expect all children to be CSharp, this is here just in case. return attribute.FindDescendantNodes().Where(t => t.IsCSharp).ToArray(); @@ -623,7 +623,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components _scopeStack.CloseScope(context); } - public override void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentExtensionNode node) + public override void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentIntermediateNode node) { if (context == null) { @@ -651,7 +651,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components context.CodeWriter.Write(");"); context.CodeWriter.WriteLine(); - IReadOnlyList GetCSharpTokens(ComponentTypeArgumentExtensionNode arg) + IReadOnlyList GetCSharpTokens(ComponentTypeArgumentIntermediateNode arg) { // We generally expect all children to be CSharp, this is here just in case. return arg.FindDescendantNodes().Where(t => t.IsCSharp).ToArray(); @@ -678,7 +678,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components _scopeStack.CloseScope(context); } - public override void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode node) + public override void WriteReferenceCapture(CodeRenderingContext context, ReferenceCaptureIntermediateNode node) { if (context == null) { @@ -696,7 +696,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components WriteReferenceCaptureInnards(context, node, shouldTypeCheck: true); } - protected override void WriteReferenceCaptureInnards(CodeRenderingContext context, RefExtensionNode node, bool shouldTypeCheck) + protected override void WriteReferenceCaptureInnards(CodeRenderingContext context, ReferenceCaptureIntermediateNode node, bool shouldTypeCheck) { // We specialize this code based on whether or not we can type check. When we're calling into // a type-inferenced component, we can't do the type check. See the comments in WriteTypeInferenceMethod. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorExtensionInitializer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorExtensionInitializer.cs index 9a8003de3d..6a03dc07e8 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorExtensionInitializer.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorExtensionInitializer.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components builder.Features.Add(new ComplexAttributeContentPass()); builder.Features.Add(new ComponentLoweringPass()); builder.Features.Add(new EventHandlerLoweringPass()); - builder.Features.Add(new RefLoweringPass()); + builder.Features.Add(new ReferenceCaptureLoweringPass()); builder.Features.Add(new BindLoweringPass()); builder.Features.Add(new TemplateDiagnosticPass()); builder.Features.Add(new GenericComponentPass()); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorNodeWriter.cs index 7e3a8e199d..256ffbee8f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorNodeWriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorNodeWriter.cs @@ -14,21 +14,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { public abstract void BeginWriteAttribute(CodeWriter codeWriter, string key); - public abstract void WriteComponent(CodeRenderingContext context, ComponentExtensionNode node); + public abstract void WriteComponent(CodeRenderingContext context, ComponentIntermediateNode node); - public abstract void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeExtensionNode node); + public abstract void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeIntermediateNode node); public abstract void WriteComponentChildContent(CodeRenderingContext context, ComponentChildContentIntermediateNode node); - public abstract void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentExtensionNode node); + public abstract void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentIntermediateNode node); - public abstract void WriteHtmlElement(CodeRenderingContext context, HtmlElementIntermediateNode node); + public abstract void WriteHtmlElement(CodeRenderingContext context, MarkupElementIntermediateNode node); - public abstract void WriteHtmlBlock(CodeRenderingContext context, HtmlBlockIntermediateNode node); + public abstract void WriteHtmlBlock(CodeRenderingContext context, MarkupBlockIntermediateNode node); - public abstract void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode node); + public abstract void WriteReferenceCapture(CodeRenderingContext context, ReferenceCaptureIntermediateNode node); - protected abstract void WriteReferenceCaptureInnards(CodeRenderingContext context, RefExtensionNode node, bool shouldTypeCheck); + protected abstract void WriteReferenceCaptureInnards(CodeRenderingContext context, ReferenceCaptureIntermediateNode node, bool shouldTypeCheck); public abstract void WriteTemplate(CodeRenderingContext context, TemplateIntermediateNode node); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorRuntimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorRuntimeNodeWriter.cs index 70a8965c18..4d7fc4db3c 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorRuntimeNodeWriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/BlazorRuntimeNodeWriter.cs @@ -145,7 +145,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } } - public override void WriteHtmlBlock(CodeRenderingContext context, HtmlBlockIntermediateNode node) + public override void WriteHtmlBlock(CodeRenderingContext context, MarkupBlockIntermediateNode node) { if (context == null) { @@ -165,7 +165,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components .WriteEndMethodInvocation(); } - public override void WriteHtmlElement(CodeRenderingContext context, HtmlElementIntermediateNode node) + public override void WriteHtmlElement(CodeRenderingContext context, MarkupElementIntermediateNode node) { if (context == null) { @@ -278,7 +278,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components context.CodeWriter.WriteUsing(node.Content, endLine: true); } - public override void WriteComponent(CodeRenderingContext context, ComponentExtensionNode node) + public override void WriteComponent(CodeRenderingContext context, ComponentIntermediateNode node) { if (context == null) { @@ -412,7 +412,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } } - public override void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeExtensionNode node) + public override void WriteComponentAttribute(CodeRenderingContext context, ComponentAttributeIntermediateNode node) { if (context == null) { @@ -440,7 +440,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components context.CodeWriter.WriteLine(); } - private void WriteComponentAttributeInnards(CodeRenderingContext context, ComponentAttributeExtensionNode node, bool canTypeCheck) + private void WriteComponentAttributeInnards(CodeRenderingContext context, ComponentAttributeIntermediateNode node, bool canTypeCheck) { if (node.AttributeStructure == AttributeStructure.Minimized) { @@ -505,7 +505,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } } - IReadOnlyList GetCSharpTokens(ComponentAttributeExtensionNode attribute) + IReadOnlyList GetCSharpTokens(ComponentAttributeIntermediateNode attribute) { // We generally expect all children to be CSharp, this is here just in case. return attribute.FindDescendantNodes().Where(t => t.IsCSharp).ToArray(); @@ -517,7 +517,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components return html.FindDescendantNodes().Where(t => t.IsHtml).ToArray(); } - bool NeedsTypeCheck(ComponentAttributeExtensionNode n) + bool NeedsTypeCheck(ComponentAttributeIntermediateNode n) { return node.BoundAttribute != null && !node.BoundAttribute.IsWeaklyTyped(); } @@ -567,7 +567,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components _scopeStack.CloseScope(context); } - public override void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentExtensionNode node) + public override void WriteComponentTypeArgument(CodeRenderingContext context, ComponentTypeArgumentIntermediateNode node) { // We can skip type arguments during runtime codegen, they are handled in the // type/parameter declarations. @@ -593,7 +593,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components _scopeStack.CloseScope(context); } - public override void WriteReferenceCapture(CodeRenderingContext context, RefExtensionNode node) + public override void WriteReferenceCapture(CodeRenderingContext context, ReferenceCaptureIntermediateNode node) { // Looks like: // @@ -615,7 +615,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components codeWriter.WriteEndMethodInvocation(); } - protected override void WriteReferenceCaptureInnards(CodeRenderingContext context, RefExtensionNode node, bool shouldTypeCheck) + protected override void WriteReferenceCaptureInnards(CodeRenderingContext context, ReferenceCaptureIntermediateNode node, bool shouldTypeCheck) { // Looks like: // diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ChildContentDiagnosticPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ChildContentDiagnosticPass.cs index bcf31bb031..c004e51bca 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ChildContentDiagnosticPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ChildContentDiagnosticPass.cs @@ -19,9 +19,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components visitor.Visit(documentNode); } - private class Visitor : IntermediateNodeWalker, IExtensionIntermediateNodeVisitor, IExtensionIntermediateNodeVisitor + private class Visitor : IntermediateNodeWalker { - public void VisitExtension(ComponentExtensionNode node) + public override void VisitComponent(ComponentIntermediateNode node) { // Check for properties that are set by both element contents (body) and the attribute itself. foreach (var childContent in node.ChildContents) @@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components base.VisitDefault(node); } - public void VisitExtension(ComponentChildContentIntermediateNode node) + public override void VisitComponentChildContent(ComponentChildContentIntermediateNode node) { // Check that each child content has a unique parameter name within its scope. This is important // because the parameter name can be implicit, and it doesn't work well when nested. @@ -58,9 +58,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components node.Diagnostics.Add(ComponentDiagnosticFactory.Create_ChildContentRepeatedParameterName( node.Source, node, - (ComponentExtensionNode)Ancestors[0], // Enclosing component + (ComponentIntermediateNode)Ancestors[0], // Enclosing component ancestor, // conflicting child content node - (ComponentExtensionNode)Ancestors[i + 1])); // Enclosing component of conflicting child content node + (ComponentIntermediateNode)Ancestors[i + 1])); // Enclosing component of conflicting child content node } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs index 14df6420ad..7d83745575 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs @@ -217,7 +217,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components "following top-level items: {1}.", RazorDiagnosticSeverity.Error); - public static RazorDiagnostic Create_ChildContentMixedWithExplicitChildContent(SourceSpan? source, ComponentExtensionNode component) + public static RazorDiagnostic Create_ChildContentMixedWithExplicitChildContent(SourceSpan? source, ComponentIntermediateNode component) { var supportedElements = string.Join(", ", component.Component.GetChildContentProperties().Select(p => $"'{p.Name}'")); return RazorDiagnostic.Create(ChildContentMixedWithExplicitChildContent, source ?? SourceSpan.Undefined, component.TagName, supportedElements); @@ -255,9 +255,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components public static RazorDiagnostic Create_ChildContentRepeatedParameterName( SourceSpan? source, ComponentChildContentIntermediateNode childContent1, - ComponentExtensionNode component1, + ComponentIntermediateNode component1, ComponentChildContentIntermediateNode childContent2, - ComponentExtensionNode component2) + ComponentIntermediateNode component2) { Debug.Assert(childContent1.ParameterName == childContent2.ParameterName); Debug.Assert(childContent1.IsParameterized); @@ -281,7 +281,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components public static RazorDiagnostic Create_GenericComponentMissingTypeArgument( SourceSpan? source, - ComponentExtensionNode component, + ComponentIntermediateNode component, IEnumerable attributes) { Debug.Assert(component.Component.IsGenericTypedComponent()); @@ -299,7 +299,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components public static RazorDiagnostic Create_GenericComponentTypeInferenceUnderspecified( SourceSpan? source, - ComponentExtensionNode component, + ComponentIntermediateNode component, IEnumerable attributes) { Debug.Assert(component.Component.IsGenericTypedComponent()); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentExtensionNode.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentExtensionNode.cs deleted file mode 100644 index cbd9ac592a..0000000000 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentExtensionNode.cs +++ /dev/null @@ -1,107 +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 System.Linq; -using System.Text; -using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.Language.CodeGeneration; -using Microsoft.AspNetCore.Razor.Language.Intermediate; - -namespace Microsoft.AspNetCore.Razor.Language.Components -{ - internal class ComponentExtensionNode : ExtensionIntermediateNode - { - public IEnumerable Attributes => Children.OfType(); - - public IEnumerable Captures => Children.OfType(); - - public IEnumerable ChildContents => Children.OfType(); - - public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection(); - - public TagHelperDescriptor Component { get; set; } - - /// - /// Gets the child content parameter name (null if unset) that was applied at the component level. - /// - public string ChildContentParameterName { get; set; } - - public IEnumerable TypeArguments => Children.OfType(); - - public string TagName { get; set; } - - // An optional type inference node. This will be populated (and point to a different part of the tree) - // if this component call site requires type inference. - public ComponentTypeInferenceMethodIntermediateNode TypeInferenceNode { get; set; } - - public string TypeName { get; set; } - - public override void Accept(IntermediateNodeVisitor visitor) - { - if (visitor == null) - { - throw new ArgumentNullException(nameof(visitor)); - } - - AcceptExtensionNode(this, visitor); - } - - public override void WriteNode(CodeTarget target, CodeRenderingContext context) - { - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var writer = (BlazorNodeWriter)context.NodeWriter; - writer.WriteComponent(context, this); - } - - private string DebuggerDisplay - { - get - { - var builder = new StringBuilder(); - builder.Append("Component: "); - builder.Append("<"); - builder.Append(TagName); - - foreach (var attribute in Attributes) - { - builder.Append(" "); - builder.Append(attribute.AttributeName); - builder.Append("=\"...\""); - } - - foreach (var capture in Captures) - { - builder.Append(" "); - builder.Append("ref"); - builder.Append("=\"...\""); - } - - foreach (var typeArgument in TypeArguments) - { - builder.Append(" "); - builder.Append(typeArgument.TypeParameterName); - builder.Append("=\"...\""); - } - - builder.Append(">"); - builder.Append(ChildContents.Any() ? "..." : string.Empty); - builder.Append(""); - - return builder.ToString(); - } - } - } -} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs index 0f9008c09e..c32df5738d 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs @@ -60,9 +60,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } } - private ComponentExtensionNode RewriteAsComponent(TagHelperIntermediateNode node, TagHelperDescriptor tagHelper) + private ComponentIntermediateNode RewriteAsComponent(TagHelperIntermediateNode node, TagHelperDescriptor tagHelper) { - var component = new ComponentExtensionNode() + var component = new ComponentIntermediateNode() { Component = tagHelper, Source = node.Source, @@ -88,9 +88,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components return component; } - private HtmlElementIntermediateNode RewriteAsElement(TagHelperIntermediateNode node) + private MarkupElementIntermediateNode RewriteAsElement(TagHelperIntermediateNode node) { - var result = new HtmlElementIntermediateNode() + var result = new MarkupElementIntermediateNode() { Source = node.Source, TagName = node.TagName, @@ -109,10 +109,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components private class ComponentRewriteVisitor : IntermediateNodeWalker { - private readonly ComponentExtensionNode _component; + private readonly ComponentIntermediateNode _component; private readonly IntermediateNodeCollection _children; - public ComponentRewriteVisitor(ComponentExtensionNode component) + public ComponentRewriteVisitor(ComponentIntermediateNode component) { _component = component; _children = component.Children; @@ -290,7 +290,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components public override void VisitTagHelperHtmlAttribute(TagHelperHtmlAttributeIntermediateNode node) { - var attribute = new ComponentAttributeExtensionNode(node); + var attribute = new ComponentAttributeIntermediateNode(node); _children.Add(attribute); // Since we don't support complex content, we can rewrite the inside of this @@ -348,7 +348,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components // that get passed to the component, it needs special code generation support. if (node.TagHelper.IsGenericTypedComponent() && node.BoundAttribute.IsTypeParameterProperty()) { - _children.Add(new ComponentTypeArgumentExtensionNode(node)); + _children.Add(new ComponentTypeArgumentIntermediateNode(node)); return; } @@ -371,7 +371,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components return; } - _children.Add(new ComponentAttributeExtensionNode(node)); + _children.Add(new ComponentAttributeIntermediateNode(node)); } public override void VisitDefault(IntermediateNode node) @@ -476,7 +476,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components // Each 'tag helper property' belongs to a specific tag helper. We want to handle // the cases for components, but leave others alone. This allows our other passes // to handle those cases. - _children.Add(node.TagHelper.IsComponentTagHelper() ? (IntermediateNode)new ComponentAttributeExtensionNode(node) : node); + _children.Add(node.TagHelper.IsComponentTagHelper() ? (IntermediateNode)new ComponentAttributeIntermediateNode(node) : node); } public override void VisitDefault(IntermediateNode node) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/EventHandlerLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/EventHandlerLoweringPass.cs index 49c05935e1..4ee38ed992 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/EventHandlerLoweringPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/EventHandlerLoweringPass.cs @@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { for (var j = 0; j < parent.Children.Count; j++) { - var componentAttribute = parent.Children[j] as ComponentAttributeExtensionNode; + var componentAttribute = parent.Children[j] as ComponentAttributeIntermediateNode; if (componentAttribute != null && componentAttribute.TagHelper != null && componentAttribute.TagHelper.IsComponentTagHelper() && @@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components tokens.Insert(i + 1, original[i]); } - if (parent is HtmlElementIntermediateNode) + if (parent is MarkupElementIntermediateNode) { var result = new HtmlAttributeIntermediateNode() { @@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } else { - var result = new ComponentAttributeExtensionNode(node); + var result = new ComponentAttributeIntermediateNode(node); result.Children.Clear(); result.Children.Add(new CSharpExpressionIntermediateNode()); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/GenericComponentPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/GenericComponentPass.cs index eebe7db984..f1932742a0 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/GenericComponentPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/GenericComponentPass.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components visitor.Visit(documentNode); } - private class Visitor : IntermediateNodeWalker, IExtensionIntermediateNodeVisitor + private class Visitor : IntermediateNodeWalker { private readonly TypeNameFeature _typeNameFeature; @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components _typeNameFeature = typeNameFeature; } - public void VisitExtension(ComponentExtensionNode node) + public override void VisitComponent(ComponentIntermediateNode node) { if (node.Component.IsGenericTypedComponent()) { @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components base.VisitDefault(node); } - private void Process(ComponentExtensionNode node) + private void Process(ComponentIntermediateNode node) { // First collect all of the information we have about each type parameter // @@ -157,12 +157,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Components CreateTypeInferenceMethod(documentNode, node); } - private string GetContent(ComponentTypeArgumentExtensionNode node) + private string GetContent(ComponentTypeArgumentIntermediateNode node) { return string.Join(string.Empty, node.FindDescendantNodes().Where(t => t.IsCSharp).Select(t => t.Content)); } - private static bool ValidateTypeArguments(ComponentExtensionNode node, Dictionary bindings) + private static bool ValidateTypeArguments(ComponentIntermediateNode node, Dictionary bindings) { var missing = new List(); foreach (var binding in bindings) @@ -185,7 +185,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components return true; } - private void RewriteTypeNames(TypeNameRewriter rewriter, ComponentExtensionNode node) + private void RewriteTypeNames(TypeNameRewriter rewriter, ComponentIntermediateNode node) { // Rewrite the component type name node.TypeName = rewriter.Rewrite(node.TypeName); @@ -243,7 +243,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } } - private void CreateTypeInferenceMethod(DocumentIntermediateNode documentNode, ComponentExtensionNode node) + private void CreateTypeInferenceMethod(DocumentIntermediateNode documentNode, ComponentIntermediateNode node) { var @namespace = documentNode.FindPrimaryNamespace().Content; @namespace = string.IsNullOrEmpty(@namespace) ? "__Blazor" : "__Blazor." + @namespace; @@ -308,7 +308,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components public string Content { get; set; } - public ComponentTypeArgumentExtensionNode Node { get; set; } + public ComponentTypeArgumentIntermediateNode Node { get; set; } } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/HtmlBlockPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/HtmlBlockPass.cs index 3106bbbaaf..e2cb256ff8 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/HtmlBlockPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/HtmlBlockPass.cs @@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components length--; } - reference.Parent.Children.Insert(start, new HtmlBlockIntermediateNode() + reference.Parent.Children.Insert(start, new MarkupBlockIntermediateNode() { Content = rewriteVisitor.Builder.ToString(), }); @@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components // the a from the list. private class FindHtmlTreeVisitor : IntermediateNodeWalker, - IExtensionIntermediateNodeVisitor + IExtensionIntermediateNodeVisitor { private bool _foundNonHtml; @@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components base.VisitDefault(node); } - public void VisitExtension(HtmlElementIntermediateNode node) + public void VisitExtension(MarkupElementIntermediateNode node) { // We need to restore the state after processing this node. // We might have found a leaf-block of HTML, but that shouldn't @@ -228,7 +228,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components private class RewriteVisitor : IntermediateNodeWalker, - IExtensionIntermediateNodeVisitor + IExtensionIntermediateNodeVisitor { private readonly StringBuilder _encodingBuilder; @@ -243,7 +243,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components public StringBuilder Builder { get; } = new StringBuilder(); - public void VisitExtension(HtmlElementIntermediateNode node) + public void VisitExtension(MarkupElementIntermediateNode node) { for (var i = 0; i < _trees.Count; i++) { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/RefLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ReferenceCaptureLoweringPass.cs similarity index 88% rename from src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/RefLoweringPass.cs rename to src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ReferenceCaptureLoweringPass.cs index f53c7d33a2..c5a9cbac02 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/RefLoweringPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ReferenceCaptureLoweringPass.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language.Components { - internal class RefLoweringPass : IntermediateNodePassBase, IRazorOptimizationPass + internal class ReferenceCaptureLoweringPass : IntermediateNodePassBase, IRazorOptimizationPass { // Run after component lowering pass public override int Order => 50; @@ -46,14 +46,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Components // Determine whether this is an element capture or a component capture, and // if applicable the type name that will appear in the resulting capture code - var componentTagHelper = (parent as ComponentExtensionNode)?.Component; + var componentTagHelper = (parent as ComponentIntermediateNode)?.Component; if (componentTagHelper != null) { - return new RefExtensionNode(identifierToken, componentTagHelper.GetTypeName()); + return new ReferenceCaptureIntermediateNode(identifierToken, componentTagHelper.GetTypeName()); } else { - return new RefExtensionNode(identifierToken); + return new ReferenceCaptureIntermediateNode(identifierToken); } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ScriptTagPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ScriptTagPass.cs index 52c2b39a50..01086ec3ac 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ScriptTagPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ScriptTagPass.cs @@ -22,9 +22,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components visitor.Visit(documentNode); } - private class Visitor : IntermediateNodeWalker, IExtensionIntermediateNodeVisitor + private class Visitor : IntermediateNodeWalker, IExtensionIntermediateNodeVisitor { - public void VisitExtension(HtmlElementIntermediateNode node) + public void VisitExtension(MarkupElementIntermediateNode node) { // Disallow