| File: Language\Syntax\InternalSyntax\SyntaxRewriter.cs | Web Access |
| Project: src\roslyn\src\Razor\src\Compiler\Microsoft.CodeAnalysis.Razor.Compiler\src\Microsoft.CodeAnalysis.Razor.Compiler.csproj (Microsoft.CodeAnalysis.Razor.Compiler) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable disable namespace Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax; internal abstract partial class SyntaxRewriter : SyntaxVisitor<GreenNode> { public override GreenNode VisitToken(SyntaxToken token) { return token; } public SyntaxList<TNode> VisitList<TNode>(SyntaxList<TNode> list) where TNode : GreenNode { SyntaxListBuilder alternate = null; for (int i = 0, n = list.Count; i < n; i++) { var item = list[i]; var visited = Visit(item); if (item != visited && alternate == null) { alternate = new SyntaxListBuilder(n); alternate.AddRange(list, 0, i); } if (alternate != null) { alternate.Add(visited); } } if (alternate != null) { return alternate.ToList<TNode>(); } return list; } }