Skip to content

Commit d171982

Browse files
WliuWliu
authored andcommitted
Welcome back JavaScript
1 parent 43eaf17 commit d171982

File tree

2 files changed

+682
-244
lines changed

2 files changed

+682
-244
lines changed

grammars/jsdoc.cson

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@
102102
'2':
103103
'name': 'punctuation.definition.bracket.angle.end.jsdoc'
104104
}
105+
{
106+
# Highlighted JavaScript example
107+
'match': '[^\\s@*](?:[^*]|\\*[^/])*'
108+
'captures':
109+
'0':
110+
'name': 'source.embedded.js'
111+
'patterns': [
112+
{
113+
'include': 'source.js'
114+
}
115+
]
116+
}
105117
]
106118
}
107119
{
@@ -248,23 +260,50 @@
248260
'name': 'variable.other.jsdoc'
249261
}
250262
{
263+
# Optional value
251264
'name': 'variable.other.jsdoc'
252-
'begin': '\\['
253-
'end': '\\](?=\\s*([\\w-]|$|\\*/))|(?=\\*/)'
254-
'patterns': [
255-
{
256-
'begin': '='
257-
'beginCaptures':
258-
'0':
259-
'name': 'keyword.operator.assignment.jsdoc'
260-
'end': '(?=(\\]\\s*([\\w-]|$|\\*/))|\\*/)'
265+
'match': '''(?x)
266+
(\\[)\\s*
267+
[\\w$]+
268+
(?:
269+
(?:\\[\\])? # Foo[].bar properties within an array
270+
\\. # Foo.Bar namespaced parameter
271+
[\\w$]+
272+
)*
273+
(?:
274+
\\s*
275+
(=) # [foo=bar] Default parameter value
276+
\\s*
277+
(
278+
(?:
279+
"(?:(?:\\*(?!/))|(?:\\\\(?!"))|[^*\\\\])*?" | # [foo="bar"] Double-quoted
280+
'(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted
281+
\\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal
282+
(?:(?:\\*(?!/))|[^*])*? # Everything else, but stop the match early at */
283+
)*
284+
)
285+
)?
286+
\\s*(?:(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/))
287+
'''
288+
'captures':
289+
'1':
290+
'name': 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'
291+
'2':
292+
'name': 'keyword.operator.assignment.jsdoc'
293+
'3':
294+
'name': 'source.embedded.js'
261295
'patterns': [
262296
{
263297
'include': '#inline-tags'
264298
}
299+
{
300+
'include': 'source.js'
301+
}
265302
]
266-
}
267-
]
303+
'4':
304+
'name': 'punctuation.definition.optional-value.end.bracket.square.jsdoc'
305+
'5':
306+
'name': 'invalid.illegal.syntax.jsdoc'
268307
}
269308
]
270309
}

0 commit comments

Comments
 (0)