Skip to content

Commit e5761cd

Browse files
committed
chore(grammar) move important rules to top
1 parent 2edfc59 commit e5761cd

File tree

1 file changed

+76
-64
lines changed

1 file changed

+76
-64
lines changed

grammars/typescript.cson

Lines changed: 76 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,81 @@
88
'name': 'TypeScript'
99

1010
'patterns': [
11+
12+
####
13+
# Rules that no one should change
14+
# These are used by code to provide fancy completions
15+
####
16+
17+
{
18+
'comment': 'Match debugger statement'
19+
'match': '\\s*(debugger)[\\s;]+'
20+
'captures':
21+
'1':
22+
'name':'keyword.debugger.ts'
23+
}
24+
{
25+
'comment': 'Match full triple slash reference comments'
26+
'match': '(\\/\\/\\/\\s*<reference\\s*path\\s*=)(.*)(\\/>)'
27+
'captures':
28+
'1':
29+
'name':'keyword.other.ts'
30+
'2':
31+
'name':'reference.path.string'
32+
'3':
33+
'name':'keyword.other.ts'
34+
}
35+
{
36+
'comment': 'Match <amd-dependency'
37+
'match': '(\\/\\/\\/\\s*<amd-dependency\\s*path\\s*=)(.*)(\\/>)'
38+
'captures':
39+
'1':
40+
'name':'keyword.other.ts'
41+
'2':
42+
'name':'amd.path.string'
43+
'3':
44+
'name':'keyword.other.ts'
45+
}
46+
{
47+
'comment': 'Match <amd-module'
48+
'match': '(\\/\\/\\/\\s*<amd-module\\s*name\\s*=)(.*)(\\/>)'
49+
'captures':
50+
'1':
51+
'name':'keyword.other.ts'
52+
'2':
53+
'name':'amd.path.string'
54+
'3':
55+
'name':'keyword.other.ts'
56+
}
57+
{
58+
'comment': 'Match import = require'
59+
'match': '(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)?\\s*=\\s*(require)\\s*\\((.*)\\)'
60+
'captures':
61+
'1':
62+
'name':'keyword.other.ts'
63+
'2':
64+
'name':'variable.type.ts'
65+
'3':
66+
'name':'keyword.other.ts'
67+
'4':
68+
'name':'require.path.string'
69+
}
70+
{
71+
'comment': 'Match ES6 "import from" syntax'
72+
'match': '(import).*(from)\\s*(.*[\'"])'
73+
'captures':
74+
'1':
75+
'name':'keyword.other.ts'
76+
'2':
77+
'name':'keyword.other.ts'
78+
'3':
79+
'name':'es6import.path.string'
80+
}
81+
82+
###
83+
# Other rules
84+
###
85+
1186
{
1287
'comment': 'Match stuff like: namespace name {...}'
1388
'match': '(?:^|(;)|\\s)(module|namespace)\\s+([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*'
@@ -561,70 +636,7 @@
561636
}
562637
]
563638
}
564-
{
565-
'comment': 'Match debugger statement'
566-
'match': '\\s*(debugger)[\\s;]+'
567-
'captures':
568-
'1':
569-
'name':'keyword.debugger.ts'
570-
}
571-
{
572-
'comment': 'Match full triple slash reference comments'
573-
'match': '(\\/\\/\\/\\s*<reference\\s*path\\s*=)(.*)(\\/>)'
574-
'captures':
575-
'1':
576-
'name':'keyword.other.ts'
577-
'2':
578-
'name':'reference.path.string'
579-
'3':
580-
'name':'keyword.other.ts'
581-
}
582-
{
583-
'comment': 'Match <amd-dependency'
584-
'match': '(\\/\\/\\/\\s*<amd-dependency\\s*path\\s*=)(.*)(\\/>)'
585-
'captures':
586-
'1':
587-
'name':'keyword.other.ts'
588-
'2':
589-
'name':'amd.path.string'
590-
'3':
591-
'name':'keyword.other.ts'
592-
}
593-
{
594-
'comment': 'Match <amd-module'
595-
'match': '(\\/\\/\\/\\s*<amd-module\\s*name\\s*=)(.*)(\\/>)'
596-
'captures':
597-
'1':
598-
'name':'keyword.other.ts'
599-
'2':
600-
'name':'amd.path.string'
601-
'3':
602-
'name':'keyword.other.ts'
603-
}
604-
{
605-
'comment': 'Match import = require'
606-
'match': '(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)?\\s*=\\s*(require)\\s*\\((.*)\\)'
607-
'captures':
608-
'1':
609-
'name':'keyword.other.ts'
610-
'2':
611-
'name':'variable.type.ts'
612-
'3':
613-
'name':'keyword.other.ts'
614-
'4':
615-
'name':'require.path.string'
616-
}
617-
{
618-
'comment': 'Match ES6 "import from" syntax'
619-
'match': '(import).*(from)\\s*(.*[\'"])'
620-
'captures':
621-
'1':
622-
'name':'keyword.other.ts'
623-
'2':
624-
'name':'keyword.other.ts'
625-
'3':
626-
'name':'es6import.path.string'
627-
}
639+
628640
{
629641
'include': '#curlybracerecursion'
630642
}

0 commit comments

Comments
 (0)