Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CSharpKeywordKind #10648

Merged
merged 4 commits into from
Jul 23, 2024
Merged

Remove CSharpKeywordKind #10648

merged 4 commits into from
Jul 23, 2024

Conversation

333fred
Copy link
Member

@333fred 333fred commented Jul 18, 2024

This type effectively duplicates a lot of Roslyn's SyntaxKind. So we just use that instead.

This type effectively duplicates a lot of Roslyn's SyntaxKind. So we just use that instead.
@333fred 333fred marked this pull request as ready for review July 18, 2024 22:59
@333fred 333fred requested a review from a team as a code owner July 18, 2024 22:59
@333fred
Copy link
Member Author

333fred commented Jul 18, 2024

@dotnet/razor-compiler for review. This is an easily-extractable part of the lexer change, so I went ahead and pulled it out.

{ "namespace", CSharpKeyword.Namespace },
{ "when", CSharpKeyword.When },
{ "where", CSharpKeyword.Where }
private static readonly Dictionary<string, CSharpSyntaxKind> _keywords = new Dictionary<string, CSharpSyntaxKind>(StringComparer.Ordinal)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making this a FrozenDictionary in the future.

@@ -2008,14 +2011,13 @@ private bool TryParseKeyword(in SyntaxListBuilder<RazorSyntaxNode> builder)

private bool AtBooleanLiteral()
{
var result = CSharpTokenizer.GetTokenKeyword(CurrentToken);
return result.HasValue && (result.Value == CSharpKeyword.True || result.Value == CSharpKeyword.False);
return LegacyCSharpTokenizer.GetTokenKeyword(CurrentToken) is CSharpSyntaxKind.TrueKeyword or CSharpSyntaxKind.FalseKeyword;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is LegacyCSharpTokenizer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's sign I missed one thing when fixing up the cherry-pick

{ "checked", CSharpSyntaxKind.CheckedKeyword },
{ "namespace", CSharpSyntaxKind.NamespaceKeyword },
{ "when", CSharpSyntaxKind.WhenKeyword },
{ "where", CSharpSyntaxKind.WhereKeyword }
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test or assert that checks those match (stringifying the enum value gives back a string equal to the key)

@DustinCampbell
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@jjonescz jjonescz added the area-compiler Umbrella for all compiler issues label Jul 23, 2024
@333fred 333fred merged commit 57e73c9 into dotnet:main Jul 23, 2024
12 checks passed
@333fred 333fred deleted the remove-csharptokenkind branch July 23, 2024 20:01
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 23, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 Preview 1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-compiler Umbrella for all compiler issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants