diff --git a/extensions/razor/package.json b/extensions/razor/package.json index 1f50b33eeaf..f2b69806fde 100644 --- a/extensions/razor/package.json +++ b/extensions/razor/package.json @@ -6,7 +6,7 @@ "vscode": "0.10.x" }, "scripts": { - "update-grammar": "node ../../build/npm/update-grammar.js demyte/language-cshtml grammars/cshtml.cson ./syntaxes/cshtml.json" + "update-grammar": "node ../../build/npm/update-grammar.js demyte/language-cshtml grammars/cshtml.json ./syntaxes/cshtml.json" }, "contributes": { "languages": [{ diff --git a/extensions/razor/syntaxes/cshtml.json b/extensions/razor/syntaxes/cshtml.json index 180ad0e68dd..241e4486800 100644 --- a/extensions/razor/syntaxes/cshtml.json +++ b/extensions/razor/syntaxes/cshtml.json @@ -1,9 +1,10 @@ { "information_for_contributors": [ - "This file has been converted from https://github.com/demyte/language-cshtml/blob/master/grammars/cshtml.cson", + "This file has been converted from https://github.com/demyte/language-cshtml/blob/master/grammars/cshtml.json", "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], + "version": "https://github.com/demyte/language-cshtml/commit/cbf0e35971324e861247145e92f4cbbe0bc42d0e", "name": "ASP.NET Razor", "scopeName": "text.html.cshtml", "fileTypes": [ @@ -35,21 +36,14 @@ } }, "patterns": [ - { - "name": "string.quoted.single.cshtml", - "match": "'" - }, { "include": "#embedded-code" }, { - "include": "#comments" + "include": "#general-includes" }, { "include": "source.cs" - }, - { - "include": "text.html.basic" } ], "end": "\\}", @@ -59,18 +53,14 @@ } } }, - { - "name": "string.quoted.single.cshtml", - "match": "'" - }, { "include": "#embedded-code" }, { - "include": "#comments" + "include": "#general-includes" }, { - "include": "text.html.basic" + "include": "source.cs" } ], "end": "\\}", @@ -107,17 +97,32 @@ "include": "#embedded-code" }, { - "include": "#comments" - }, - { - "include": "source.cs" - }, - { - "include": "text.html.basic" + "include": "#general-includes" } ], "end": "(\\n|\\s)", - "comments": "Covers single line Razor tags" + "comments": "Single statement Razor tags" + }, + { + "begin": "(@\\()", + "captures": { + "0": { + "name": "punctuation.section.embedded.begin.cshtml" + } + }, + "patterns": [ + { + "include": "#embedded-code" + }, + { + "include": "#general-includes" + }, + { + "include": "source.cs" + } + ], + "end": "(\\))", + "comments": "Covers same line Razor statments with embedded C#" }, { "include": "#comments" @@ -139,7 +144,7 @@ }, "patterns": [ { - "include": "#comments" + "include": "#general-includes" } ] }, @@ -152,6 +157,69 @@ }, "end": "\\*@", "name": "comment.block.cshtml" + }, + "line-comments": { + "name": "comment.line.double-slash.cshtml", + "begin": "(\\s*)//", + "end": "$(\\s*)" + }, + "block-comments": { + "name": "comment.block.cshtml", + "begin": "/\\*", + "end": "((?=})|(\\*/))" + }, + "single-quotes": { + "name": "string.quoted.single.cshtml", + "begin": "'", + "end": "'" + }, + "double-quotes": { + "name": "string.quoted.double.cshtml", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "include": "text.html.basic" + } + ] + }, + "round-brackets": { + "name": "string.bracers.round.cshtml", + "begin": "\\(", + "end": "\\)" + }, + "squiggly-brackets": { + "name": "string.bracers.squiggly.cshtml", + "begin": "{", + "end": "}" + }, + "general-includes": { + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#line-comments" + }, + { + "include": "#block-comments" + }, + { + "include": "#round-brackets" + }, + { + "include": "#squiggly-brackets" + }, + { + "include": "#single-quotes" + }, + { + "include": "#double-quotes" + }, + { + "include": "text.html.basic" + } + ] } } } \ No newline at end of file