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

Add grammar support for new directives: rendermode, preservewhitespace and typeparam #6887

Merged
merged 4 commits into from Feb 15, 2024

Conversation

jordi1215
Copy link
Member

@jordi1215 jordi1215 commented Feb 14, 2024

This pull request fixes dotnet/razor#9882 in the razor repository. It updates the TextMate grammar to include code coloring for three new Razor directives: rendermode, preservewhitespace, and typeparam. You can find more information about these directives in the razor documentation.

Changes Summary

tmLanguage.yml

This file defines the TextMate grammar. I added support for the three new Razor directives, following the same format as the existing directives.

tmLanguage.json

This file is automatically generated to reflect the changes in tmLanguage.yml. You can update it by running the razorTests or the npm run compile:razorTextMate command.

razorTests

I added three new entries in grammarTests.test.ts and created three new test files for the new directives. These tests follow the same format as the existing tests for other Razor directives.

Visualization

Before

before_vs_code

After

after_vs_code_2

- added grammar support for rendermode, preservewhitespace and typeparam in tmLanguage.yml
- populated the corresponding json file with the npm run compile:razorTextMate command
- added the corresponding tests in Microsoft.AspNetCore.Razor.VSCode.Grammar.Test
- added the snapshot for the three new added grammar tests: rendermode, preservewhitespace and typeparam. The snapshot is verified to be correct with all the token correctly identified. In the future, subsequent tests will be tested against these created snapshots.
@jordi1215 jordi1215 requested review from a team as code owners February 14, 2024 00:16
Copy link
Contributor

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

addresses an dotnet/razor#9882 in the razor repository

GitHub Pro-tip, if you include the word "fixes" or "closes" immediately before an issue number, then GitHub will automatically close the issue when the PR merges.

- since only "true" or "false" are expected after "preservewhitespace", the grammar should color the boolean-literal accordingly
added a few more tests for completeness
@jordi1215 jordi1215 merged commit 682c432 into main Feb 15, 2024
13 checks passed
@jordi1215 jordi1215 deleted the dev/jordi1215/add-grammar-for-new-directives branch February 15, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blazor @rendermode directive colouring
2 participants