Skip to content

Commit 077d686

Browse files
authored
Remove unnecessary IDE references to GetEditHandler (#9054)
There are a few simple IDE scenarios that are using GetEditHandler that do no need to do so. This removes them in preparation for turning off calculations entirely.
1 parent bd4b98f commit 077d686

File tree

4 files changed

+9
-29
lines changed

4 files changed

+9
-29
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/FormattingVisitor.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Microsoft.AspNetCore.Razor.Language;
99
using Microsoft.AspNetCore.Razor.Language.Components;
1010
using Microsoft.AspNetCore.Razor.Language.Extensions;
11-
using Microsoft.AspNetCore.Razor.Language.Legacy;
1211
using Microsoft.AspNetCore.Razor.Language.Syntax;
1312
using Microsoft.AspNetCore.Razor.LanguageServer.Extensions;
1413

@@ -506,18 +505,12 @@ private static SyntaxList<RazorSyntaxNode> GetRewrittenMarkupStartTagChildren(Ma
506505
var tokenBuilder = SyntaxListBuilder<SyntaxToken>.Create();
507506
tokenBuilder.AddRange(tokens, 0, tokens.Length);
508507
var markupTransition = SyntaxFactory.MarkupTransition(tokenBuilder.ToList(), node.ChunkGenerator).Green.CreateRed(node, node.Position);
509-
var editHandler = node.GetEditHandler();
510-
if (editHandler != null)
511-
{
512-
markupTransition = markupTransition.WithEditHandler(editHandler);
513-
}
514508

515509
var builder = new SyntaxListBuilder(1);
516510
builder.Add(markupTransition);
517511
return new SyntaxList<RazorSyntaxNode>(builder.ToListNode().CreateRed(node, node.Position));
518512
}
519513

520-
SpanEditHandler? latestSpanEditHandler = null;
521514
var children = node.Children;
522515
var newChildren = new SyntaxListBuilder(children.Count);
523516
var literals = new List<MarkupTextLiteralSyntax>();
@@ -526,7 +519,6 @@ private static SyntaxList<RazorSyntaxNode> GetRewrittenMarkupStartTagChildren(Ma
526519
if (child is MarkupTextLiteralSyntax literal)
527520
{
528521
literals.Add(literal);
529-
latestSpanEditHandler = literal.GetEditHandler() ?? latestSpanEditHandler;
530522
}
531523
else if (child is MarkupMiscAttributeContentSyntax miscContent)
532524
{
@@ -535,7 +527,6 @@ private static SyntaxList<RazorSyntaxNode> GetRewrittenMarkupStartTagChildren(Ma
535527
if (contentChild is MarkupTextLiteralSyntax contentLiteral)
536528
{
537529
literals.Add(contentLiteral);
538-
latestSpanEditHandler = contentLiteral.GetEditHandler() ?? latestSpanEditHandler;
539530
}
540531
else
541532
{
@@ -561,9 +552,7 @@ void AddLiteralIfExists()
561552
if (literals.Count > 0)
562553
{
563554
var mergedLiteral = SyntaxUtilities.MergeTextLiterals(literals.ToArray());
564-
mergedLiteral = mergedLiteral.WithEditHandler(latestSpanEditHandler);
565555
literals.Clear();
566-
latestSpanEditHandler = null;
567556
newChildren.Add(mergedLiteral);
568557
}
569558
}
@@ -578,11 +567,6 @@ private static SyntaxList<RazorSyntaxNode> GetRewrittenMarkupEndTagChildren(Mark
578567
var tokenBuilder = SyntaxListBuilder<SyntaxToken>.Create();
579568
tokenBuilder.AddRange(tokens, 0, tokens.Length);
580569
var markupTransition = SyntaxFactory.MarkupTransition(tokenBuilder.ToList(), node.ChunkGenerator).Green.CreateRed(node, node.Position);
581-
var editHandler = node.GetEditHandler();
582-
if (editHandler != null)
583-
{
584-
markupTransition = markupTransition.WithEditHandler(editHandler);
585-
}
586570

587571
var builder = new SyntaxListBuilder(1);
588572
builder.Add(markupTransition);

src/Razor/src/Microsoft.VisualStudio.Editor.Razor/ClassifiedSpan.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ namespace Microsoft.VisualStudio.Editor.Razor;
77

88
public struct ClassifiedSpan
99
{
10-
public ClassifiedSpan(SourceSpan span, SourceSpan blockSpan, SpanKind spanKind, BlockKind blockKind, AcceptedCharacters acceptedCharacters)
10+
public ClassifiedSpan(SourceSpan span, SourceSpan blockSpan, SpanKind spanKind, BlockKind blockKind)
1111
{
1212
Span = span;
1313
BlockSpan = blockSpan;
1414
SpanKind = spanKind;
1515
BlockKind = blockKind;
16-
AcceptedCharacters = acceptedCharacters;
1716
}
1817

19-
public AcceptedCharacters AcceptedCharacters { get; }
20-
2118
public BlockKind BlockKind { get; }
2219

2320
public SourceSpan BlockSpan { get; }

src/Razor/src/Microsoft.VisualStudio.Editor.Razor/DefaultRazorSyntaxFactsService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public override IReadOnlyList<ClassifiedSpan> GetClassifiedSpans(RazorSyntaxTree
2020
item.Span,
2121
item.BlockSpan,
2222
(SpanKind)item.SpanKind,
23-
(BlockKind)item.BlockKind,
24-
(AcceptedCharacters)item.AcceptedCharacters)).ToArray();
23+
(BlockKind)item.BlockKind)).ToArray();
2524
}
2625

2726
public override IReadOnlyList<TagHelperSpan> GetTagHelperSpans(RazorSyntaxTree syntaxTree)

src/Razor/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultRazorSyntaxFactsServiceTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public void GetClassifiedSpans_ReturnsExpectedSpans()
2626
// Arrange
2727
var expectedSpans = new[]
2828
{
29-
new ClassifiedSpan(new SourceSpan("test.cshtml", 0, 0, 0, 5), new SourceSpan("test.cshtml", 0, 0, 0, 5), SpanKind.Markup, BlockKind.Tag, AcceptedCharacters.Any),
30-
new ClassifiedSpan(new SourceSpan("test.cshtml", 5, 0, 5, 6), new SourceSpan("test.cshtml", 0, 0, 0, 42), SpanKind.Markup, BlockKind.Markup, AcceptedCharacters.Any),
31-
new ClassifiedSpan(new SourceSpan("test.cshtml", 34, 1, 27, 2), new SourceSpan("test.cshtml", 0, 0, 0, 42), SpanKind.Markup, BlockKind.Markup, AcceptedCharacters.Any),
32-
new ClassifiedSpan(new SourceSpan("test.cshtml", 36, 2, 0, 6), new SourceSpan("test.cshtml", 36, 2, 0, 6), SpanKind.Markup, BlockKind.Tag, AcceptedCharacters.Any),
29+
new ClassifiedSpan(new SourceSpan("test.cshtml", 0, 0, 0, 5), new SourceSpan("test.cshtml", 0, 0, 0, 5), SpanKind.Markup, BlockKind.Tag),
30+
new ClassifiedSpan(new SourceSpan("test.cshtml", 5, 0, 5, 6), new SourceSpan("test.cshtml", 0, 0, 0, 42), SpanKind.Markup, BlockKind.Markup),
31+
new ClassifiedSpan(new SourceSpan("test.cshtml", 34, 1, 27, 2), new SourceSpan("test.cshtml", 0, 0, 0, 42), SpanKind.Markup, BlockKind.Markup),
32+
new ClassifiedSpan(new SourceSpan("test.cshtml", 36, 2, 0, 6), new SourceSpan("test.cshtml", 36, 2, 0, 6), SpanKind.Markup, BlockKind.Tag),
3333
};
3434
var codeDocument = GetCodeDocument(
3535
@"<div>
@@ -51,9 +51,9 @@ public void GetClassifiedSpans_ReturnsAttributeSpansInDocumentOrder()
5151
// Arrange
5252
var expectedSpans = new[]
5353
{
54-
new ClassifiedSpan(new SourceSpan("test.cshtml", 14, 0, 14, 1), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Code, BlockKind.Tag, AcceptedCharacters.AnyExceptNewline),
55-
new ClassifiedSpan(new SourceSpan("test.cshtml", 23, 0, 23, 2), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Markup, BlockKind.Tag, AcceptedCharacters.Any),
56-
new ClassifiedSpan(new SourceSpan("test.cshtml", 32, 0, 32, 4), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Code, BlockKind.Tag, AcceptedCharacters.AnyExceptNewline),
54+
new ClassifiedSpan(new SourceSpan("test.cshtml", 14, 0, 14, 1), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Code, BlockKind.Tag),
55+
new ClassifiedSpan(new SourceSpan("test.cshtml", 23, 0, 23, 2), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Markup, BlockKind.Tag),
56+
new ClassifiedSpan(new SourceSpan("test.cshtml", 32, 0, 32, 4), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Code, BlockKind.Tag),
5757
};
5858
var codeDocument = GetCodeDocument(
5959
@"<taghelper id=1 class=""th"" show=true></taghelper>");

0 commit comments

Comments
 (0)