Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit ded13b7

Browse files
committed
Feedback
1 parent b9ba360 commit ded13b7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Microsoft.AspNetCore.Razor.Language/Legacy/SpanEditHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Diagnostics;
67
using System.Linq;
78
using Microsoft.AspNetCore.Razor.Language.Syntax;
89

@@ -115,6 +116,10 @@ protected virtual SyntaxNode UpdateSpan(SyntaxNode target, SourceChange change)
115116
{
116117
newTarget = Syntax.InternalSyntax.SyntaxFactory.UnclassifiedTextLiteral(builder.ToList()).CreateRed(target.Parent, target.Position);
117118
}
119+
else
120+
{
121+
Debug.Fail($"The type {target?.GetType().Name} is not a supported span node.");
122+
}
118123

119124
var context = target.GetSpanContext();
120125
newTarget = context != null ? newTarget?.WithSpanContext(context) : newTarget;

src/Microsoft.AspNetCore.Razor.Language/Syntax/LegacySyntaxNodeExtensions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,13 @@ public static IEnumerable<SyntaxNode> FlattenSpans(this SyntaxNode node)
190190
throw new ArgumentNullException(nameof(node));
191191
}
192192

193-
var spanNodes = node.DescendantNodes().Where(n => n.IsSpanKind());
194-
return spanNodes;
193+
foreach (var child in node.DescendantNodes())
194+
{
195+
if (child.IsSpanKind())
196+
{
197+
yield return child;
198+
}
199+
}
195200
}
196201

197202
public static SyntaxNode PreviousSpan(this SyntaxNode node)

0 commit comments

Comments
 (0)