Some minor cleanup (dotnet/aspnetcore-tooling#123)
\n\nCommit migrated from 97930b91f8
This commit is contained in:
parent
40633dde21
commit
ceb4d0853a
|
|
@ -751,7 +751,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
var context = node.GetSpanContext();
|
||||
if (context != null && context.ChunkGenerator == SpanChunkGenerator.Null)
|
||||
{
|
||||
base.VisitMarkupTextLiteral(node);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -763,11 +762,48 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
token.Content.Length == 0)
|
||||
{
|
||||
// We don't want to create IR nodes for marker tokens.
|
||||
base.VisitMarkupTextLiteral(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VisitHtmlContent(node);
|
||||
}
|
||||
|
||||
public override void VisitMarkupStartTag(MarkupStartTagSyntax node)
|
||||
{
|
||||
if (node.IsMarkupTransition)
|
||||
{
|
||||
// No need to visit <text> tags.
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var child in node.Children)
|
||||
{
|
||||
Visit(child);
|
||||
}
|
||||
}
|
||||
|
||||
public override void VisitMarkupEndTag(MarkupEndTagSyntax node)
|
||||
{
|
||||
if (node.IsMarkupTransition)
|
||||
{
|
||||
// No need to visit </text> tags.
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var child in node.Children)
|
||||
{
|
||||
Visit(child);
|
||||
}
|
||||
}
|
||||
|
||||
private void VisitHtmlContent(SyntaxNode node)
|
||||
{
|
||||
if (node == null || (node is SyntaxToken token && token.IsMissing))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var source = BuildSourceSpanFromNode(node);
|
||||
var currentChildren = _builder.Current.Children;
|
||||
if (currentChildren.Count > 0 && currentChildren[currentChildren.Count - 1] is HtmlContentIntermediateNode)
|
||||
|
|
@ -777,7 +813,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
if (existingHtmlContent.Source == null && source == null)
|
||||
{
|
||||
Combine(existingHtmlContent, node);
|
||||
base.VisitMarkupTextLiteral(node);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -787,7 +822,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
existingHtmlContent.Source.Value.AbsoluteIndex + existingHtmlContent.Source.Value.Length == source.Value.AbsoluteIndex)
|
||||
{
|
||||
Combine(existingHtmlContent, node);
|
||||
base.VisitMarkupTextLiteral(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -806,24 +840,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
});
|
||||
|
||||
_builder.Pop();
|
||||
|
||||
base.VisitMarkupTextLiteral(node);
|
||||
}
|
||||
|
||||
public override void VisitMarkupStartTag(MarkupStartTagSyntax node)
|
||||
{
|
||||
foreach (var child in node.Children)
|
||||
{
|
||||
Visit(child);
|
||||
}
|
||||
}
|
||||
|
||||
public override void VisitMarkupEndTag(MarkupEndTagSyntax node)
|
||||
{
|
||||
foreach (var child in node.Children)
|
||||
{
|
||||
Visit(child);
|
||||
}
|
||||
}
|
||||
|
||||
public override void VisitMarkupTagHelperElement(MarkupTagHelperElementSyntax node)
|
||||
|
|
@ -1140,7 +1156,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
// just process the attributes.
|
||||
//
|
||||
// Visit the attributes
|
||||
foreach (var block in node.Children)
|
||||
foreach (var block in node.Attributes)
|
||||
{
|
||||
if (block is MarkupAttributeBlockSyntax attribute)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
|
|||
throw new ArgumentNullException(nameof(node));
|
||||
}
|
||||
|
||||
var tokens = node.DescendantNodes().Where(n => n.IsToken).Cast<SyntaxToken>();
|
||||
var tokens = node.DescendantNodesAndSelf().Where(n => n.IsToken).Cast<SyntaxToken>();
|
||||
var content = string.Concat(tokens.Select(t => t.Content));
|
||||
return content;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue