@@ -13,29 +13,6 @@ patterns:
1313- include : ' #special'
1414
1515repository :
16- arrow-function :
17- patterns :
18- - name : arrow.function.js
19- patterns :
20- # e.g. (args) =>
21- - name : storage.type.function.arrow.js
22- match : |-
23- (?x)
24- \s*
25- (
26- (?:
27- (\() (.*?)? (\)))|
28- ([_$a-zA-Z][_$\w]*
29- )
30- )\s*(=>)
31- captures :
32- ' 1 ' : {name: entity.arrow.function.js}
33- ' 2 ' : {name: punctuation.definition.parameters.begin.js}
34- ' 3 ' : {name: variable.parameter.function.arrow.js}
35- ' 4 ' : {name: punctuation.definition.parameters.end.js}
36- ' 5 ' : {name: variable.parameter.function.arrow.js}
37- ' 6 ' : {name: punctuation.definition.arrow.js}
38-
3916 brackets :
4017 patterns :
4118 - name : meta.function-call.method.with-arguments.js
@@ -94,6 +71,23 @@ repository:
9471 ' 0 ' : {name: punctuation.definition.comment.html.js}
9572 ' 2 ' : {name: punctuation.definition.comment.html.js}
9673
74+ function-constructor-parameters :
75+ patterns :
76+ - begin : (\()
77+ beginCaptures :
78+ ' 1 ' : {name: punctuation.definition.parameters.begin.js}
79+ end : (\))
80+ endCaptures :
81+ ' 1 ' : {name: punctuation.definition.parameters.end.js}
82+ patterns :
83+ - name : variable.parameter.function.js
84+ match : |-
85+ (?x)
86+ [_$a-zA-Z][_$\w]*
87+ - name : punctuation.separator.parameter.function.js
88+ match : ' ,'
89+ - include : ' #comments'
90+
9791 core :
9892 patterns :
9993 - include : ' #leading-space'
@@ -107,7 +101,7 @@ repository:
107101
108102 - include : ' #literal-keywords'
109103
110- - include : ' #arrow-function'
104+ - include : ' #literal- arrow-function-constructor '
111105
112106 - include : ' #literal-class'
113107 - include : ' #literal-module'
@@ -158,13 +152,13 @@ repository:
158152
159153 # getter/setter
160154 - name : meta.accessor.js
161- match : \b([gs]et \s*) \b([_$a-zA-Z][_$\w]*)\s*(\()(.*?)(\))
162- captures :
155+ begin : \b(get|set) \s*\b([_$a-zA-Z][_$\w]*)\s*
156+ beginCaptures :
163157 ' 1 ' : {name: storage.type.accessor.js}
164158 ' 2 ' : {name: entity.name.accessor.js}
165- ' 3 ' : {name: punctuation.definition.parameters.begin.js}
166- ' 4 ' : {name: variable.parameter.accessor.js}
167- ' 5 ' : {name: punctuation.definition. parameters.end.js}
159+ end : (?<=\))
160+ patterns :
161+ - include : ' #function-constructor- parameters'
168162
169163 literal-function-call :
170164 patterns :
@@ -193,61 +187,53 @@ repository:
193187
194188 literal-function-constructor :
195189 patterns :
196- # e.g. function myFunc(arg ) { }
190+ # e.g. function play(arg1, arg2 ) { }
197191 - name : meta.function.js
198- match : \b(function\*?)(?:\s+([a-zA-Z_$][_$\w]*))?\s*(\()(.*?)(\))
199- captures :
192+ begin : \b(function\*?)(?:\s+([a-zA-Z_$][_$\w]*))?\s*
193+ beginCaptures :
200194 ' 1 ' : {name: storage.type.function.js}
201195 ' 2 ' : {name: entity.name.function.js}
202- ' 3 ' : {name: punctuation.definition.parameters.begin.js}
203- ' 4 ' : {name: variable.parameter.function.js}
204- ' 5 ' : {name: punctuation.definition. parameters.end.js}
196+ end : (?<=\))
197+ patterns :
198+ - include : ' #function-constructor- parameters'
205199
206- # e.g. Sound.prototype.play = function() { }
200+ # e.g. Sound.prototype.play = function(arg1, arg2 ) { }
207201 - name : meta.prototype.function.js
208- match : ([_$a-zA-Z][_$\w]*)\.(prototype)\.([_$a-zA-Z][_$\w]*)\s*=\s*(function\*?)?\s*(\()(.*?)(\))
209- captures :
202+ begin : ([_$a-zA-Z][_$\w]*)\.(prototype)\.([_$a-zA-Z][_$\w]*)\s*=\s*(function\*?)?\s*
203+ beginCaptures :
210204 ' 1 ' : {name: entity.name.class.js}
211205 ' 2 ' : {name: support.constant.js}
212206 ' 3 ' : {name: entity.name.function.js}
213207 ' 4 ' : {name: storage.type.function.js}
214- ' 5 ' : {name: punctuation.definition.parameters.begin.js}
215- ' 6 ' : {name: variable.parameter.function.js}
216- ' 7 ' : {name: punctuation.definition.parameters.end.js}
217-
218- # e.g. Sound.prototype.play = myfunc
219- - name : meta.function.js
220- match : ([_$a-zA-Z][_$\w]*)\.(prototype)\.([_$a-zA-Z][_$\w]*)\s*=\s*
221- captures :
222- ' 1 ' : {name: entity.name.class.js}
223- ' 2 ' : {name: support.constant.js}
224- ' 3 ' : {name: entity.name.function.js}
208+ end : (?<=\))
209+ patterns :
210+ - include : ' #function-constructor-parameters'
225211
226- # e.g. .play = function() { }
212+ # e.g. .play = function(arg1, arg2 ) { }
227213 - name : meta.function.js
228- match : \.([_$a-zA-Z][_$\w]*)\s*=\s*(function\*?)( [_$a-zA-Z][_$\w]*)?\s*(\()(.*?)(\))
214+ match : \.([_$a-zA-Z][_$\w]*)\s*=\s*(function\*?)( [_$a-zA-Z][_$\w]*)?\s*
229215 captures :
230216 ' 1 ' : {name: entity.name.function.js}
231217 ' 2 ' : {name: storage.type.function.js}
232218 ' 3 ' : {name: entity.name.function.js}
233- ' 4 ' : {name: punctuation.definition.parameters.begin.js}
234- ' 5 ' : {name: variable.parameter.function.js}
235- ' 6 ' : {name: punctuation.definition. parameters.end.js}
219+ end : (?<=\))
220+ patterns :
221+ - include : ' #function-constructor- parameters'
236222
237- # e.g. foobar : function() { }
223+ # e.g. play : function(arg1, arg2 ) { }
238224 - name : meta.function.json.js
239- match : \b([_$a-zA-Z][_$\w]*)\s*(:)\s*\b(function\*?)?\s*(\()(.*?)(\))
225+ match : \b([_$a-zA-Z][_$\w]*)\s*(:)\s*\b(function\*?)?\s*
240226 captures :
241227 ' 1 ' : {name: entity.name.function.js}
242228 ' 2 ' : {name: punctuation.separator.key-value.js}
243229 ' 3 ' : {name: storage.type.function.js}
244- ' 4 ' : {name: punctuation.definition.parameters.begin.js}
245- ' 5 ' : {name: variable.parameter.function.js}
246- ' 6 ' : {name: punctuation.definition. parameters.end.js}
230+ end : (?<=\))
231+ patterns :
232+ - include : ' #function-constructor- parameters'
247233
248- # e.g. "foo ": function
234+ # e.g. "play ": function(arg1, arg2) { }
249235 - name : meta.function.json.js
250- match : (?:((')(.*?)('))|((")(.*?)(")))\s*(:)\s*\b(function\*?)?\s*(\()(.*?)(\))
236+ match : (?:((')(.*?)('))|((")(.*?)(")))\s*(:)\s*\b(function\*?)?\s*
251237 captures :
252238 ' 1 ' : {name: string.quoted.single.js}
253239 ' 2 ' : {name: punctuation.definition.string.begin.js}
@@ -259,9 +245,24 @@ repository:
259245 ' 8 ' : {name: punctuation.definition.string.end.js}
260246 ' 9 ' : {name: punctuation.separator.key-value.js}
261247 ' 10 ' : {name: storage.type.function.js}
262- ' 11 ' : {name: punctuation.definition.parameters.begin.js}
263- ' 12 ' : {name: variable.parameter.function.js}
264- ' 13 ' : {name: punctuation.definition.parameters.end.js}
248+ end : (?<=\))
249+ patterns :
250+ - include : ' #function-constructor-parameters'
251+
252+ literal-arrow-function-constructor :
253+ patterns :
254+ - name : arrow.function.js
255+ patterns :
256+ # e.g. (args) =>
257+ - name : storage.type.function.arrow.js
258+ begin : |-
259+ (?x)
260+ (?=\([^)]+\)\s*(=>))
261+ end : (?<=\))\s*(=>)
262+ endCaptures :
263+ ' 1 ' : {name: punctuation.definition.arrow.js}
264+ patterns :
265+ - include : ' #function-constructor-parameters'
265266
266267 literal-method :
267268 patterns :
@@ -285,23 +286,20 @@ repository:
285286 ' 2 ' : {name: meta.group.braces.round.function.arguments.js}
286287 ' 3 ' : {name: meta.brace.round.js}
287288
288- # ES6 methods, e.g. abc(x, y, z){
289+ # ES6 methods, e.g. play(arg1, arg2) { }
289290 - name : meta.method.js
290- match : |-
291+ begin : |-
291292 (?x)
292293 (?<![_$\w])
293294 (?<!function\s) # An approximation due to fixed width look-behind, but usually good enough
294295 ([_$a-zA-Z][_$\w]*)
295- (\()
296- (?:\s*([^()]*?))?\s*
297- (\))
298296 \s*
299- (?={)
300- captures :
297+ (?=\([^)]+\)\s*\ {)
298+ beginCaptures :
301299 ' 1 ' : {name: entity.name.method.js}
302- ' 2 ' : {name: punctuation.definition.parameters.begin.js}
303- ' 3 ' : {name: variable.parameter.method.js}
304- ' 4 ' : {name: punctuation.definition. parameters.end.js}
300+ end : (?<=\))
301+ patterns :
302+ - include : ' #function-constructor- parameters'
305303
306304 literal-keywords :
307305 patterns :
0 commit comments