Skip to content

Commit df47e78

Browse files
Michael Lyonsmichaelblyons
authored andcommitted
Open CodeBehind/CodeFile from WebForms front end
foo.ascx to foo.ascx.cs
1 parent d7c72c5 commit df47e78

6 files changed

Lines changed: 36 additions & 0 deletions

File tree

WebForms/WebForms.sublime-commands

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
{
3+
"caption": "C# WebForms: Open CodeBehind/CodeFile",
4+
"command": "open_code_file_from_front_end",
5+
},
6+
]

WebForms/WebForms.sublime-syntax

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ contexts:
6161
4: punctuation.definition.string.begin.cs-webforms
6262
5: punctuation.definition.string.end.cs-webforms
6363

64+
directive-codefile-attribute:
65+
- match: \b(CodeBehind|CodeFile)\s*(?:(=)\s*((")([^"]*)("))?)?\s*
66+
captures:
67+
1: entity.other.attribute-name.cs-webforms
68+
2: punctuation.separator.key-value.cs-webforms
69+
3: string.quoted.double.cs-webforms
70+
4: punctuation.definition.string.begin.cs-webforms
71+
5: meta.path.codefile.cs-webforms
72+
6: punctuation.definition.string.end.cs-webforms
73+
6474
directive-end:
6575
- match: '{{csharp_tag_end}}'
6676
scope: punctuation.section.embedded.end.cs-webforms

WebForms/ascx.sublime-syntax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ contexts:
1919
scope: constant.language.processing-directive.cs-webforms entity.name.class.cs
2020
set:
2121
- meta_scope: meta.block.processing-directive.contents.type.cs-webforms
22+
- include: directive-codefile-attribute
2223
- include: directive-generic-attribute
2324
- include: directive-end

WebForms/aspx.sublime-syntax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ contexts:
1919
scope: constant.language.processing-directive.cs-webforms entity.name.class.cs
2020
set:
2121
- meta_scope: meta.block.processing-directive.contents.type.cs-webforms
22+
- include: directive-codefile-attribute
2223
- include: directive-generic-attribute
2324
- include: directive-end

WebForms/master.sublime-syntax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ contexts:
1919
scope: constant.language.processing-directive.cs-webforms entity.name.class.cs
2020
set:
2121
- meta_scope: meta.block.processing-directive.contents.type.cs-webforms
22+
- include: directive-codefile-attribute
2223
- include: directive-generic-attribute
2324
- include: directive-end

webforms.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sublime
2+
import sublime_plugin
3+
4+
5+
class OpenCodeFileFromFrontEndCommand(sublime_plugin.TextCommand):
6+
"""Open foo.ascx.cs from foo.ascx"""
7+
8+
def is_enabled(self):
9+
if ((self.view.match_selector(0, 'text.html.cs.webforms')
10+
and self.view.find_by_selector('meta.path.codefile'))):
11+
return True
12+
return False
13+
14+
def run(self, edit):
15+
region = self.view.find_by_selector('meta.path.codefile')[0]
16+
codefile = self.view.substr(region)
17+
self.view.window().open_file(str(codefile))

0 commit comments

Comments
 (0)