Skip to content

Commit b782205

Browse files
committed
Fixing scope and color of word constructor
1 parent 98fef6c commit b782205

File tree

7 files changed

+81
-22
lines changed

7 files changed

+81
-22
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,16 @@ repository:
154154

155155
method-declaration:
156156
name: meta.method.declaration.ts
157-
begin: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
157+
begin: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
158158
beginCaptures:
159159
'1': { name: storage.modifier.ts }
160160
'2': { name: storage.modifier.ts }
161161
'3': { name: storage.modifier.ts }
162162
'4': { name: storage.type.property.ts }
163163
'5': { name: keyword.operator.ts }
164-
'6': { name: entity.name.function.ts }
165-
'7': { name: keyword.operator.ts }
164+
'6': { name: support.type.ts }
165+
'7': { name: entity.name.function.ts }
166+
'8': { name: keyword.operator.ts }
166167
end: '(?=\}|;|,)|(?<=\})'
167168
patterns:
168169
- include: '#comment'
@@ -174,15 +175,16 @@ repository:
174175

175176
method-overload-declaration:
176177
name: meta.method.overload.declaration.ts
177-
match: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
178+
match: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
178179
captures:
179180
'1': { name: storage.modifier.ts }
180181
'2': { name: storage.modifier.ts }
181182
'3': { name: storage.modifier.ts }
182183
'4': { name: storage.type.property.ts }
183184
'5': { name: keyword.operator.ts }
184-
'6': { name: entity.name.function.ts }
185-
'7': { name: keyword.operator.ts }
185+
'6': { name: support.type.ts }
186+
'7': { name: entity.name.function.ts }
187+
'8': { name: keyword.operator.ts }
186188

187189
indexer-declaration:
188190
name: meta.indexer.declaration.ts

TypeScript.tmLanguage

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@
711711
<key>method-declaration</key>
712712
<dict>
713713
<key>begin</key>
714-
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
714+
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
715715
<key>beginCaptures</key>
716716
<dict>
717717
<key>1</key>
@@ -742,9 +742,14 @@
742742
<key>6</key>
743743
<dict>
744744
<key>name</key>
745-
<string>entity.name.function.ts</string>
745+
<string>support.type.ts</string>
746746
</dict>
747747
<key>7</key>
748+
<dict>
749+
<key>name</key>
750+
<string>entity.name.function.ts</string>
751+
</dict>
752+
<key>8</key>
748753
<dict>
749754
<key>name</key>
750755
<string>keyword.operator.ts</string>
@@ -814,16 +819,21 @@
814819
<key>6</key>
815820
<dict>
816821
<key>name</key>
817-
<string>entity.name.function.ts</string>
822+
<string>support.type.ts</string>
818823
</dict>
819824
<key>7</key>
825+
<dict>
826+
<key>name</key>
827+
<string>entity.name.function.ts</string>
828+
</dict>
829+
<key>8</key>
820830
<dict>
821831
<key>name</key>
822832
<string>keyword.operator.ts</string>
823833
</dict>
824834
</dict>
825835
<key>match</key>
826-
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
836+
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
827837
<key>name</key>
828838
<string>meta.method.overload.declaration.ts</string>
829839
</dict>

TypeScriptReact.YAML-tmLanguage

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,16 @@ repository:
156156

157157
method-declaration:
158158
name: meta.method.declaration.tsx
159-
begin: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
159+
begin: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
160160
beginCaptures:
161161
'1': { name: storage.modifier.tsx }
162162
'2': { name: storage.modifier.tsx }
163163
'3': { name: storage.modifier.tsx }
164164
'4': { name: storage.type.property.tsx }
165165
'5': { name: keyword.operator.tsx }
166-
'6': { name: entity.name.function.tsx }
167-
'7': { name: keyword.operator.tsx }
166+
'6': { name: support.type.tsx }
167+
'7': { name: entity.name.function.tsx }
168+
'8': { name: keyword.operator.tsx }
168169
end: '(?=\}|;|,)|(?<=\})'
169170
patterns:
170171
- include: '#comment'
@@ -176,15 +177,16 @@ repository:
176177

177178
method-overload-declaration:
178179
name: meta.method.overload.declaration.tsx
179-
match: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
180+
match: '\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\<)'
180181
captures:
181182
'1': { name: storage.modifier.tsx }
182183
'2': { name: storage.modifier.tsx }
183184
'3': { name: storage.modifier.tsx }
184185
'4': { name: storage.type.property.tsx }
185186
'5': { name: keyword.operator.tsx }
186-
'6': { name: entity.name.function.tsx }
187-
'7': { name: keyword.operator.tsx }
187+
'6': { name: support.type.tsx }
188+
'7': { name: entity.name.function.tsx }
189+
'8': { name: keyword.operator.tsx }
188190

189191
indexer-declaration:
190192
name: meta.indexer.declaration.tsx

TypeScriptReact.tmLanguage

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@
10771077
<key>method-declaration</key>
10781078
<dict>
10791079
<key>begin</key>
1080-
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
1080+
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
10811081
<key>beginCaptures</key>
10821082
<dict>
10831083
<key>1</key>
@@ -1108,9 +1108,14 @@
11081108
<key>6</key>
11091109
<dict>
11101110
<key>name</key>
1111-
<string>entity.name.function.tsx</string>
1111+
<string>support.type.tsx</string>
11121112
</dict>
11131113
<key>7</key>
1114+
<dict>
1115+
<key>name</key>
1116+
<string>entity.name.function.tsx</string>
1117+
</dict>
1118+
<key>8</key>
11141119
<dict>
11151120
<key>name</key>
11161121
<string>keyword.operator.tsx</string>
@@ -1180,16 +1185,21 @@
11801185
<key>6</key>
11811186
<dict>
11821187
<key>name</key>
1183-
<string>entity.name.function.tsx</string>
1188+
<string>support.type.tsx</string>
11841189
</dict>
11851190
<key>7</key>
1191+
<dict>
1192+
<key>name</key>
1193+
<string>entity.name.function.tsx</string>
1194+
</dict>
1195+
<key>8</key>
11861196
<dict>
11871197
<key>name</key>
11881198
<string>keyword.operator.tsx</string>
11891199
</dict>
11901200
</dict>
11911201
<key>match</key>
1192-
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
1202+
<string>\b(?:(abstract)\s+)?\b(?:(public|private|protected)\s+)?\b(?:(async)\s+)?(?:(get|set)\s+)?(?:(new)|(?:\b(constructor)\b)|(?:([a-zA-Z_$][\.\w$]*)\s*(\??)))?\s*(?=\(|\&lt;)</string>
11931203
<key>name</key>
11941204
<string>meta.method.overload.declaration.tsx</string>
11951205
</dict>

tests/baselines/Issue191.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[2, 5]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts entity.name.function.ts
1+
[2, 5]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts support.type.ts
22
[2, 17]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts parameter.name.ts storage.modifier.ts
33
[2, 24]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts parameter.name.ts variable.parameter.ts
44
[2, 33]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts meta.type.annotation.ts meta.type.primitive.ts storage.type.ts
@@ -15,7 +15,7 @@
1515
[6, 60]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.decl.block.ts meta.block.ts meta.brace.paren.ts
1616
[11, 13]: source.ts meta.declaration.object.ts meta.type.parameters.ts meta.type.name.ts
1717
[11, 16]: source.ts meta.declaration.object.ts meta.type.parameters.ts meta.type.name.ts
18-
[12, 5]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts entity.name.function.ts
18+
[12, 5]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts support.type.ts
1919
[12, 17]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts parameter.name.ts storage.modifier.ts
2020
[12, 24]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts parameter.name.ts variable.parameter.ts
2121
[12, 33]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts meta.type.annotation.ts meta.type.primitive.ts storage.type.ts

tests/baselines/Issue32.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[5, 1]: source.ts meta.declaration.object.ts storage.type.ts
2+
[5, 11]: source.ts meta.declaration.object.ts meta.object.name.ts entity.name.class.ts
3+
[6, 2]: source.ts meta.declaration.object.ts meta.object.body.ts meta.field.declaration.ts variable.ts
4+
[7, 2]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts entity.name.function.ts
5+
[11, 1]: source.ts meta.declaration.object.ts storage.type.ts
6+
[12, 2]: source.ts meta.declaration.object.ts meta.object.body.ts meta.field.declaration.ts variable.ts
7+
[13, 2]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts entity.name.function.ts
8+
[14, 3]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.decl.block.ts constant.language.this.ts
9+
[16, 2]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts support.type.ts
10+
[16, 14]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts parameter.name.ts variable.parameter.ts
11+
[16, 17]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts meta.type.annotation.ts meta.type.primitive.ts storage.type.ts
12+
[16, 25]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts parameter.name.ts variable.parameter.ts
13+
[16, 28]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.function.type.parameter.ts meta.type.annotation.ts meta.type.primitive.ts storage.type.ts
14+
[18, 1]: source.ts

tests/cases/Issue32.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Testing Isuue 32: Adding constructor as a support.type keword
3+
*/
4+
5+
^^interface ^^NewInterface{
6+
^^currentData: Data;
7+
^^setVal(d: Data)
8+
}
9+
10+
11+
^^class NewClass implements NewInterface {
12+
^^currentData: Data;
13+
^^setVal(d: Data){
14+
^^this.currentData = d;
15+
}
16+
^^constructor(^^m: ^^number, ^^n: ^^string){}
17+
}
18+
^^
19+
/*
20+
Testing comments
21+
*/

0 commit comments

Comments
 (0)