diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1905112 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +/.git* export-ignore +tests/ export-ignore +README.md export-ignore diff --git a/.github/workflows/syntax.yml b/.github/workflows/syntax.yml index 46cd432..2fdf6fc 100644 --- a/.github/workflows/syntax.yml +++ b/.github/workflows/syntax.yml @@ -1,4 +1,5 @@ name: Syntax Tests +# https://github.com/sublimetext/syntax-test-action on: push: @@ -17,17 +18,20 @@ on: jobs: main: name: Syntax Tests (${{ matrix.build }}) + runs-on: ubuntu-latest + timeout-minutes: 15 strategy: matrix: include: - - build: 3211 - packages: st3 - - build: 4073 + - build: latest packages: master - runs-on: ubuntu-latest + - build: stable + packages: master + - build: 4134 # Need HTML with `html` context for inclusion + packages: binary steps: - - uses: actions/checkout@v2 - - uses: SublimeText/syntax-test-action@v1 + - uses: actions/checkout@v4 + - uses: SublimeText/syntax-test-action@v2 with: build: ${{ matrix.build }} default_packages: ${{ matrix.packages }} diff --git a/messages/3.0.0.md b/.messages/3.0.0.md similarity index 100% rename from messages/3.0.0.md rename to .messages/3.0.0.md diff --git a/messages/4.0.0.md b/.messages/4.0.0.md similarity index 100% rename from messages/4.0.0.md rename to .messages/4.0.0.md diff --git a/README.md b/README.md index 8cbf99b..9570aca 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,19 @@ [Sublime Text][st] [syntax highlighting][ss-docs] for `.cshtml`, `.aspx`, and similar files. -## Current support +## WebForms -### Highlighting +The old ASP.Net style pages that necessitated creation of this package. Post-Visual Basic ASP, but pre-Razor. + +### Current support + +#### Highlighting - Embedded C# (` - ``` [pkg]: https://packagecontrol.io/packages/HTML%20(C%23) [st]: https://www.sublimetext.com/ diff --git a/Razor/C# (Razor).sublime-syntax b/Razor/C# (Razor).sublime-syntax new file mode 100644 index 0000000..a09ba7c --- /dev/null +++ b/Razor/C# (Razor).sublime-syntax @@ -0,0 +1,46 @@ +%YAML 1.2 +--- +scope: source.cs.embedded.html +hidden: true +# version: 2 + +extends: Packages/C#/C#.sublime-syntax + +############################################################################## + +contexts: + # code_block_in: + # - meta_prepend: true + # - match: (%>)(\s*\n)? + # scope: meta.embedded.cs + # captures: + # 1: punctuation.section.embedded.end.cs-razor + # 2: meta.html-newline-after-csharp.cs-razor # used by indentation rules + # push: embedding-syntax + + embedding-syntax: + - clear_scopes: true + - meta_scope: embedding.cs text.html.cs.razor + - meta_include_prototype: false + - match: <%(?![=#:$@-]) + scope: meta.embedded.cs punctuation.section.embedded.begin.cs-razor + pop: 1 + - include: Packages/HTML (C#)/Razor/Razor.sublime-syntax#comments + - include: Packages/HTML (C#)/Razor/Razor.sublime-syntax#html + + stray-braces: + - match: (\})(\s*\n)? + scope: meta.embedded.cs + captures: + 1: punctuation.section.embedded.end.cs-razor + 2: meta.html-newline-after-csharp.cs-razor # used by indentation rules + # - match: \} + # scope: invalid.illegal.stray.cs + + stray-brackets: + - match: \] + scope: invalid.illegal.stray.cs + + stray-parens: + - match: \) + scope: invalid.illegal.stray.cs diff --git a/Razor/CSS (Razor).sublime-syntax b/Razor/CSS (Razor).sublime-syntax new file mode 100644 index 0000000..74535d9 --- /dev/null +++ b/Razor/CSS (Razor).sublime-syntax @@ -0,0 +1,44 @@ +%YAML 1.2 +--- +name: CSS (WebForms) +scope: source.css.cs.razor +version: 2 + +extends: Packages/CSS/CSS.sublime-syntax +hidden: true + +contexts: + + prototype: + - meta_prepend: true + - include: Razor.sublime-syntax#comments + - include: csharp-embedded + + string-content: + - meta_prepend: true + - include: Razor.sublime-syntax#csharp-interpolations + + csharp-interpolations: + - meta_include_prototype: false + # - match: (?=@) + # push: csharp-interpolation-body + - include: Razor.sublime-syntax#csharp-interpolations + + csharp-interpolation-body: + - clear_scopes: 1 + - meta_include_prototype: false + - include: csharp-embedded + - include: immediately-pop + + csharp-embedded: + - meta_include_prototype: false + - include: Razor.sublime-syntax#razor-constructs + # - match: <%[=#:$] + # scope: meta.embedded.cs punctuation.section.embedded.begin.cs-webforms + # embed: Packages/C#/C#.sublime-syntax + # embed_scope: meta.embedded.cs source.cs.embedded.css + # escape: (%>)(\s*\n)? + # escape_captures: + # 0: meta.embedded.cs + # 1: punctuation.section.embedded.end.cs-webforms + # 2: meta.html-newline-after-csharp.cs-webforms diff --git a/Razor/JavaScript (Razor).sublime-syntax b/Razor/JavaScript (Razor).sublime-syntax new file mode 100644 index 0000000..1481341 --- /dev/null +++ b/Razor/JavaScript (Razor).sublime-syntax @@ -0,0 +1,43 @@ +%YAML 1.2 +--- +name: JavaScript (Razor) +scope: source.js.cs.razor +version: 2 +hidden: true + +extends: Packages/JavaScript/JavaScript.sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - include: Razor.sublime-syntax#comments + # - include: csharp-embedded + + string-content: + - meta_prepend: true + - include: Razor.sublime-syntax#csharp-interpolations + + csharp-interpolations: + - meta_include_prototype: false + - match: (?=<%[=#:$]) + push: csharp-interpolation-body + + csharp-interpolation-body: + - clear_scopes: 1 + - meta_include_prototype: false + - include: csharp-embedded + - include: immediately-pop + + csharp-embedded: + - meta_include_prototype: false + - include: Razor.sublime-syntax#razor-constructs + # - match: <%[=#:$] + # scope: meta.embedded.cs punctuation.section.embedded.begin.cs-webforms + # embed: Packages/C#/C#.sublime-syntax + # embed_scope: meta.embedded.cs source.cs.embedded.css + # escape: (%>)(\s*\n)? + # escape_captures: + # 0: meta.embedded.cs + # 1: punctuation.section.embedded.end.cs-webforms + # 2: meta.html-newline-after-csharp.cs-webforms diff --git a/Razor/Razor.sublime-syntax b/Razor/Razor.sublime-syntax new file mode 100644 index 0000000..e28c255 --- /dev/null +++ b/Razor/Razor.sublime-syntax @@ -0,0 +1,334 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/syntax.html +name: HTML (C# Razor) +scope: text.html.cs.razor +version: 2 + +extends: Packages/HTML/HTML.sublime-syntax + +file_extensions: + - cshtml + +variables: + csharp_tag: '@{' + csharp_tag_end: '}' + csharp_tag_interpolation_paren: '@\(' + csharp_tag_interpolation_bare: '@(?=\w)' + +contexts: + prototype: + - meta_prepend: true + - include: comments + - include: csharp-embedded + + main: + - meta_include_prototype: false + - match: '' + push: [razor, directives] + + razor: + # This is the main Razor context. + # It includes `csharp-tags` which are allowed to be closed by } tags at any + # level of code-block on stack resuming with the next top-level @{ tag. + - meta_include_prototype: false + - include: csharp-tags + - include: html + + comments: + - match: '@\*' + scope: punctuation.definition.comment.block.begin.cs-razor + push: + - meta_scope: comment.block.cs-razor + - match: '\*@' + scope: punctuation.definition.comment.block.end.cs-razor + pop: 1 + +###[ DIRECTIVES ]################################################################ + + directives: + - meta_include_prototype: false + - include: comments + - include: directive + - include: Packages/HTML/HTML (Plain).sublime-syntax#comment + - match: (?=\S) + pop: 1 + + directive: + - match: (@)(model)\b + captures: + 1: punctuation.section.embedded.line.cs-razor + 2: source.cs.embedded.html keyword.other.cs-razor + embed: scope:source.cs#type + embed_scope: source.cs.embedded.html + escape: $ + - match: (@)(using)\b(?!\s*\() + captures: + 1: punctuation.section.embedded.line.cs-razor + 2: source.cs.embedded.html keyword.other.cs-razor + embed: scope:source.cs#line_of_code_in + embed_scope: source.cs.embedded.html + escape: $ + +###[ RAZOR CONSTRUCTS ]####################################################### + + razor-constructs: + - match: (@)(section)\b(?:\s+(\w+))? + captures: + 1: punctuation.section.embedded.line.cs-razor + 2: source.cs.embedded.html keyword.other.cs-razor + 3: entity.name.section.cs-razor + push: + - match: \{ + scope: punctuation.section.block.begin.cs-razor + set: + - match: \} + scope: punctuation.section.block.end.cs-razor + pop: true + - include: razor + - match: (@)(functions)\b + captures: + 1: punctuation.section.embedded.line.cs-razor + 2: source.cs.embedded.html keyword.other.cs-razor + push: + - match: \{ + scope: punctuation.section.block.begin.cs-razor + set: + - clear_scopes: 1 + - meta_scope: source.cs.embedded.functions.cs-razor + - match: \} + scope: punctuation.section.block.end.cs-razor + pop: true + - include: scope:source.cs#code_block_in + - match: \s*(?!\{)(?=\S) + scope: invalid.illegal.expected-block.cs-razor + pop: true + - match: '@@' + scope: constant.character.escape.cs-razor + - match: (@)(?=(?:if|switch|for|foreach|using|try|lock)\b) + captures: + 1: punctuation.section.embedded.cs-razor + push: + - clear_scopes: 1 + - meta_content_scope: source.cs.embedded.html + - include: scope:source.cs#line_of_code + - match: '' + pop: true + with_prototype: + - include: razor-block-prototype + - match: '[\w-+]+@\w+' # ignore email addresses + - match: '@(?=(?:\w+\.)*\w+(?:[<\s]|$))' + scope: punctuation.section.embedded.line.cs-razor + embed: scope:source.cs#line_of_code_in + embed_scope: source.cs.embedded.html + escape: $|(?=[<\s]) + - match: '@(?=(?:\w+\.)*\w+\()' + scope: punctuation.section.embedded.line.cs-razor + push: + - meta_content_scope: source.cs.embedded.html + - match: (?=[<\s]) + pop: true + - include: scope:source.cs#line_of_code_in + - match: '@\(' + scope: punctuation.section.embedded.begin.cs-razor + push: + - clear_scopes: 1 + - meta_content_scope: source.cs.embedded.html + - match: \) + scope: punctuation.section.embedded.end.cs-razor + pop: true + - include: scope:source.cs#line_of_code_in + #- match: '@(?=\w+(?:\.\w+)*)(?!\s*[+=|(])' # TODO: support a.b[2] etc. + # comment: property/variable access + # scope: punctuation.section.embedded.line.cs-razor + # #push: razor-block # TODO: stop at closing " etc. + - match: '@' + scope: punctuation.section.embedded.line.cs-razor + push: razor-block + + razor-block-prototype: + - match: (?=[<&]) + embed: scope:text.html.basic + escape: (?=[@}]|$) + - match: '@:' + scope: punctuation.section.embedded.html.cs-razor + embed: scope:text.html.basic + escape: $ + + eat-whitespace: + - match: (?=\S) + pop: true + + razor-block: + - clear_scopes: 1 + - meta_content_scope: source.cs.embedded.html + - match: (?=[<\s]) + pop: true + - match: (?=\S)(?!@) + push: + - include: scope:source.cs#line_of_code + with_prototype: + - include: razor-block-prototype + +###[ HTML CONTENT ]########################################################### + + tag-html: + - meta_prepend: true + - include: razor-constructs + - include: csharp-interpolations + + cdata-content: + - meta_prepend: true + - meta_include_prototype: false + - include: csharp-interpolations + + script-javascript-content: + - meta_include_prototype: false + - match: \s*(( + escape_captures: + 0: meta.tag.sgml.cdata.html punctuation.definition.tag.end.html + - match: '{{script_content_begin}}' + captures: + 1: comment.block.html punctuation.definition.comment.begin.html + pop: 1 # make sure to match only once + embed: scope:source.js.cs.razor + embed_scope: source.js.embedded.html + escape: '{{script_content_end}}' + escape_captures: + 1: source.js.embedded.html + 2: comment.block.html punctuation.definition.comment.end.html + 3: source.js.embedded.html + 4: comment.block.html punctuation.definition.comment.end.html + + style-css-content: + - meta_include_prototype: false + - match: \s*(( + escape_captures: + 0: meta.tag.sgml.cdata.html punctuation.definition.tag.end.html + - match: '{{style_content_begin}}' + captures: + 1: comment.block.html punctuation.definition.comment.begin.html + pop: 1 # make sure to match only once + embed: scope:source.css.cs.razor + embed_scope: source.css.embedded.html + escape: '{{style_content_end}}' + escape_captures: + 1: source.css.embedded.html + 2: comment.block.html punctuation.definition.comment.end.html + 3: source.css.embedded.html + 4: comment.block.html punctuation.definition.comment.end.html + + tag-event-attribute-value: + - match: \" + scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html + embed: scope:source.js.cs.razor + embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html + escape: \" + escape_captures: + 0: meta.string.html string.quoted.double.html punctuation.definition.string.end.html + - match: \' + scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html + embed: scope:source.js.cs.razor + embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html + escape: \' + escape_captures: + 0: meta.string.html string.quoted.single.html punctuation.definition.string.end.html + - include: else-pop + + tag-style-attribute-value: + - match: \" + scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html + embed: scope:source.css.cs.razor#rule-list-body + embed_scope: meta.string.html meta.interpolation.html source.css.embedded.html + escape: \" + escape_captures: + 0: meta.string.html string.quoted.double.html punctuation.definition.string.end.html + - match: \' + scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html + embed: scope:source.css.cs.razor#rule-list-body + embed_scope: meta.string.html meta.interpolation.html source.css.embedded.html + escape: \' + escape_captures: + 0: meta.string.html string.quoted.single.html punctuation.definition.string.end.html + - include: else-pop + + tag-attribute-value-content: + - meta_prepend: true + - include: csharp-interpolations + + strings-common-content: + - meta_prepend: true + - include: csharp-interpolations + +###[ C# TAGS ]############################################################### + + csharp-tags: + # - include: php-tag-incomplete + - include: comments + - match: '{{csharp_tag}}' + scope: punctuation.section.embedded.begin.cs-razor + push: csharp-tag-content + + csharp-tag-content: + - meta_include_prototype: false + - meta_scope: meta.embedded.cs + - meta_content_scope: source.cs.embedded.html + - match: ({{csharp_tag_end}})(\s*\n)? + captures: + 1: punctuation.section.embedded.end.cs-razor + 2: meta.html-newline-after-csharp.cs-razor # used by indentation rules + pop: 1 + - include: Packages/HTML (C#)/Razor/C# (Razor).sublime-syntax + apply_prototype: true + + csharp-interpolations: + - meta_include_prototype: false + - match: '@@' + scope: constant.character.escape.cs-razor + - match: (?={{csharp_tag_interpolation_bare}}) + push: csharp-interpolation-body + + csharp-interpolation-body: + # - clear_scopes: 1 + - meta_include_prototype: false + - include: csharp-embedded + - include: immediately-pop + + csharp-embedded: + - meta_include_prototype: false + - match: '{{csharp_tag_interpolation_bare}}' + scope: meta.embedded.cs punctuation.section.embedded.begin.cs-razor + embed: Packages/C#/C#.sublime-syntax + embed_scope: meta.embedded.cs source.cs.embedded.html + escape: ((?=")|\s*\n)? + escape_captures: + 0: meta.embedded.cs + # 1: punctuation.section.embedded.end.cs-razor + 1: meta.html-newline-after-csharp.cs-razor + - match: '{{csharp_tag_interpolation_paren}}' + scope: meta.embedded.cs punctuation.section.embedded.begin.cs-razor + embed: Packages/C#/C#.sublime-syntax + embed_scope: meta.embedded.cs source.cs.embedded.html + escape: (\))(\s*\n)? + escape_captures: + 0: meta.embedded.cs + 1: punctuation.section.embedded.end.cs-razor + 2: meta.html-newline-after-csharp.cs-razor diff --git a/Razor/embeddings/CSS (for C# Razor double-quoted).sublime-syntax b/Razor/embeddings/CSS (for C# Razor double-quoted).sublime-syntax new file mode 100644 index 0000000..9542e72 --- /dev/null +++ b/Razor/embeddings/CSS (for C# Razor double-quoted).sublime-syntax @@ -0,0 +1,17 @@ +%YAML 1.2 +--- +scope: source.css.embedded.string.quoted.double.cs.razor +version: 2 +hidden: true + +extends: Packages/HTML (C#)/Razor/CSS (Razor).sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - match: (?=") + pop: 1 + + main: + - include: rule-list-body diff --git a/Razor/embeddings/CSS (for C# Razor single-quoted).sublime-syntax b/Razor/embeddings/CSS (for C# Razor single-quoted).sublime-syntax new file mode 100644 index 0000000..e3afa3f --- /dev/null +++ b/Razor/embeddings/CSS (for C# Razor single-quoted).sublime-syntax @@ -0,0 +1,17 @@ +%YAML 1.2 +--- +scope: source.css.embedded.string.quoted.single.cs.razor +version: 2 +hidden: true + +extends: Packages/HTML (C#)/Razor/CSS (Razor).sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - match: (?=') + pop: 1 + + main: + - include: rule-list-body diff --git a/Razor/embeddings/JavaScript (for C# Razor double-quoted).sublime-syntax b/Razor/embeddings/JavaScript (for C# Razor double-quoted).sublime-syntax new file mode 100644 index 0000000..402f845 --- /dev/null +++ b/Razor/embeddings/JavaScript (for C# Razor double-quoted).sublime-syntax @@ -0,0 +1,14 @@ +%YAML 1.2 +--- +scope: source.js.embedded.string.quoted.double.cs.razor +version: 2 +hidden: true + +extends: Packages/HTML (C#)/Razor/JavaScript (Razor).sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - match: (?=") + pop: 1 diff --git a/Razor/embeddings/JavaScript (for C# Razor single-quoted).sublime-syntax b/Razor/embeddings/JavaScript (for C# Razor single-quoted).sublime-syntax new file mode 100644 index 0000000..c13cf83 --- /dev/null +++ b/Razor/embeddings/JavaScript (for C# Razor single-quoted).sublime-syntax @@ -0,0 +1,14 @@ +%YAML 1.2 +--- +scope: source.js.embedded.string.quoted.single.cs.razor +version: 2 +hidden: true + +extends: Packages/HTML (C#)/Razor/JavaScript (Razor).sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - match: (?=') + pop: 1 diff --git a/support/Razor/Comments.tmPreferences b/Razor/support/Comments.tmPreferences similarity index 100% rename from support/Razor/Comments.tmPreferences rename to Razor/support/Comments.tmPreferences diff --git a/tests/syntax_test_cshtml.cshtml b/Razor/tests/syntax_test_cshtml.cshtml similarity index 92% rename from tests/syntax_test_cshtml.cshtml rename to Razor/tests/syntax_test_cshtml.cshtml index 5df584a..eae238a 100644 --- a/tests/syntax_test_cshtml.cshtml +++ b/Razor/tests/syntax_test_cshtml.cshtml @@ -1,4 +1,4 @@ - + @using System.Collections.Generic @@ -30,10 +30,10 @@ Support@contoso.com - + - +

@DateTime.Now

@@ -45,7 +45,7 @@ - + @@ -74,7 +74,7 @@ @if (value % 2 == 0) - + {

The value was even.

@@ -118,11 +118,11 @@ else var person = people[i]; @:Name: @person.Name } *@ - + @{ var quote = "The future depends on what you do today. - Mahatma Gandhi"; - + } @@ -162,13 +162,13 @@ finally // Do critical section work } -@* - @{ - /* C# comment */ - // Another C# comment - } - -*@ + +@{ + /* C# comment */ + // Another C# comment +} + + @functions { // @@ -209,6 +209,7 @@ finally diff --git a/WebForms/C# (WebForms).sublime-syntax b/WebForms/C# (WebForms).sublime-syntax new file mode 100644 index 0000000..12309c3 --- /dev/null +++ b/WebForms/C# (WebForms).sublime-syntax @@ -0,0 +1,41 @@ +%YAML 1.2 +--- +scope: source.cs.embedded.html +hidden: true +# version: 2 + +extends: Packages/C#/C#.sublime-syntax + +############################################################################## + +contexts: + code_block_in: + - meta_prepend: true + - match: (%>)(\s*\n)? + scope: meta.embedded.cs + captures: + 1: punctuation.section.embedded.end.cs-webforms + 2: meta.html-newline-after-csharp.cs-webforms # used by indentation rules + push: embedding-syntax + + embedding-syntax: + - clear_scopes: true + - meta_scope: embedding.cs text.html.cs.webforms + - meta_include_prototype: false + - match: <%(?![=#:$@-]) + scope: meta.embedded.cs punctuation.section.embedded.begin.cs-webforms + pop: 1 + - include: Packages/HTML (C#)/WebForms/WebForms.sublime-syntax#comments + - include: Packages/HTML (C#)/WebForms/WebForms.sublime-syntax#html + + stray-braces: + - match: \} + scope: invalid.illegal.stray.cs + + stray-brackets: + - match: \] + scope: invalid.illegal.stray.cs + + stray-parens: + - match: \) + scope: invalid.illegal.stray.cs diff --git a/WebForms/CSS (WebForms).sublime-syntax b/WebForms/CSS (WebForms).sublime-syntax new file mode 100644 index 0000000..a29035c --- /dev/null +++ b/WebForms/CSS (WebForms).sublime-syntax @@ -0,0 +1,42 @@ +%YAML 1.2 +--- +name: CSS (WebForms) +scope: source.css.cs.webforms +version: 2 +hidden: true + +extends: Packages/CSS/CSS.sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - include: WebForms.sublime-syntax#comments + - include: csharp-embedded + + string-content: + - meta_prepend: true + - include: csharp-interpolations + + csharp-interpolations: + - meta_include_prototype: false + - match: (?=<%[=#:$]) + push: csharp-interpolation-body + + csharp-interpolation-body: + - clear_scopes: 1 + - meta_include_prototype: false + - include: csharp-embedded + - include: immediately-pop + + csharp-embedded: + - meta_include_prototype: false + - match: <%[=#:$] + scope: meta.embedded.cs punctuation.section.embedded.begin.cs-webforms + embed: Packages/C#/C#.sublime-syntax + embed_scope: meta.embedded.cs source.cs.embedded.css + escape: (%>)(\s*\n)? + escape_captures: + 0: meta.embedded.cs + 1: punctuation.section.embedded.end.cs-webforms + 2: meta.html-newline-after-csharp.cs-webforms diff --git a/WebForms/JavaScript (WebForms).sublime-syntax b/WebForms/JavaScript (WebForms).sublime-syntax new file mode 100644 index 0000000..9d8f9c9 --- /dev/null +++ b/WebForms/JavaScript (WebForms).sublime-syntax @@ -0,0 +1,42 @@ +%YAML 1.2 +--- +name: JavaScript (WebForms) +scope: source.js.cs.webforms +version: 2 +hidden: true + +extends: Packages/JavaScript/JavaScript.sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - include: WebForms.sublime-syntax#comments + - include: csharp-embedded + + string-content: + - meta_prepend: true + - include: csharp-interpolations + + csharp-interpolations: + - meta_include_prototype: false + - match: (?=<%[=#:$]) + push: csharp-interpolation-body + + csharp-interpolation-body: + - clear_scopes: 1 + - meta_include_prototype: false + - include: csharp-embedded + - include: immediately-pop + + csharp-embedded: + - meta_include_prototype: false + - match: <%[=#:$] + scope: meta.embedded.cs punctuation.section.embedded.begin.cs-webforms + embed: Packages/C#/C#.sublime-syntax + embed_scope: meta.embedded.cs source.cs.embedded.css + escape: (%>)(\s*\n)? + escape_captures: + 0: meta.embedded.cs + 1: punctuation.section.embedded.end.cs-webforms + 2: meta.html-newline-after-csharp.cs-webforms diff --git a/WebForms/WebForms.sublime-commands b/WebForms/WebForms.sublime-commands new file mode 100644 index 0000000..1d30625 --- /dev/null +++ b/WebForms/WebForms.sublime-commands @@ -0,0 +1,10 @@ +[ + { + "caption": "C# WebForms: Open CodeBehind / CodeFile", + "command": "open_code_file_from_front_end", + }, + { + "caption": "C# WebForms: Open Front End", + "command": "open_front_end_from_code_file", + }, +] diff --git a/WebForms/WebForms.sublime-syntax b/WebForms/WebForms.sublime-syntax new file mode 100644 index 0000000..65571b5 --- /dev/null +++ b/WebForms/WebForms.sublime-syntax @@ -0,0 +1,387 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/syntax.html +name: HTML (C# WebForms) +scope: text.html.cs.webforms +version: 2 + +extends: Packages/HTML/HTML.sublime-syntax +hidden: true +file_extensions: [] + +variables: + csharp_tag: (?:<%(?![=#:$@-])) + csharp_tag_interpolation: (?:<%[=#:$]) + csharp_tag_end: (?:%>) + +contexts: + prototype: + - meta_prepend: true + - include: comments + - include: csharp-embedded + + main: + - meta_include_prototype: false + - match: '' + push: [webforms, directives] + + webforms: + # This is the main ASP.Net context. + # It includes `csharp-tags` which are allowed to be closed by %> tags at any + # level of code-block on stack resuming with the next top-level <% tag. + - meta_include_prototype: false + - include: csharp-tags + - include: html + + comments: + - match: <%-- + scope: punctuation.definition.comment.block.begin.cs-webforms + push: + - meta_scope: comment.block.cs-webforms + - match: '--%>' + scope: punctuation.definition.comment.block.end.cs-webforms + pop: true + +###[ DIRECTIVES ]################################################################ + + directives: + - meta_include_prototype: false + - include: comments + - include: directive + - match: (?=\S) + pop: 1 + + directive-generic-attribute: + - match: \b(\w+)\s*(?:(=)\s*((")[^"]*("))?)?\s* + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: punctuation.definition.string.end.cs-webforms + + directive-codefile-attribute: + - match: \b(CodeBehind|CodeFile)\s*(?:(=)\s*((")([^"]*)("))?)?\s* + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: meta.path.codefile.cs-webforms + 6: punctuation.definition.string.end.cs-webforms + + directive-end: + - match: '{{csharp_tag_end}}' + scope: punctuation.section.embedded.end.cs-webforms + pop: 1 + + directive: + # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx + - match: <%@ + scope: punctuation.section.embedded.begin.cs-webforms + push: + - meta_scope: meta.block.processing-directive.cs-webforms + - include: directive-type + - include: directive-import + - include: directive-implements + - include: directive-reference + - include: directive-outputcache + - include: directive-other + # Blank directives are considered to be "Page" or "Control" by .Net + - include: directive-generic-attribute + - include: directive-end + + directive-type: [] + + directive-import: + # https://msdn.microsoft.com/en-us/library/eb44kack(v=vs.100).aspx + - match: \b(?i:Import)\b + scope: constant.language.processing-directive.cs-webforms + set: + - meta_scope: meta.block.processing-directive.contents.import.cs-webforms + - match: \b(?i:(Namespace))\s*(=)\s*((")([^"]*)(")) + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: meta.path.cs + 6: punctuation.definition.string.end.cs-webforms + - include: directive-end + + directive-implements: + # https://msdn.microsoft.com/en-us/library/cbsf6k72(v=vs.100).aspx + - match: \b(?i:Implements)\b + scope: constant.language.processing-directive.cs-webforms + set: + - meta_scope: meta.block.processing-directive.contents.implements.cs-webforms + - match: \b(?i:(Interface))\s*(=)\s*((")([^"]*)(")) + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: entity.other.inherited-class.cs + 6: punctuation.definition.string.end.cs-webforms + - include: directive-end + + directive-reference: + # https://msdn.microsoft.com/en-us/library/w70c655a(v=vs.100).aspx + - match: \b(?i:Reference)\b + scope: constant.language.processing-directive.reference.cs-webforms + set: + - meta_scope: meta.block.processing-directive.contents.reference.cs-webforms + - match: \b(?i:(Page|Control|VirtualPath))\s*(=)\s*((")([^"]*)(")) + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: meta.path.cs + 6: punctuation.definition.string.end.cs-webforms + - include: directive-end + + directive-outputcache: + # https://msdn.microsoft.com/en-us/library/hdxfb6cy(v=vs.100).aspx + - match: \b(?i:OutputCache)\b + scope: constant.language.processing-directive.caching.cs-webforms + set: + - meta_scope: meta.block.processing-directive.contents.outputcache.cs-webforms + - match: \b(?i:(Duration))\s*(=)\s*((")(?:(\d+)|[^"]*)(")) + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: constant.numeric.integer.cs-webforms + 6: punctuation.definition.string.end.cs-webforms + - match: \b(?i:(NoStore|Shared))\s*(=)\s*((")(?i:(true|false)|[^"]*)(")) + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: constant.language.boolean.cs-webforms + 6: punctuation.definition.string.end.cs-webforms + - match: \b(?i:(Location))\s*(=)\s*((")(?i:(Any|Client|Downstream|Server|None|ServerAndClient)|[^"]*)(")) + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: meta.enum.cache-location.cs-webforms + 6: punctuation.definition.string.end.cs-webforms + - match: \b(?i:(CacheProfile|SqlDependency|ProviderName|VaryBy(?:Control|Custom|Header|Param|ContentEncoding)))\s*(=)\s*((")([^"]*)(")) + captures: + 1: entity.other.attribute-name.cs-webforms + 2: punctuation.separator.key-value.cs-webforms + 3: string.quoted.double.cs-webforms + 4: punctuation.definition.string.begin.cs-webforms + 5: meta.path.cs + 6: punctuation.definition.string.end.cs-webforms + - include: directive-end + + directive-other: + # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx + - match: \b(Register|Assembly|PreviousPageType|MasterType)\b + scope: constant.language.processing-directive.cs-webforms + set: + - include: directive-generic-attribute + - include: directive-end + + +###[ HTML CONTENT ]########################################################### + + script-tag-csharp: + - match: (?i)(<)(script)[^>]+(runat)(=)(?:((')server('))|((")server("))) + captures: + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: constant.language.processing-directive.cshtml + 4: punctuation.separator.key-value.cshtml + 5: string.quoted.single.cshtml + 6: punctuation.definition.string.begin.cshtml + 7: punctuation.definition.string.end.cshtml + 8: string.quoted.double.cshtml + 9: punctuation.definition.string.begin.cshtml + 10: punctuation.definition.string.end.cshtml + push: + - match: (?i)() + captures: + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.html + 3: punctuation.definition.tag.end.html + pop: 1 + - match: '>' + scope: punctuation.definition.tag.end.html + embed: Packages/C#/C#.sublime-syntax + embed_scope: source.cs.embedded.html + escape: (?i)(?= + escape_captures: + 0: meta.tag.sgml.cdata.html punctuation.definition.tag.end.html + - match: '{{script_content_begin}}' + captures: + 1: comment.block.html punctuation.definition.comment.begin.html + pop: 1 # make sure to match only once + embed: scope:source.js.cs.webforms + embed_scope: source.js.embedded.html + escape: '{{script_content_end}}' + escape_captures: + 1: source.js.embedded.html + 2: comment.block.html punctuation.definition.comment.end.html + 3: source.js.embedded.html + 4: comment.block.html punctuation.definition.comment.end.html + + style-css-content: + - meta_include_prototype: false + - match: \s*(( + escape_captures: + 0: meta.tag.sgml.cdata.html punctuation.definition.tag.end.html + - match: '{{style_content_begin}}' + captures: + 1: comment.block.html punctuation.definition.comment.begin.html + pop: 1 # make sure to match only once + embed: scope:source.css.cs.webforms + embed_scope: source.css.embedded.html + escape: '{{style_content_end}}' + escape_captures: + 1: source.css.embedded.html + 2: comment.block.html punctuation.definition.comment.end.html + 3: source.css.embedded.html + 4: comment.block.html punctuation.definition.comment.end.html + + tag-event-attribute-value: + - match: \" + scope: string.quoted.double.html punctuation.definition.string.begin.html + set: tag-event-attribute-value-double-quoted-content + - match: \' + scope: string.quoted.single.html punctuation.definition.string.begin.html + set: tag-event-attribute-value-single-quoted-content + - include: else-pop + + tag-event-attribute-value-double-quoted-content: + - meta_scope: meta.string.html + - meta_content_scope: meta.interpolation.html source.js.embedded.html + - match: \" + scope: string.quoted.double.html punctuation.definition.string.end.html + pop: 1 + - include: scope:source.js.embedded.string.quoted.double.cs.webforms + + tag-event-attribute-value-single-quoted-content: + - meta_scope: meta.string.html + - meta_content_scope: meta.interpolation.html source.js.embedded.html + - match: \' + scope: string.quoted.single.html punctuation.definition.string.end.html + pop: 1 + - include: scope:source.js.embedded.string.quoted.single.cs.webforms + + tag-style-attribute-value: + - match: \" + scope: string.quoted.double.html punctuation.definition.string.begin.html + set: tag-style-attribute-value-double-quoted-content + - match: \' + scope: string.quoted.single.html punctuation.definition.string.begin.html + set: tag-style-attribute-value-single-quoted-content + - include: else-pop + + tag-style-attribute-value-double-quoted-content: + - meta_scope: meta.string.html + - meta_content_scope: meta.interpolation.html source.css.embedded.html + - match: \" + scope: string.quoted.double.html punctuation.definition.string.end.html + pop: 1 + - include: scope:source.css.embedded.string.quoted.double.cs.webforms + + tag-style-attribute-value-single-quoted-content: + - meta_scope: meta.string.html + - meta_content_scope: meta.interpolation.html source.css.embedded.html + - match: \' + scope: string.quoted.single.html punctuation.definition.string.end.html + pop: 1 + - include: scope:source.css.embedded.string.quoted.single.cs.webforms + + tag-attribute-value-content: + - meta_prepend: true + - include: csharp-interpolations + + strings-common-content: + - meta_prepend: true + - include: csharp-interpolations + +###[ C# TAGS ]############################################################### + + csharp-tags: + # - include: php-tag-incomplete + - include: comments + - match: '{{csharp_tag}}' + scope: punctuation.section.embedded.begin.cs-webforms + push: csharp-tag-content + + csharp-tag-content: + - meta_include_prototype: false + - meta_scope: meta.embedded.cs + - meta_content_scope: source.cs.embedded.html + - match: ({{csharp_tag_end}})(\s*\n)? + captures: + 1: punctuation.section.embedded.end.cs-webforms + 2: meta.html-newline-after-csharp.cs-webforms # used by indentation rules + pop: 1 + - include: Packages/HTML (C#)/WebForms/C# (WebForms).sublime-syntax + apply_prototype: true + + csharp-interpolations: + - meta_include_prototype: false + - match: (?={{csharp_tag_interpolation}}) + push: csharp-interpolation-body + + csharp-interpolation-body: + # - clear_scopes: 1 + - meta_include_prototype: false + - include: csharp-embedded + - include: immediately-pop + + csharp-embedded: + - meta_include_prototype: false + - match: '{{csharp_tag_interpolation}}' + scope: meta.embedded.cs punctuation.section.embedded.begin.cs-webforms + embed: Packages/C#/C#.sublime-syntax + embed_scope: meta.embedded.cs source.cs.embedded.html + escape: ({{csharp_tag_end}})(\s*\n)? + escape_captures: + 0: meta.embedded.cs + 1: punctuation.section.embedded.end.cs-webforms + 2: meta.html-newline-after-csharp.cs-webforms + diff --git a/WebForms/asax.sublime-syntax b/WebForms/asax.sublime-syntax new file mode 100644 index 0000000..e128b57 --- /dev/null +++ b/WebForms/asax.sublime-syntax @@ -0,0 +1,23 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/syntax.html +name: HTML (C#) Application +scope: text.html.cs.webforms.asax +version: 2 + +extends: Packages/HTML (C#)/WebForms/WebForms.sublime-syntax + +first_line_match: <%@\s*Application\b + +file_extensions: + - asax + +contexts: + directive-type: + # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx + - match: \b(?i:Application)\b + scope: constant.language.processing-directive.cs-webforms entity.name.class.cs + set: + - meta_scope: meta.block.processing-directive.contents.type.cs-webforms + - include: directive-generic-attribute + - include: directive-end diff --git a/WebForms/ascx.sublime-syntax b/WebForms/ascx.sublime-syntax new file mode 100644 index 0000000..5e80229 --- /dev/null +++ b/WebForms/ascx.sublime-syntax @@ -0,0 +1,24 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/syntax.html +name: HTML (C#) Control +scope: text.html.cs.webforms.ascx +version: 2 + +extends: Packages/HTML (C#)/WebForms/WebForms.sublime-syntax + +first_line_match: <%@\s*Control\b + +file_extensions: + - ascx + +contexts: + directive-type: + # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx + - match: \b(?i:Control)\b + scope: constant.language.processing-directive.cs-webforms entity.name.class.cs + set: + - meta_scope: meta.block.processing-directive.contents.type.cs-webforms + - include: directive-codefile-attribute + - include: directive-generic-attribute + - include: directive-end diff --git a/ashx.sublime-syntax b/WebForms/ashx.sublime-syntax similarity index 95% rename from ashx.sublime-syntax rename to WebForms/ashx.sublime-syntax index 4d5fbc9..1558137 100644 --- a/ashx.sublime-syntax +++ b/WebForms/ashx.sublime-syntax @@ -1,11 +1,15 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# http://www.sublimetext.com/docs/syntax.html name: .Net Web Handler (ASHX) +scope: source.cs.webforms.ashx +version: 2 + first_line_match: <%@\s*WebHandler + file_extensions: - ashx -scope: embedding.ashx + contexts: main: - match: '' diff --git a/WebForms/aspx.sublime-syntax b/WebForms/aspx.sublime-syntax new file mode 100644 index 0000000..c469973 --- /dev/null +++ b/WebForms/aspx.sublime-syntax @@ -0,0 +1,24 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/syntax.html +name: HTML (C#) Page +scope: text.html.cs.webforms.aspx +version: 2 + +extends: Packages/HTML (C#)/WebForms/WebForms.sublime-syntax + +first_line_match: <%@\s*Page\b + +file_extensions: + - aspx + +contexts: + directive-type: + # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx + - match: \b(?i:Page)\b + scope: constant.language.processing-directive.cs-webforms entity.name.class.cs + set: + - meta_scope: meta.block.processing-directive.contents.type.cs-webforms + - include: directive-codefile-attribute + - include: directive-generic-attribute + - include: directive-end diff --git a/WebForms/embeddings/CSS (for C# WebForms double-quoted).sublime-syntax b/WebForms/embeddings/CSS (for C# WebForms double-quoted).sublime-syntax new file mode 100644 index 0000000..50987c7 --- /dev/null +++ b/WebForms/embeddings/CSS (for C# WebForms double-quoted).sublime-syntax @@ -0,0 +1,17 @@ +%YAML 1.2 +--- +scope: source.css.embedded.string.quoted.double.cs.webforms +version: 2 +hidden: true + +extends: Packages/HTML (C#)/WebForms/CSS (WebForms).sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - match: (?=") + pop: 1 + + main: + - include: rule-list-body diff --git a/WebForms/embeddings/CSS (for C# WebForms single-quoted).sublime-syntax b/WebForms/embeddings/CSS (for C# WebForms single-quoted).sublime-syntax new file mode 100644 index 0000000..0039737 --- /dev/null +++ b/WebForms/embeddings/CSS (for C# WebForms single-quoted).sublime-syntax @@ -0,0 +1,17 @@ +%YAML 1.2 +--- +scope: source.css.embedded.string.quoted.single.cs.webforms +version: 2 +hidden: true + +extends: Packages/HTML (C#)/WebForms/CSS (WebForms).sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - match: (?=') + pop: 1 + + main: + - include: rule-list-body diff --git a/WebForms/embeddings/JavaScript (for C# WebForms double-quoted).sublime-syntax b/WebForms/embeddings/JavaScript (for C# WebForms double-quoted).sublime-syntax new file mode 100644 index 0000000..9c04c9e --- /dev/null +++ b/WebForms/embeddings/JavaScript (for C# WebForms double-quoted).sublime-syntax @@ -0,0 +1,14 @@ +%YAML 1.2 +--- +scope: source.js.embedded.string.quoted.double.cs.webforms +version: 2 +hidden: true + +extends: Packages/HTML (C#)/WebForms/JavaScript (WebForms).sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - match: (?=") + pop: 1 diff --git a/WebForms/embeddings/JavaScript (for C# WebForms single-quoted).sublime-syntax b/WebForms/embeddings/JavaScript (for C# WebForms single-quoted).sublime-syntax new file mode 100644 index 0000000..aa368b2 --- /dev/null +++ b/WebForms/embeddings/JavaScript (for C# WebForms single-quoted).sublime-syntax @@ -0,0 +1,14 @@ +%YAML 1.2 +--- +scope: source.js.embedded.string.quoted.single.cs.webforms +version: 2 +hidden: true + +extends: Packages/HTML (C#)/WebForms/JavaScript (WebForms).sublime-syntax + +contexts: + + prototype: + - meta_prepend: true + - match: (?=') + pop: 1 diff --git a/WebForms/master.sublime-syntax b/WebForms/master.sublime-syntax new file mode 100644 index 0000000..6d73c63 --- /dev/null +++ b/WebForms/master.sublime-syntax @@ -0,0 +1,24 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/syntax.html +name: HTML (C#) Master +scope: text.html.cs.webforms.master +version: 2 + +extends: Packages/HTML (C#)/WebForms/WebForms.sublime-syntax + +first_line_match: <%@\s*Master\b + +file_extensions: + - master + +contexts: + directive-type: + # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx + - match: \b(?i:Master)\b + scope: constant.language.processing-directive.cs-webforms entity.name.class.cs + set: + - meta_scope: meta.block.processing-directive.contents.type.cs-webforms + - include: directive-codefile-attribute + - include: directive-generic-attribute + - include: directive-end diff --git a/support/ASP.Net/Comments.tmPreferences b/WebForms/support/Comments.tmPreferences similarity index 100% rename from support/ASP.Net/Comments.tmPreferences rename to WebForms/support/Comments.tmPreferences diff --git a/support/Symbol List Directives.tmPreferences b/WebForms/support/Symbol List Directives.tmPreferences similarity index 100% rename from support/Symbol List Directives.tmPreferences rename to WebForms/support/Symbol List Directives.tmPreferences diff --git a/support/ASP.Net/code-blocks/code-block.sublime-snippet b/WebForms/support/code-blocks/code-block.sublime-snippet similarity index 100% rename from support/ASP.Net/code-blocks/code-block.sublime-snippet rename to WebForms/support/code-blocks/code-block.sublime-snippet diff --git a/support/ASP.Net/code-blocks/foreach-block.sublime-snippet b/WebForms/support/code-blocks/foreach-block.sublime-snippet similarity index 100% rename from support/ASP.Net/code-blocks/foreach-block.sublime-snippet rename to WebForms/support/code-blocks/foreach-block.sublime-snippet diff --git a/support/ASP.Net/code-blocks/if-block.sublime-snippet b/WebForms/support/code-blocks/if-block.sublime-snippet similarity index 100% rename from support/ASP.Net/code-blocks/if-block.sublime-snippet rename to WebForms/support/code-blocks/if-block.sublime-snippet diff --git a/support/ASP.Net/controls/Repeater.sublime-snippet b/WebForms/support/controls/Repeater.sublime-snippet similarity index 100% rename from support/ASP.Net/controls/Repeater.sublime-snippet rename to WebForms/support/controls/Repeater.sublime-snippet diff --git a/support/ASP.Net/directives/OutputCache.sublime-completions b/WebForms/support/directives/OutputCache.sublime-completions similarity index 100% rename from support/ASP.Net/directives/OutputCache.sublime-completions rename to WebForms/support/directives/OutputCache.sublime-completions diff --git a/support/ASP.Net/directives/directive types.sublime-completions b/WebForms/support/directives/directive types.sublime-completions similarity index 100% rename from support/ASP.Net/directives/directive types.sublime-completions rename to WebForms/support/directives/directive types.sublime-completions diff --git a/support/ASP.Net/expressions/appsetting.sublime-snippet b/WebForms/support/expressions/appsetting.sublime-snippet similarity index 100% rename from support/ASP.Net/expressions/appsetting.sublime-snippet rename to WebForms/support/expressions/appsetting.sublime-snippet diff --git a/support/ASP.Net/expressions/databound-encoded.sublime-snippet b/WebForms/support/expressions/databound-encoded.sublime-snippet similarity index 100% rename from support/ASP.Net/expressions/databound-encoded.sublime-snippet rename to WebForms/support/expressions/databound-encoded.sublime-snippet diff --git a/support/ASP.Net/expressions/databound.sublime-snippet b/WebForms/support/expressions/databound.sublime-snippet similarity index 100% rename from support/ASP.Net/expressions/databound.sublime-snippet rename to WebForms/support/expressions/databound.sublime-snippet diff --git a/support/ASP.Net/expressions/directive.sublime-snippet b/WebForms/support/expressions/directive.sublime-snippet similarity index 100% rename from support/ASP.Net/expressions/directive.sublime-snippet rename to WebForms/support/expressions/directive.sublime-snippet diff --git a/support/ASP.Net/expressions/encoded.sublime-snippet b/WebForms/support/expressions/encoded.sublime-snippet similarity index 100% rename from support/ASP.Net/expressions/encoded.sublime-snippet rename to WebForms/support/expressions/encoded.sublime-snippet diff --git a/support/ASP.Net/expressions/literal.sublime-snippet b/WebForms/support/expressions/literal.sublime-snippet similarity index 100% rename from support/ASP.Net/expressions/literal.sublime-snippet rename to WebForms/support/expressions/literal.sublime-snippet diff --git a/support/ASP.Net/root.sublime-completions b/WebForms/support/root.sublime-completions similarity index 100% rename from support/ASP.Net/root.sublime-completions rename to WebForms/support/root.sublime-completions diff --git a/tests/syntax_test_ashx.ashx b/WebForms/tests/syntax_test_ashx.ashx similarity index 85% rename from tests/syntax_test_ashx.ashx rename to WebForms/tests/syntax_test_ashx.ashx index 16293d6..3a4b5e3 100644 --- a/tests/syntax_test_ashx.ashx +++ b/WebForms/tests/syntax_test_ashx.ashx @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/HTML (C#)/ashx.sublime-syntax" +// SYNTAX TEST "Packages/HTML (C#)/WebForms/ashx.sublime-syntax" <%@ WebHandler Language="C#" Class="Handler" %> diff --git a/WebForms/tests/syntax_test_aspx.aspx b/WebForms/tests/syntax_test_aspx.aspx new file mode 100644 index 0000000..947b514 --- /dev/null +++ b/WebForms/tests/syntax_test_aspx.aspx @@ -0,0 +1,147 @@ +<%-- SYNTAX TEST "Packages/HTML (C#)/WebForms/aspx.sublime-syntax" --%> + +<%@ Page Debug="true" Title="" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> +<%-- <- punctuation.section.embedded.begin --%> +<%--^^^^ constant.language.processing-directive entity.name.class.cs --%> +<%-- ^^^^^ entity.other.attribute-name --%> +<%-- ^ punctuation.separator.key-value --%> +<%-- ^^^^^^ string.quoted.double --%> +<%-- ^ punctuation.definition.string.begin --%> +<%-- ^ punctuation.definition.string.end --%> +<%-- ^^^^^ entity.other.attribute-name --%> +<%-- ^ punctuation.separator.key-value --%> +<%-- ^^ string.quoted.double --%> +<%-- ^ punctuation.definition.string.begin --%> +<%-- ^ punctuation.definition.string.end --%> + +<%@ Import Namespace="System.Net" %> +<%-- <- punctuation.section.embedded.begin --%> +<%--^^^^^^ constant.language.processing-directive --%> +<%-- ^^^^^^^^^ entity.other.attribute-name --%> +<%-- ^ punctuation.separator.key-value --%> +<%-- ^^^^^^^^^^^^ string.quoted.double --%> +<%-- ^ punctuation.definition.string.begin --%> +<%-- ^^^^^^^^^^ meta.path.cs --%> +<%-- ^ punctuation.definition.string.end --%> +<%-- ^^ punctuation.section.embedded.end --%> + +<%@ Register TagPrefix="my" Namespace="Foo.Bar" Assembly="Solution.LinkLibrary" %> +<%-- <- punctuation.section.embedded.begin --%> +<%--^^^^^^^^ constant.language.processing-directive --%> +<%-- ^^^^^^^^ entity.other.attribute-name - constant.language.processing-directive --%> +<%-- ^^^^ string.quoted.double --%> + +<%@ Implements Interface="IFooPage" %> +<%--^^^^^^^^^^ constant.language.processing-directive --%> +<%-- ^^^^^^^^^ entity.other.attribute-name --%> +<%-- ^^^^^^^^ entity.other.inherited-class.cs --%> + +<%@ OutputCache Duration="120" VaryByControl="ControlName" NoStore="true" %> +<%--^^^^^^^^^^^ constant.language.processing-directive.caching --%> +<%-- ^^^^^^^^ entity.other.attribute-name --%> +<%-- ^^^ constant.numeric.integer +<%-- ^^^^ constant.language.boolean --%> + +<%@ Foo="bar" %> +<%--^^^ entity.other.attribute-name --%> +<%-- ^^^ string.quoted.double --%> + + +<%-- <- source.cs.embedded.html --%> +<%--^ punctuation.definition.tag.begin.html --%> +<%-- ^^^^^^ entity.name.tag.html --%> +<%-- ^ punctuation.definition.tag.end.html --%> +<%-- ^^^^^^^^^^ - source.cs.embedded.html --%> + + + + + C# HTML + + +<%-- ^^^ - source.js.embedded.html source.cs.embedded.html --%> + + + + + <% if(3 > 10) +<%--^^ punctuation.section.embedded.begin - source.cs --%> +<%-- ^^^^^^^^^^ source.cs.embedded.html --%> + { %> +<%-- ^ punctuation.section.block.begin --%> +<%-- ^^ punctuation.section.embedded.end --%> +<%-- ^^^^^ - source.cs.embedded.html --%> +

Baz

+ <% } else { %> +<%-- ^^^^^^^^^^ source.cs.embedded.html --%> +<%-- ^ punctuation.section.block.end --%> +<%-- ^^^^ keyword.control.conditional.else --%> +<%-- ^ punctuation.section.block.begin --%> +<%-- ^^^ - source.cs.embedded.html --%> +

Biff

+ <% } %> + +

<%: variable %>

+<%-- ^^^ punctuation.section.embedded.begin --%> +<%-- ^^^^^^^^^^ source.cs.embedded.html --%> +<%-- ^^ punctuation.section.embedded.end --%> +<%-- ^^^^^^ - source.cs.embedded.html --%> + + ">link +<%-- ^^^^ entity.other.attribute-name - source.cs --%> +<%-- ^^^ punctuation.section.embedded.begin - source.cs --%> +<%-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded --%> +<%-- ^^^^^^^^^^^^^^^^ string.quoted.double.cs --%> +<%-- ^^^^^ - source.cs --%> + + ]]> +<%-- ^^^ punctuation.section.embedded.begin --%> +<%-- ^^^^^^^^^^ source.cs.embedded.html --%> +<%-- ^^ punctuation.section.embedded.end --%> +<%-- ^^^^^^ - source.cs.embedded.html --%> + +

<%= variable %>

+<%-- ^^^ punctuation.section.embedded.begin --%> +<%-- ^^^^^^^^^^ source.cs.embedded.html --%> +<%-- ^^ punctuation.section.embedded.end --%> +<%-- ^^^^^^ - source.cs.embedded.html --%> + + diff --git a/aspnet.sublime-syntax b/aspnet.sublime-syntax deleted file mode 100644 index 8b70c55..0000000 --- a/aspnet.sublime-syntax +++ /dev/null @@ -1,215 +0,0 @@ -%YAML 1.2 ---- -# http://www.sublimetext.com/docs/3/syntax.html -name: HTML (C#) -file_extensions: - - aspx - - ascx - - asax - - master -scope: embedding.cshtml.aspnet -contexts: - main: - - include: html - - directive-generic-attribute: - - match: \b(\w+)\s*(?:(=)\s*((")[^"]*("))?)?\s* - captures: - 1: entity.other.attribute-name.cshtml - 2: punctuation.separator.key-value.cshtml - 3: string.quoted.double.cshtml - 4: punctuation.definition.string.begin.cshtml - 5: punctuation.definition.string.end.cshtml - - directive-end: - - match: '%>' - scope: punctuation.section.embedded.end.cshtml - pop: true - - directive: - # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx - - match: <%@ - scope: punctuation.section.embedded.begin.cshtml - set: - - meta_scope: meta.block.processing-directive.cshtml - - include: directive-type - - include: directive-import - - include: directive-implements - - include: directive-reference - - include: directive-outputcache - - include: directive-other - # Blank directives are considered to be "Page" or "Control" by .Net - - include: directive-generic-attribute - - include: directive-end - - directive-type: - # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx - - match: \b(?i:Application|Page|Control|Master)\b - scope: constant.language.processing-directive.cshtml entity.name.class.cs - set: - - meta_scope: meta.block.processing-directive.contents.type.cshtml - - include: directive-generic-attribute - - include: directive-end - - directive-import: - # https://msdn.microsoft.com/en-us/library/eb44kack(v=vs.100).aspx - - match: \b(?i:Import)\b - scope: constant.language.processing-directive.cshtml - set: - - meta_scope: meta.block.processing-directive.contents.import.cshtml - - match: \b(?i:(Namespace))\s*(=)\s*((")([^"]*)(")) - captures: - 1: entity.other.attribute-name.cshtml - 2: punctuation.separator.key-value.cshtml - 3: string.quoted.double.cshtml - 4: punctuation.definition.string.begin.cshtml - 5: meta.path.cs - 6: punctuation.definition.string.end.cshtml - - include: directive-end - - directive-implements: - # https://msdn.microsoft.com/en-us/library/cbsf6k72(v=vs.100).aspx - - match: \b(?i:Implements)\b - scope: constant.language.processing-directive.cshtml - set: - - meta_scope: meta.block.processing-directive.contents.implements.cshtml - - match: \b(?i:(Interface))\s*(=)\s*((")([^"]*)(")) - captures: - 1: entity.other.attribute-name.cshtml - 2: punctuation.separator.key-value.cshtml - 3: string.quoted.double.cshtml - 4: punctuation.definition.string.begin.cshtml - 5: entity.other.inherited-class.cs - 6: punctuation.definition.string.end.cshtml - - include: directive-end - - directive-reference: - # https://msdn.microsoft.com/en-us/library/w70c655a(v=vs.100).aspx - - match: \b(?i:Reference)\b - scope: constant.language.processing-directive.reference.cshtml - set: - - meta_scope: meta.block.processing-directive.contents.reference.cshtml - - match: \b(?i:(Page|Control|VirtualPath))\s*(=)\s*((")([^"]*)(")) - captures: - 1: entity.other.attribute-name.cshtml - 2: punctuation.separator.key-value.cshtml - 3: string.quoted.double.cshtml - 4: punctuation.definition.string.begin.cshtml - 5: meta.path.cs - 6: punctuation.definition.string.end.cshtml - - include: directive-end - - directive-outputcache: - # https://msdn.microsoft.com/en-us/library/hdxfb6cy(v=vs.100).aspx - - match: \b(?i:OutputCache)\b - scope: constant.language.processing-directive.caching.cshtml - set: - - meta_scope: meta.block.processing-directive.contents.outputcache.cshtml - - match: \b(?i:(Duration))\s*(=)\s*((")(?:(\d+)|[^"]*)(")) - captures: - 1: entity.other.attribute-name.cshtml - 2: punctuation.separator.key-value.cshtml - 3: string.quoted.double.cshtml - 4: punctuation.definition.string.begin.cshtml - 5: constant.numeric.integer.cshtml - 6: punctuation.definition.string.end.cshtml - - match: \b(?i:(NoStore|Shared))\s*(=)\s*((")(?i:(true|false)|[^"]*)(")) - captures: - 1: entity.other.attribute-name.cshtml - 2: punctuation.separator.key-value.cshtml - 3: string.quoted.double.cshtml - 4: punctuation.definition.string.begin.cshtml - 5: constant.language.boolean.cshtml - 6: punctuation.definition.string.end.cshtml - - match: \b(?i:(Location))\s*(=)\s*((")(?i:(Any|Client|Downstream|Server|None|ServerAndClient)|[^"]*)(")) - captures: - 1: entity.other.attribute-name.cshtml - 2: punctuation.separator.key-value.cshtml - 3: string.quoted.double.cshtml - 4: punctuation.definition.string.begin.cshtml - 5: meta.enum.cache-location.cshtml - 6: punctuation.definition.string.end.cshtml - - match: \b(?i:(CacheProfile|SqlDependency|ProviderName|VaryBy(?:Control|Custom|Header|Param|ContentEncoding)))\s*(=)\s*((")([^"]*)(")) - captures: - 1: entity.other.attribute-name.cshtml - 2: punctuation.separator.key-value.cshtml - 3: string.quoted.double.cshtml - 4: punctuation.definition.string.begin.cshtml - 5: meta.path.cs - 6: punctuation.definition.string.end.cshtml - - include: directive-end - - directive-other: - # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx - - match: \b(Register|Assembly|PreviousPageType|MasterType)\b - scope: constant.language.processing-directive.cshtml - set: - - include: directive-generic-attribute - - include: directive-end - - html: - - match: '' - set: scope:text.html.basic - with_prototype: - - match: <(?=<) - scope: invalid.illegal.cshtml - - include: comments - - include: script-tag-cs - - include: directive - - include: block-cs - - block-cs: - - match: <%[=#:$]? - scope: punctuation.section.embedded.begin.cshtml - embed: inside-block-cs - embed_scope: source.cs.embedded.html - escape: '%>' - escape_captures: - 0: punctuation.section.embedded.end.cshtml - - inside-block-cs: - - match: \} - scope: punctuation.section.block.end.cs - push: - - match: \belse\b - scope: keyword.control.conditional.else.cs - pop: true - - match: (?=\S) - pop: true - - include: scope:source.cs - - script-tag-cs: - - match: (?i)(<)(script)[^>]+(runat)(=)(?:((')server('))|((")server("))) - captures: - 1: punctuation.definition.tag.begin.html - 2: entity.name.tag.script.html - 3: constant.language.processing-directive.cshtml - 4: punctuation.separator.key-value.cshtml - 5: string.quoted.single.cshtml - 6: punctuation.definition.string.begin.cshtml - 7: punctuation.definition.string.end.cshtml - 8: string.quoted.double.cshtml - 9: punctuation.definition.string.begin.cshtml - 10: punctuation.definition.string.end.cshtml - push: - - match: (?i)() - captures: - 1: punctuation.definition.tag.begin.html - 2: entity.name.tag.html - 3: punctuation.definition.tag.end.html - pop: true - - match: '>' - scope: punctuation.definition.tag.end.html - embed: scope:source.cs - embed_scope: source.cs.embedded.html - escape: (?i)(?=' - scope: comment.block.end.cshtml - pop: true diff --git a/cshtml.sublime-settings b/cshtml.sublime-settings index be4aaa6..3f8c8da 100644 --- a/cshtml.sublime-settings +++ b/cshtml.sublime-settings @@ -1,9 +1,9 @@ { - "auto_complete_selector": "embedding.cshtml.aspnet - comment", + "auto_complete_selector": "text.html.cs - comment", "auto_complete_triggers": [ { "characters": "@", - "selector": "embedding.cshtml.razor", + "selector": "text.html.cs.razor", } ] } diff --git a/messaging.json b/messaging.json index c2538a2..a461f14 100644 --- a/messaging.json +++ b/messaging.json @@ -1,4 +1,4 @@ { - "4.0.0": "messages/4.0.0.md", - "3.0.0": "messages/3.0.0.md" + "4.0.0": ".messages/4.0.0.md", + "3.0.0": ".messages/3.0.0.md" } diff --git a/razor.sublime-syntax b/razor.sublime-syntax deleted file mode 100644 index 7fc57fc..0000000 --- a/razor.sublime-syntax +++ /dev/null @@ -1,141 +0,0 @@ -%YAML 1.2 ---- -# http://www.sublimetext.com/docs/3/syntax.html -name: HTML Razor (C#) -file_extensions: - - cshtml -scope: embedding.cshtml.razor -contexts: - main: - - include: html - - html: - - match: '' - set: razor-html - - razor-comments: - - match: '@\*' - scope: punctuation.definition.comment.begin.cshtml - push: - - meta_scope: comment.block.cshtml - - match: '\*@' - scope: punctuation.definition.comment.end.cshtml - pop: true - - razor: - - include: razor-comments - - match: (@)(model)\b - captures: - 1: punctuation.section.embedded.line.cshtml - 2: source.cs.embedded.html keyword.other.cshtml - embed: scope:source.cs - embed_scope: source.cs.embedded.html - escape: $ - - match: (@)(section)\b(?:\s+(\w+))? - captures: - 1: punctuation.section.embedded.line.cshtml - 2: source.cs.embedded.html keyword.other.cshtml - 3: entity.name.section.cshtml - push: - - match: \{ - scope: punctuation.section.block.begin.cshtml - set: - - match: \} - scope: punctuation.section.block.end.cshtml - pop: true - - include: razor-html - - match: (@)(functions)\b - captures: - 1: punctuation.section.embedded.line.cshtml - 2: source.cs.embedded.html keyword.other.cshtml - push: - - match: \{ - scope: punctuation.section.block.begin.cshtml - set: - - clear_scopes: 1 - - meta_scope: source.cs.embedded.functions.cshtml - - match: \} - scope: punctuation.section.block.end.cshtml - pop: true - - include: scope:source.cs#code_block_in - - match: \s*(?!\{)(?=\S) - scope: invalid.illegal.expected-block.cshtml - pop: true - - match: (@)(using)\b(?!\s*\() - captures: - 1: punctuation.section.embedded.line.cshtml - 2: source.cs.embedded.html keyword.other.cshtml - embed: scope:source.cs - embed_scope: source.cs.embedded.html - escape: $ - - match: '@@' - scope: constant.character.escape.cshtml - - match: (@)(?=(?:if|switch|for|foreach|using|try|lock)\b) - captures: - 1: punctuation.section.embedded.cshtml - push: - - clear_scopes: 1 - - meta_content_scope: source.cs.embedded.html - - include: scope:source.cs#line_of_code - - match: '' - pop: true - with_prototype: - - include: razor-block-prototype - - match: '[\w-+]+@\w+' # ignore email addresses - - match: '@(?=(?:\w+\.)*\w+(?:[<\s]|$))' - scope: punctuation.section.embedded.line.cshtml - embed: scope:source.cs#line_of_code_in - embed_scope: source.cs.embedded.html - escape: $|(?=[<\s]) - - match: '@(?=(?:\w+\.)*\w+\()' - scope: punctuation.section.embedded.line.cshtml - push: - - meta_content_scope: source.cs.embedded.html - - match: (?=[<\s]) - pop: true - - include: scope:source.cs#line_of_code_in - - match: '@\(' - scope: punctuation.section.embedded.begin.cshtml - push: - - clear_scopes: 1 - - meta_content_scope: source.cs.embedded.html - - match: \) - scope: punctuation.section.embedded.end.cshtml - pop: true - - include: scope:source.cs#line_of_code_in - #- match: '@(?=\w+(?:\.\w+)*)(?!\s*[+=|(])' # TODO: support a.b[2] etc. - # comment: property/variable access - # scope: punctuation.section.embedded.line.cshtml - # #push: razor-block # TODO: stop at closing " etc. - - match: '@' - scope: punctuation.section.embedded.line.cshtml - push: razor-block - - razor-block-prototype: - - match: (?=[<&]) - embed: scope:text.html.basic - escape: (?=[@}]|$) - - match: '@:' - scope: punctuation.section.embedded.html.cshtml - embed: scope:text.html.basic - escape: $ - - eat-whitespace: - - match: (?=\S) - pop: true - - razor-block: - - clear_scopes: 1 - - meta_content_scope: source.cs.embedded.html - - match: (?=[<\s]) - pop: true - - match: (?=\S)(?!@) - push: - - include: scope:source.cs#line_of_code - with_prototype: - - include: razor-block-prototype - - razor-html: - - meta_content_scope: text.html.basic - - include: razor - - include: scope:text.html.basic diff --git a/tests/syntax_test_aspx.aspx b/tests/syntax_test_aspx.aspx deleted file mode 100644 index 115e687..0000000 --- a/tests/syntax_test_aspx.aspx +++ /dev/null @@ -1,129 +0,0 @@ -// SYNTAX TEST "Packages/HTML (C#)/aspnet.sublime-syntax" - -<%@ Page Debug="true" Title="" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> -// <- punctuation.section.embedded.begin.cshtml -// ^^^^ constant.language.processing-directive.cshtml entity.name.class.cs -// ^^^^^ entity.other.attribute-name.cshtml -// ^ punctuation.separator.key-value.cshtml -// ^^^^^^ string.quoted.double.cshtml -// ^ punctuation.definition.string.begin.cshtml -// ^ punctuation.definition.string.end.cshtml -// ^^^^^ entity.other.attribute-name.cshtml -// ^ punctuation.separator.key-value.cshtml -// ^^ string.quoted.double.cshtml -// ^ punctuation.definition.string.begin.cshtml -// ^ punctuation.definition.string.end.cshtml - -<%@ Import Namespace="System.Net" %> -// <- punctuation.section.embedded.begin.cshtml -// ^^^^^^ constant.language.processing-directive.cshtml -// ^^^^^^^^^ entity.other.attribute-name.cshtml -// ^ punctuation.separator.key-value.cshtml -// ^^^^^^^^^^^^ string.quoted.double.cshtml -// ^ punctuation.definition.string.begin.cshtml -// ^^^^^^^^^^ meta.path.cs -// ^ punctuation.definition.string.end.cshtml -// ^^ punctuation.section.embedded.end.cshtml - -<%@ Register TagPrefix="my" Namespace="Foo.Bar" Assembly="Solution.LinkLibrary" %> -// <- punctuation.section.embedded.begin.cshtml -// ^^^^^^^^ constant.language.processing-directive.cshtml -// ^^^^^^^^ entity.other.attribute-name.cshtml - constant.language.processing-directive.cshtml -// ^^^^ string.quoted.double.cshtml - -<%@ Implements Interface="IFooPage" %> -// ^^^^^^^^^^ constant.language.processing-directive.cshtml -// ^^^^^^^^^ entity.other.attribute-name.cshtml -// ^^^^^^^^ entity.other.inherited-class.cs - -<%@ OutputCache Duration="120" VaryByControl="ControlName" NoStore="true" %> -// ^^^^^^^^^^^ constant.language.processing-directive.caching.cshtml -// ^^^^^^^^ entity.other.attribute-name.cshtml -// ^^^ constant.numeric.integer.cshtml -// ^^^^ constant.language.boolean.cshtml - -<%@ Foo="bar" %> -// ^^^ entity.other.attribute-name.cshtml -// ^^^ string.quoted.double.cshtml - - -// <- source.cs.embedded.html -// ^^ punctuation.definition.tag.begin.html -// ^^^^^^ entity.name.tag.html -// ^ punctuation.definition.tag.end.html -// ^^^^^^^^^^ - source.cs.embedded.html - - - - - C# HTML - - - // ^^^ - source.js.embedded.html source.cs.embedded.html - - - - - <% if(3 > 10) - // <- punctuation.section.embedded.begin.cshtml - source.cs.embedded.html - // ^^^^^^^^^^ source.cs.embedded.html - { %> - // ^ punctuation.section.block.begin - // ^^ punctuation.section.embedded.end.cshtml - // ^^^^^ - source.cs.embedded.html -

Baz

- <% } %> - //^^^ source.cs.embedded.html - // ^ punctuation.section.block.end - // ^^^ - source.cs.embedded.html - - ">link - // ^^^^ entity.other.attribute-name.html - source.cs.embedded.html - // ^^^ punctuation.section.embedded.begin.cshtml - source.cs.embedded.html - // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html - // ^^^^^^^^^^^^^^^^ string.quoted.double.cs - // ^^^^^ - source.cs.embedded.html - -

<%= variable %>

- // ^^^ punctuation.section.embedded.begin.cshtml - // ^^^^^^^^^^ source.cs.embedded.html - // ^^ punctuation.section.embedded.end.cshtml - // ^^^^^^ - source.cs.embedded.html - - diff --git a/webforms.py b/webforms.py new file mode 100644 index 0000000..1bfc78d --- /dev/null +++ b/webforms.py @@ -0,0 +1,35 @@ +import sublime +import sublime_plugin +from re import search +from os.path import isfile + + +class OpenCodeFileFromFrontEndCommand(sublime_plugin.TextCommand): + """Open foo.ascx.cs from foo.ascx""" + + def is_enabled(self): + if ((self.view.match_selector(0, 'text.html.cs.webforms') + and self.view.find_by_selector('meta.path.codefile'))): + return True + return False + + def run(self, edit): + region = self.view.find_by_selector('meta.path.codefile')[0] + codefile = self.view.substr(region) + self.view.window().open_file(str(codefile)) + + +class OpenFrontEndFromCodeFileCommand(sublime_plugin.TextCommand): + """Naively open foo.ascx from foo.ascx.cs""" + + def is_enabled(self): + filename = self.view.file_name() + if ((filename + and self.view.match_selector(0, 'source.cs') + and search(r'\.(?:as[pc]x|master)\.cs$', filename) + and isfile(filename[:-3]))): + return True + return False + + def run(self, edit): + self.view.window().open_file(self.view.file_name()[:-3])