|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
4 | 4 | using System.Collections.Immutable;
|
| 5 | +using System.Diagnostics; |
5 | 6 | using Microsoft.AspNetCore.Razor.Language.Legacy;
|
6 | 7 | using Microsoft.AspNetCore.Razor.Language.Syntax;
|
7 | 8 | using Microsoft.AspNetCore.Razor.PooledObjects;
|
@@ -366,49 +367,40 @@ public void Dispose()
|
366 | 367 | }
|
367 | 368 | }
|
368 | 369 |
|
369 |
| - private void WriteSpan(SyntaxNode node, SpanKindInternal kind, AcceptedCharactersInternal? acceptedCharacters = null) |
| 370 | + private void WriteSpan(SyntaxNode node, SpanKindInternal kind) |
370 | 371 | {
|
371 | 372 | if (node.IsMissing)
|
372 | 373 | {
|
373 | 374 | return;
|
374 | 375 | }
|
375 | 376 |
|
| 377 | + Debug.Assert(_currentBlock != null, "Current block should not be null when writing a span for a node."); |
| 378 | + |
376 | 379 | var spanSource = node.GetSourceSpan(_source);
|
377 | 380 | var blockSource = _currentBlock.GetSourceSpan(_source);
|
378 |
| - if (!acceptedCharacters.HasValue) |
379 |
| - { |
380 |
| - acceptedCharacters = AcceptedCharactersInternal.Any; |
381 |
| - var context = node.GetEditHandler(); |
382 |
| - if (context != null) |
383 |
| - { |
384 |
| - acceptedCharacters = context.AcceptedCharacters; |
385 |
| - } |
386 |
| - } |
387 | 381 |
|
388 |
| - var span = new ClassifiedSpanInternal(spanSource, blockSource, kind, _currentBlockKind, acceptedCharacters.Value); |
| 382 | + var acceptedCharacters = node.GetEditHandler() is { } context |
| 383 | + ? context.AcceptedCharacters |
| 384 | + : AcceptedCharactersInternal.Any; |
| 385 | + |
| 386 | + var span = new ClassifiedSpanInternal(spanSource, blockSource, kind, _currentBlockKind, acceptedCharacters); |
| 387 | + |
389 | 388 | _spans.Add(span);
|
390 | 389 | }
|
391 | 390 |
|
392 |
| - private void WriteSpan(SyntaxToken token, SpanKindInternal kind, AcceptedCharactersInternal? acceptedCharacters = null) |
| 391 | + private void WriteSpan(SyntaxToken token, SpanKindInternal kind, AcceptedCharactersInternal acceptedCharacters) |
393 | 392 | {
|
394 | 393 | if (token.IsMissing)
|
395 | 394 | {
|
396 | 395 | return;
|
397 | 396 | }
|
398 | 397 |
|
| 398 | + Debug.Assert(_currentBlock != null, "Current block should not be null when writing a span for a token."); |
| 399 | + |
399 | 400 | var spanSource = token.GetSourceSpan(_source);
|
400 | 401 | var blockSource = _currentBlock.GetSourceSpan(_source);
|
401 |
| - if (!acceptedCharacters.HasValue) |
402 |
| - { |
403 |
| - acceptedCharacters = AcceptedCharactersInternal.Any; |
404 |
| - var context = token.GetEditHandler(); |
405 |
| - if (context != null) |
406 |
| - { |
407 |
| - acceptedCharacters = context.AcceptedCharacters; |
408 |
| - } |
409 |
| - } |
| 402 | + var span = new ClassifiedSpanInternal(spanSource, blockSource, kind, _currentBlockKind, acceptedCharacters); |
410 | 403 |
|
411 |
| - var span = new ClassifiedSpanInternal(spanSource, blockSource, kind, _currentBlockKind, acceptedCharacters.Value); |
412 | 404 | _spans.Add(span);
|
413 | 405 | }
|
414 | 406 |
|
|
0 commit comments