Skip to content

Commit f92d6a4

Browse files
mszabo-wikiaClaude
andauthored
feat: add delay keyword to syntax highlighting (#272)
The upcoming Hack `delay` keyword is syntactically identical to `await`. Add it to the control keyword grammar pattern and include a snapshot test. Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent c6b14a2 commit f92d6a4

3 files changed

Lines changed: 67 additions & 1 deletion

File tree

syntaxes/hack.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@
988988
"name": "keyword.control.php"
989989
}
990990
},
991-
"match": "\\s*\\b(await|break|c(ase|ontinue)|concurrent|default|do|else|for(each)?|if|nameof|return|switch|use|while)\\b"
991+
"match": "\\s*\\b(await|break|c(ase|ontinue)|concurrent|de(fault|lay)|do|else|for(each)?|if|nameof|return|switch|use|while)\\b"
992992
},
993993
{
994994
"begin": "(?i)\\b((?:require|include)(?:_once)?)\\b\\s*",

test/grammar/delay.hack

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
async function gen_foo(): Awaitable<int> {
2+
return 1;
3+
}
4+
5+
async function gen_bar(): Awaitable<void> {
6+
$x = delay gen_foo();
7+
}

test/grammar/delay.hack.snap

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SYNTAX TEST "source.hack" "autogenerated snapshot test"
2+
>async function gen_foo(): Awaitable<int> {
3+
#^^^^^ source.hack meta.function.php storage.modifier.php
4+
# ^ source.hack meta.function.php
5+
# ^^^^^^^^ source.hack meta.function.php storage.type.function.php
6+
# ^ source.hack meta.function.php
7+
# ^^^^^^^ source.hack meta.function.php entity.name.function.php
8+
# ^ source.hack meta.function.php punctuation.definition.parameters.begin.php
9+
# ^ source.hack meta.function.php punctuation.definition.parameters.end.php
10+
# ^ source.hack meta.function.php punctuation.definition.type.php
11+
# ^ source.hack meta.function.php
12+
# ^^^^^^^^^ source.hack meta.function.php support.class.php
13+
# ^ source.hack meta.function.php
14+
# ^^^ source.hack meta.function.php support.type.php
15+
# ^ source.hack meta.function.php
16+
# ^ source.hack meta.function.php
17+
# ^ source.hack punctuation.section.scope.begin.php
18+
> return 1;
19+
#^^ source.hack
20+
# ^^^^^^ source.hack keyword.control.php
21+
# ^ source.hack
22+
# ^ source.hack constant.numeric.php
23+
# ^ source.hack punctuation.terminator.expression.php
24+
>}
25+
#^ source.hack punctuation.section.scope.end.php
26+
>
27+
#^ source.hack
28+
>async function gen_bar(): Awaitable<void> {
29+
#^^^^^ source.hack meta.function.php storage.modifier.php
30+
# ^ source.hack meta.function.php
31+
# ^^^^^^^^ source.hack meta.function.php storage.type.function.php
32+
# ^ source.hack meta.function.php
33+
# ^^^^^^^ source.hack meta.function.php entity.name.function.php
34+
# ^ source.hack meta.function.php punctuation.definition.parameters.begin.php
35+
# ^ source.hack meta.function.php punctuation.definition.parameters.end.php
36+
# ^ source.hack meta.function.php punctuation.definition.type.php
37+
# ^ source.hack meta.function.php
38+
# ^^^^^^^^^ source.hack meta.function.php support.class.php
39+
# ^ source.hack meta.function.php
40+
# ^^^^ source.hack meta.function.php support.class.php
41+
# ^ source.hack meta.function.php
42+
# ^ source.hack meta.function.php
43+
# ^ source.hack punctuation.section.scope.begin.php
44+
> $x = delay gen_foo();
45+
#^^ source.hack
46+
# ^ source.hack variable.other.php punctuation.definition.variable.php
47+
# ^ source.hack variable.other.php
48+
# ^ source.hack
49+
# ^ source.hack keyword.operator.assignment.php
50+
# ^ source.hack
51+
# ^^^^^ source.hack keyword.control.php
52+
# ^ source.hack
53+
# ^^^^^^^ source.hack meta.function-call.php entity.name.function.php
54+
# ^^ source.hack
55+
# ^ source.hack punctuation.terminator.expression.php
56+
>}
57+
#^ source.hack punctuation.section.scope.end.php
58+
>
59+
#^ source.hack

0 commit comments

Comments
 (0)