From b7b429dfeefdd17c3b0dfc2a5dff2a80fc2f3744 Mon Sep 17 00:00:00 2001 From: Jordi Ramos Date: Tue, 13 Feb 2024 13:36:04 -0800 Subject: [PATCH 1/4] added grammar support for new directives - 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 --- .../syntaxes/aspnetcorerazor.tmLanguage.json | 78 +++++++++++++++++++ .../syntaxes/aspnetcorerazor.tmLanguage.yml | 35 ++++++++- .../tests/grammarTests.test.ts | 6 ++ .../tests/preservewhitespaceDirective.ts | 33 ++++++++ .../tests/rendermodeDirective.ts | 33 ++++++++ .../tests/typeparamDirective.ts | 33 ++++++++ 6 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/preservewhitespaceDirective.ts create mode 100644 test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/rendermodeDirective.ts create mode 100644 test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/typeparamDirective.ts diff --git a/src/razor/syntaxes/aspnetcorerazor.tmLanguage.json b/src/razor/syntaxes/aspnetcorerazor.tmLanguage.json index 8f6454c36..05e33e652 100644 --- a/src/razor/syntaxes/aspnetcorerazor.tmLanguage.json +++ b/src/razor/syntaxes/aspnetcorerazor.tmLanguage.json @@ -525,6 +525,15 @@ }, { "include": "#using-directive" + }, + { + "include": "#rendermode-directive" + }, + { + "include": "#preservewhitespace-directive" + }, + { + "include": "#typeparam-directive" } ] }, @@ -849,6 +858,75 @@ } } }, + "rendermode-directive": { + "name": "meta.directive", + "match": "(@)(rendermode)\\s+([^$]+)?", + "captures": { + "1": { + "patterns": [ + { + "include": "#transition" + } + ] + }, + "2": { + "name": "keyword.control.razor.directive.rendermode" + }, + "3": { + "patterns": [ + { + "include": "source.cs#type" + } + ] + } + } + }, + "preservewhitespace-directive": { + "name": "meta.directive", + "match": "(@)(preservewhitespace)\\s+([^$]+)?", + "captures": { + "1": { + "patterns": [ + { + "include": "#transition" + } + ] + }, + "2": { + "name": "keyword.control.razor.directive.preservewhitespace" + }, + "3": { + "patterns": [ + { + "include": "source.cs#type" + } + ] + } + } + }, + "typeparam-directive": { + "name": "meta.directive", + "match": "(@)(typeparam)\\s+([^$]+)?", + "captures": { + "1": { + "patterns": [ + { + "include": "#transition" + } + ] + }, + "2": { + "name": "keyword.control.razor.directive.typeparam" + }, + "3": { + "patterns": [ + { + "include": "source.cs#type" + } + ] + } + } + }, "attribute-directive": { "name": "meta.directive", "begin": "(@)(attribute)\\b\\s+", diff --git a/src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml b/src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml index 46b2accdb..3b935f8c3 100644 --- a/src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml +++ b/src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml @@ -281,6 +281,9 @@ repository: - include: '#section-directive' - include: '#layout-directive' - include: '#using-directive' + - include: '#rendermode-directive' + - include: '#preservewhitespace-directive' + - include: '#typeparam-directive' #>>>>> @code and @functions <<<<< @@ -420,6 +423,36 @@ repository: 3: { patterns: [ include: 'source.cs#type' ] } 4: { name: 'entity.name.variable.property.cs' } + #>>>>> @rendermode <<<<< + + rendermode-directive: + name: 'meta.directive' + match: '(@)(rendermode)\s+([^$]+)?' + captures: + 1: { patterns: [ include: '#transition' ] } + 2: { name: 'keyword.control.razor.directive.rendermode'} + 3: { patterns: [ include: 'source.cs#type' ] } + + #>>>>> @preservewhitespace <<<<< + + preservewhitespace-directive: + name: 'meta.directive' + match: '(@)(preservewhitespace)\s+([^$]+)?' + captures: + 1: { patterns: [ include: '#transition' ] } + 2: { name: 'keyword.control.razor.directive.preservewhitespace'} + 3: { patterns: [ include: 'source.cs#type' ] } + + #>>>>> @typeparam <<<<< + + typeparam-directive: + name: 'meta.directive' + match: '(@)(typeparam)\s+([^$]+)?' + captures: + 1: { patterns: [ include: '#transition' ] } + 2: { name: 'keyword.control.razor.directive.typeparam'} + 3: { patterns: [ include: 'source.cs#type' ] } + #>>>>> @attribute <<<<< attribute-directive: @@ -925,4 +958,4 @@ repository: - include: 'source.cs#punctuation-semicolon' end: '(\))' endCaptures: - 1: { name: 'punctuation.parenthesis.close.cs' } \ No newline at end of file + 1: { name: 'punctuation.parenthesis.close.cs' } diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/grammarTests.test.ts b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/grammarTests.test.ts index b601b8fdd..096ebb68e 100644 --- a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/grammarTests.test.ts +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/grammarTests.test.ts @@ -39,6 +39,9 @@ import { RunTryStatementSuite } from './tryStatement'; import { RunUsingDirectiveSuite } from './usingDirective'; import { RunUsingStatementSuite } from './usingStatement'; import { RunWhileStatementSuite } from './whileStatement'; +import { RunRendermodeDirectiveSuite } from './rendermodeDirective'; +import { RunPreservewhitespaceDirectiveSuite } from './preservewhitespaceDirective'; +import { RunTypeparamDirectiveSuite } from './typeparamDirective'; // We bring together all test suites and wrap them in one here. The reason behind this is that // modules get reloaded per test suite and the vscode-textmate library doesn't support the way @@ -71,6 +74,9 @@ describe('Grammar tests', () => { RunSectionDirectiveSuite(); RunLayoutDirectiveSuite(); RunUsingDirectiveSuite(); + RunRendermodeDirectiveSuite(); + RunPreservewhitespaceDirectiveSuite(); + RunTypeparamDirectiveSuite(); // Razor C# Control Structures RunUsingStatementSuite(); diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/preservewhitespaceDirective.ts b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/preservewhitespaceDirective.ts new file mode 100644 index 000000000..1bf790f25 --- /dev/null +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/preservewhitespaceDirective.ts @@ -0,0 +1,33 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { describe, it } from '@jest/globals'; +import { assertMatchesSnapshot } from './infrastructure/testUtilities'; + +// See GrammarTests.test.ts for details on exporting this test suite instead of running in place. + +export function RunPreservewhitespaceDirectiveSuite() { + describe('@preservewhitespace directive', () => { + it('No bool', async () => { + await assertMatchesSnapshot('@preservewhitespace'); + }); + + it('No bool spaced', async () => { + await assertMatchesSnapshot('@preservewhitespace '); + }); + + it('Incomplete bool', async () => { + await assertMatchesSnapshot('@preservewhitespace fal'); + }); + + it('Bool provided', async () => { + await assertMatchesSnapshot('@preservewhitespace true'); + }); + + it('Bool provided spaced', async () => { + await assertMatchesSnapshot('@preservewhitespace false '); + }); + }); +} diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/rendermodeDirective.ts b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/rendermodeDirective.ts new file mode 100644 index 000000000..1bdfe118b --- /dev/null +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/rendermodeDirective.ts @@ -0,0 +1,33 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { describe, it } from '@jest/globals'; +import { assertMatchesSnapshot } from './infrastructure/testUtilities'; + +// See GrammarTests.test.ts for details on exporting this test suite instead of running in place. + +export function RunRendermodeDirectiveSuite() { + describe('@rendermode directive', () => { + it('No mode', async () => { + await assertMatchesSnapshot('@rendermode'); + }); + + it('No mode spaced', async () => { + await assertMatchesSnapshot('@rendermode '); + }); + + it('Incomplete mode, generic', async () => { + await assertMatchesSnapshot('@rendermode InteractiveWebAssemb'); + }); + + it('Mode provided', async () => { + await assertMatchesSnapshot('@rendermode InteractiveServer'); + }); + + it('Mode provided spaced', async () => { + await assertMatchesSnapshot('@rendermode InteractiveAuto '); + }); + }); +} diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/typeparamDirective.ts b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/typeparamDirective.ts new file mode 100644 index 000000000..e4c94dda6 --- /dev/null +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/typeparamDirective.ts @@ -0,0 +1,33 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { describe, it } from '@jest/globals'; +import { assertMatchesSnapshot } from './infrastructure/testUtilities'; + +// See GrammarTests.test.ts for details on exporting this test suite instead of running in place. + +export function RunTypeparamDirectiveSuite() { + describe('@typeparam directive', () => { + it('No type', async () => { + await assertMatchesSnapshot('@typeparam'); + }); + + it('No type spaced', async () => { + await assertMatchesSnapshot('@typeparam '); + }); + + it('Incomplete type, generic', async () => { + await assertMatchesSnapshot('@typeparam SomeViewBase { + await assertMatchesSnapshot('@typeparam Person'); + }); + + it('Type provided spaced', async () => { + await assertMatchesSnapshot('@typeparam Person '); + }); + }); +} From 0c645dfb5d6ac74606a8ba80bc277fb86993c750 Mon Sep 17 00:00:00 2001 From: Jordi Ramos Date: Tue, 13 Feb 2024 15:25:12 -0800 Subject: [PATCH 2/4] Update grammarTests.test.ts.snap - 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. --- .../__snapshots__/grammarTests.test.ts.snap | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap index 88b77e4ce..f378decda 100644 --- a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap @@ -2820,6 +2820,49 @@ exports[`Grammar tests @page directive Routed spaced 1`] = ` " `; +exports[`Grammar tests @preservewhitespace directive Bool provided 1`] = ` +"Line: @preservewhitespace true + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace + - token from 19 to 20 ( ) with scopes text.aspnetcorerazor, meta.directive + - token from 20 to 24 (true) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs +" +`; + +exports[`Grammar tests @preservewhitespace directive Bool provided spaced 1`] = ` +"Line: @preservewhitespace false + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace + - token from 19 to 33 ( ) with scopes text.aspnetcorerazor, meta.directive + - token from 33 to 38 (false) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs + - token from 38 to 48 ( ) with scopes text.aspnetcorerazor, meta.directive +" +`; + +exports[`Grammar tests @preservewhitespace directive Incomplete bool 1`] = ` +"Line: @preservewhitespace fal + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace + - token from 19 to 20 ( ) with scopes text.aspnetcorerazor, meta.directive + - token from 20 to 23 (fal) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs +" +`; + +exports[`Grammar tests @preservewhitespace directive No bool 1`] = ` +"Line: @preservewhitespace + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace +" +`; + +exports[`Grammar tests @preservewhitespace directive No bool spaced 1`] = ` +"Line: @preservewhitespace + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace + - token from 19 to 34 ( ) with scopes text.aspnetcorerazor, meta.directive +" +`; + exports[`Grammar tests @removeTagHelper directive Incomplete parameter 1`] = ` "Line: @removeTagHelper " - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition @@ -2876,6 +2919,49 @@ exports[`Grammar tests @removeTagHelper directive Unquoted parameter 1`] = ` " `; +exports[`Grammar tests @rendermode directive Incomplete mode, generic 1`] = ` +"Line: @rendermode InteractiveWebAssemb + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 11 (rendermode) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.rendermode + - token from 11 to 12 ( ) with scopes text.aspnetcorerazor, meta.directive + - token from 12 to 32 (InteractiveWebAssemb) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs +" +`; + +exports[`Grammar tests @rendermode directive Mode provided 1`] = ` +"Line: @rendermode InteractiveServer + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 11 (rendermode) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.rendermode + - token from 11 to 12 ( ) with scopes text.aspnetcorerazor, meta.directive + - token from 12 to 29 (InteractiveServer) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs +" +`; + +exports[`Grammar tests @rendermode directive Mode provided spaced 1`] = ` +"Line: @rendermode InteractiveAuto + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 11 (rendermode) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.rendermode + - token from 11 to 25 ( ) with scopes text.aspnetcorerazor, meta.directive + - token from 25 to 40 (InteractiveAuto) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs + - token from 40 to 50 ( ) with scopes text.aspnetcorerazor, meta.directive +" +`; + +exports[`Grammar tests @rendermode directive No mode 1`] = ` +"Line: @rendermode + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 11 (rendermode) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.rendermode +" +`; + +exports[`Grammar tests @rendermode directive No mode spaced 1`] = ` +"Line: @rendermode + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 11 (rendermode) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.rendermode + - token from 11 to 26 ( ) with scopes text.aspnetcorerazor, meta.directive +" +`; + exports[`Grammar tests @section directive As C# local 1`] = ` "Line: @section.method() - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.expression.implicit.cshtml, keyword.control.cshtml.transition @@ -3661,6 +3747,51 @@ exports[`Grammar tests @try { ... } catch/finally { ... } Single line 1`] = ` " `; +exports[`Grammar tests @typeparam directive Incomplete type, generic 1`] = ` +"Line: @typeparam SomeViewBase Date: Wed, 14 Feb 2024 16:11:22 -0800 Subject: [PATCH 3/4] classifying boolean after preservewhitespace directives - since only "true" or "false" are expected after "preservewhitespace", the grammar should color the boolean-literal accordingly --- src/razor/syntaxes/aspnetcorerazor.tmLanguage.json | 2 +- src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml | 2 +- .../tests/__snapshots__/grammarTests.test.ts.snap | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/razor/syntaxes/aspnetcorerazor.tmLanguage.json b/src/razor/syntaxes/aspnetcorerazor.tmLanguage.json index 05e33e652..b82283682 100644 --- a/src/razor/syntaxes/aspnetcorerazor.tmLanguage.json +++ b/src/razor/syntaxes/aspnetcorerazor.tmLanguage.json @@ -898,7 +898,7 @@ "3": { "patterns": [ { - "include": "source.cs#type" + "include": "source.cs#boolean-literal" } ] } diff --git a/src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml b/src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml index 3b935f8c3..66867921f 100644 --- a/src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml +++ b/src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml @@ -441,7 +441,7 @@ repository: captures: 1: { patterns: [ include: '#transition' ] } 2: { name: 'keyword.control.razor.directive.preservewhitespace'} - 3: { patterns: [ include: 'source.cs#type' ] } + 3: { patterns: [ include: 'source.cs#boolean-literal' ] } #>>>>> @typeparam <<<<< diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap index f378decda..aee8dfbb4 100644 --- a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap @@ -2825,7 +2825,7 @@ exports[`Grammar tests @preservewhitespace directive Bool provided 1`] = ` - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace - token from 19 to 20 ( ) with scopes text.aspnetcorerazor, meta.directive - - token from 20 to 24 (true) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs + - token from 20 to 24 (true) with scopes text.aspnetcorerazor, meta.directive, constant.language.boolean.true.cs " `; @@ -2834,7 +2834,7 @@ exports[`Grammar tests @preservewhitespace directive Bool provided spaced 1`] = - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace - token from 19 to 33 ( ) with scopes text.aspnetcorerazor, meta.directive - - token from 33 to 38 (false) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs + - token from 33 to 38 (false) with scopes text.aspnetcorerazor, meta.directive, constant.language.boolean.false.cs - token from 38 to 48 ( ) with scopes text.aspnetcorerazor, meta.directive " `; @@ -2844,7 +2844,7 @@ exports[`Grammar tests @preservewhitespace directive Incomplete bool 1`] = ` - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace - token from 19 to 20 ( ) with scopes text.aspnetcorerazor, meta.directive - - token from 20 to 23 (fal) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs + - token from 20 to 24 (fal) with scopes text.aspnetcorerazor, meta.directive " `; From 52beb2e3969db405a976130209237ab852d2b14c Mon Sep 17 00:00:00 2001 From: Jordi Ramos Date: Wed, 14 Feb 2024 16:21:32 -0800 Subject: [PATCH 4/4] updated directives tests added a few more tests for completeness --- .../__snapshots__/grammarTests.test.ts.snap | 25 +++++++++++++++++-- .../tests/preservewhitespaceDirective.ts | 6 ++++- .../tests/rendermodeDirective.ts | 2 +- .../tests/typeparamDirective.ts | 4 +++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap index aee8dfbb4..901635556 100644 --- a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/grammarTests.test.ts.snap @@ -2820,7 +2820,16 @@ exports[`Grammar tests @page directive Routed spaced 1`] = ` " `; -exports[`Grammar tests @preservewhitespace directive Bool provided 1`] = ` +exports[`Grammar tests @preservewhitespace directive Bool provided (false) 1`] = ` +"Line: @preservewhitespace false + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace + - token from 19 to 20 ( ) with scopes text.aspnetcorerazor, meta.directive + - token from 20 to 25 (false) with scopes text.aspnetcorerazor, meta.directive, constant.language.boolean.false.cs +" +`; + +exports[`Grammar tests @preservewhitespace directive Bool provided (true) 1`] = ` "Line: @preservewhitespace true - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition - token from 1 to 19 (preservewhitespace) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.preservewhitespace @@ -2919,7 +2928,7 @@ exports[`Grammar tests @removeTagHelper directive Unquoted parameter 1`] = ` " `; -exports[`Grammar tests @rendermode directive Incomplete mode, generic 1`] = ` +exports[`Grammar tests @rendermode directive Incomplete mode 1`] = ` "Line: @rendermode InteractiveWebAssemb - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition - token from 1 to 11 (rendermode) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.rendermode @@ -3747,6 +3756,18 @@ exports[`Grammar tests @try { ... } catch/finally { ... } Single line 1`] = ` " `; +exports[`Grammar tests @typeparam directive Complete type, generic 1`] = ` +"Line: @typeparam SomeViewBase + - token from 0 to 1 (@) with scopes text.aspnetcorerazor, meta.directive, keyword.control.cshtml.transition + - token from 1 to 10 (typeparam) with scopes text.aspnetcorerazor, meta.directive, keyword.control.razor.directive.typeparam + - token from 10 to 11 ( ) with scopes text.aspnetcorerazor, meta.directive + - token from 11 to 23 (SomeViewBase) with scopes text.aspnetcorerazor, meta.directive, entity.name.type.cs + - token from 23 to 24 (<) with scopes text.aspnetcorerazor, meta.directive, punctuation.definition.typeparameters.begin.cs + - token from 24 to 30 (string) with scopes text.aspnetcorerazor, meta.directive, keyword.type.cs + - token from 30 to 31 (>) with scopes text.aspnetcorerazor, meta.directive, punctuation.definition.typeparameters.end.cs +" +`; + exports[`Grammar tests @typeparam directive Incomplete type, generic 1`] = ` "Line: @typeparam SomeViewBase { + it('Bool provided (true)', async () => { await assertMatchesSnapshot('@preservewhitespace true'); }); + it('Bool provided (false)', async () => { + await assertMatchesSnapshot('@preservewhitespace false'); + }); + it('Bool provided spaced', async () => { await assertMatchesSnapshot('@preservewhitespace false '); }); diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/rendermodeDirective.ts b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/rendermodeDirective.ts index 1bdfe118b..9da60b4e5 100644 --- a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/rendermodeDirective.ts +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/rendermodeDirective.ts @@ -18,7 +18,7 @@ export function RunRendermodeDirectiveSuite() { await assertMatchesSnapshot('@rendermode '); }); - it('Incomplete mode, generic', async () => { + it('Incomplete mode', async () => { await assertMatchesSnapshot('@rendermode InteractiveWebAssemb'); }); diff --git a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/typeparamDirective.ts b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/typeparamDirective.ts index e4c94dda6..893020549 100644 --- a/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/typeparamDirective.ts +++ b/test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/typeparamDirective.ts @@ -22,6 +22,10 @@ export function RunTypeparamDirectiveSuite() { await assertMatchesSnapshot('@typeparam SomeViewBase { + await assertMatchesSnapshot('@typeparam SomeViewBase'); + }); + it('Type provided', async () => { await assertMatchesSnapshot('@typeparam Person'); });