Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c2be582
SyntaxRewriter: Remove VisitToken implementation
DustinCampbell Apr 3, 2025
6237c2b
SyntaxToken: Remove WithLeadingTrivia and WithTrailingTrivia
DustinCampbell Apr 3, 2025
7ff4145
SyntaxWalker: Remove VisitLeadingTrivia and VisitTrailingTrivia
DustinCampbell Apr 3, 2025
39a09d0
SyntaxNode: Remove HasLeadingTrivia and HasTrailingTrivia
DustinCampbell Apr 3, 2025
00f4ae5
SyntaxRewriter: Remove VisitList(SyntaxTriviaList)
DustinCampbell Apr 3, 2025
3060e2d
SyntaxTriviaList: Remove Enumerator.InitializeFrom helpers
DustinCampbell Apr 3, 2025
ac8fdb9
SyntaxNode: Remove GetLeadingTrivia and GetTrailingTrivia
DustinCampbell Apr 3, 2025
ab2325f
Remove SyntaxTriviaList and SyntaxTriviaListBuilder
DustinCampbell Apr 3, 2025
4371ff3
Internal.SyntaxToken: Remove uncalled constructors
DustinCampbell Apr 3, 2025
dffabf3
Internal.SyntaxRewriter: Remove VisitToken implementation
DustinCampbell Apr 3, 2025
8bc91a1
GreenNode: Remove WithLeadingTrivia and WithTrailingTrivia
DustinCampbell Apr 3, 2025
758cc7d
Internal.SyntaxToken: Remove LeadingTrivia and TrailingTrivia
DustinCampbell Apr 3, 2025
34f2a80
GeenNode: Remove HasLeadingTrivia and HasTrailingTrivia
DustinCampbell Apr 3, 2025
6197c1e
GreenNode: Remove GetLeadingTriviaWidth() and GetTrailingTriviaWidth()
DustinCampbell Apr 3, 2025
bdcc24f
GreenNode: Remove logic to write leading/trailing trivia
DustinCampbell Apr 3, 2025
099c81f
Internal.SyntaxToken: Don't compare trivia in IsEquivalentTo
DustinCampbell Apr 3, 2025
339803e
GreenNode: Remove GetLeadingTrivia() and GetTrailingTrivia()
DustinCampbell Apr 3, 2025
d17f252
Internal.SyntaxToken: Remove leading and trailing trivia fields
DustinCampbell Apr 3, 2025
5432996
Remove SyntaxTrivia and InternalSyntax.SyntaxTrivia
DustinCampbell Apr 3, 2025
1977b4a
GreenNode: Consolidate FullWidth and Width
DustinCampbell Apr 3, 2025
74259d7
SyntaxNode: Consolidate FullWidth and Width
DustinCampbell Apr 3, 2025
2186f51
SyntaxNode: Consolidate FullSpan and Span
DustinCampbell Apr 3, 2025
194bae9
Remove outdated comment and simplify GreenNode.WriteTo
DustinCampbell Apr 7, 2025
111ae93
Remove unused NodeFlags
DustinCampbell Apr 7, 2025
48b244a
GreenNode: Remove GetValue and GetValueText
DustinCampbell Apr 7, 2025
559723d
GreenNode: Remove GetFirstToken/Terminal and GetLastToken/Terminal
DustinCampbell Apr 7, 2025
8faf0e6
Remove SyntaxList<T>.FullSpan
DustinCampbell Apr 7, 2025
3d73b3b
GreenNode: Make ToString() to return the same text as ToFullString()
DustinCampbell Apr 7, 2025
947d638
Remove GreenNode.ToFullString() and SyntaxNode.ToFullString()
DustinCampbell Apr 7, 2025
684cae0
Merge branch 'main' into remove-dead-syntax
DustinCampbell Apr 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using Microsoft.AspNetCore.Razor.Language.Components;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Roslyn.Test.Utilities;
using Xunit;

Expand Down Expand Up @@ -356,16 +355,22 @@ public void CodeBlocksTrailingWhitespace_10()
""",
directives: [ComponentCodeDirective.Directive]);

var codeBlock = tree1.Root.ChildNodes()[0].ChildNodes()[1];
Assert.Equal("CSharpCodeBlockSyntax<CSharpCodeBlock> at 0::11", codeBlock.ToString());
var codeBlock = Assert.IsType<CSharpCodeBlockSyntax>(tree1.Root.ChildNodes()[0].ChildNodes()[1]);
Assert.Equal(SyntaxKind.CSharpCodeBlock, codeBlock.Kind);
Assert.Equal(0, codeBlock.Position);
Assert.Equal(11, codeBlock.Width);

var children = codeBlock.ChildNodes();
Assert.Equal(2, children.Count);

var directive = children[0];
Assert.Equal("RazorDirectiveSyntax<RazorDirective> at 0::9", directive.ToString());
var directive = Assert.IsType<RazorDirectiveSyntax>(children[0]);
Assert.Equal(SyntaxKind.RazorDirective, directive.Kind);
Assert.Equal(0, directive.Position);
Assert.Equal(9, directive.Width);

var whitespace = children[1];
Assert.Equal("RazorMetaCodeSyntax<RazorMetaCode> at 9::2", whitespace.ToString());
var whitespace = Assert.IsType<RazorMetaCodeSyntax>(children[1]);
Assert.Equal(SyntaxKind.RazorMetaCode, whitespace.Kind);
Assert.Equal(9, whitespace.Position);
Assert.Equal(2, whitespace.Width);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal void EvaluateData(
var binder = new TagHelperBinder(tagHelperPrefix, descriptors);
var rewrittenTree = TagHelperParseTreeRewriter.Rewrite(syntaxTree, binder, out _);

Assert.Equal(syntaxTree.Root.FullWidth, rewrittenTree.Root.FullWidth);
Assert.Equal(syntaxTree.Root.Width, rewrittenTree.Root.Width);

BaselineTest(rewrittenTree);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal void EvaluateData(
var binder = new TagHelperBinder(tagHelperPrefix, descriptors);
var rewrittenTree = TagHelperParseTreeRewriter.Rewrite(syntaxTree, binder, out _);

Assert.Equal(syntaxTree.Root.FullWidth, rewrittenTree.Root.FullWidth);
Assert.Equal(syntaxTree.Root.Width, rewrittenTree.Root.Width);

BaselineTest(rewrittenTree);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ private void Combine(HtmlContentIntermediateNode node, SyntaxNode item)
node.Source.Value.AbsoluteIndex,
node.Source.Value.LineIndex,
node.Source.Value.CharacterIndex,
node.Source.Value.Length + item.FullWidth,
node.Source.Value.Length + item.Width,
node.Source.Value.LineCount,
node.Source.Value.EndCharacterIndex);
}
Expand Down Expand Up @@ -2223,7 +2223,7 @@ private void Combine(HtmlContentIntermediateNode node, SyntaxNode item)
node.Source.Value.AbsoluteIndex,
node.Source.Value.LineIndex,
node.Source.Value.CharacterIndex,
node.Source.Value.Length + item.FullWidth,
node.Source.Value.Length + item.Width,
node.Source.Value.LineCount,
node.Source.Value.EndCharacterIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ private RazorDirectiveBodySyntax ParseTagHelperDirective(

// Accept the directive name
var keywordToken = EatCurrentToken();
var keywordLength = keywordToken.FullWidth + 1 /* @ */;
var keywordLength = keywordToken.Width + 1 /* @ */;

var foundWhitespace = At(SyntaxKind.Whitespace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ private static bool IsTypeAttribute(MarkupAttributeBlockSyntax attributeBlock)
return false;
}

var trimmedStartContent = attributeBlock.Name.ToFullString().TrimStart();
var trimmedStartContent = attributeBlock.Name.ToString().TrimStart();
if (trimmedStartContent.StartsWith("type", StringComparison.OrdinalIgnoreCase) &&
(trimmedStartContent.Length == 4 ||
ValidAfterTypeAttributeNameCharacters.Contains(trimmedStartContent[4])))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected override PartialParseResultInternal CanAcceptChange(SyntaxNode target,

// Get the edit context
char? lastChar = null;
if (changeRelativePosition > 0 && target.FullWidth > 0)
if (changeRelativePosition > 0 && target.Width > 0)
{
lastChar = target.GetContent()[changeRelativePosition - 1];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static MarkupTagHelperStartTagSyntax Rewrite(
// TODO: Accept more than just Markup attributes: https://github.com/aspnet/Razor/issues/96.
// Something like:
// <input @checked />
var location = new SourceSpan(codeBlock.GetSourceLocation(source), codeBlock.FullWidth);
var location = new SourceSpan(codeBlock.GetSourceLocation(source), codeBlock.Width);
var diagnostic = RazorDiagnosticFactory.CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(location, tagName);
errorSink.OnError(diagnostic);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ private void ValidateBinding(
{
_errorSink.OnError(
RazorDiagnosticFactory.CreateTagHelper_InconsistentTagStructure(
new SourceSpan(tagBlock.GetSourceLocation(_source), tagBlock.FullWidth),
new SourceSpan(tagBlock.GetSourceLocation(_source), tagBlock.Width),
baseDescriptor!.DisplayName,
descriptor.DisplayName,
tagName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal string GetOriginalText(SyntaxNode node)
throw new ArgumentNullException(nameof(node));
}

if (node.FullWidth == 0)
if (node.Width == 0)
{
return string.Empty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ internal static SyntaxNode ItemInternal(SyntaxNode node, int index)
}

idx -= currentOccupancy;
position += greenChild.FullWidth;
position += greenChild.Width;
}

slotIndex++;
Expand Down Expand Up @@ -158,7 +158,7 @@ internal static SyntaxNode ItemInternal(SyntaxNode node, int index)
internal static SyntaxNode ChildThatContainsPosition(SyntaxNode node, int targetPosition, out int index)
{
// The targetPosition must already be within this node
Debug.Assert(node.FullSpan.Contains(targetPosition));
Debug.Assert(node.Span.Contains(targetPosition));

var green = node.Green;
var position = node.Position;
Expand All @@ -174,7 +174,7 @@ internal static SyntaxNode ChildThatContainsPosition(SyntaxNode node, int target
var greenChild = green.GetSlot(slot);
if (greenChild != null)
{
var endPosition = position + greenChild.FullWidth;
var endPosition = position + greenChild.Width;
if (targetPosition < endPosition)
{
// Descend into the child element
Expand Down
Loading