Skip to content

Commit fa4ef0f

Browse files
mszabo-wikiaClaude
andauthored
fix: highlight parameters after inline shape default values (#220)
The default value end pattern `(?=,|\))` matched the `)` inside expressions like `shape()`, prematurely closing the parameter scope and breaking highlighting for all subsequent parameters. Add a nested parentheses-matching pattern so balanced parens in default value expressions are consumed correctly. Fixes #124. Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent 40114cd commit fa4ef0f

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

syntaxes/hack.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,15 @@
454454
}
455455
},
456456
"patterns": [
457+
{
458+
"begin": "\\(",
459+
"end": "\\)",
460+
"patterns": [
461+
{
462+
"include": "#language"
463+
}
464+
]
465+
},
457466
{
458467
"include": "#language"
459468
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type sometype = shape(
2+
'x' => int
3+
);
4+
5+
function myfunction(
6+
int $anint,
7+
shape(?'x'=>'a') $myshape = shape(),
8+
sometype $more,
9+
int $other = 5
10+
): void {
11+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
>type sometype = shape(
2+
#^^^^ source.hack meta.typedecl.php storage.type.typedecl.php
3+
# ^ source.hack meta.typedecl.php
4+
# ^^^^^^^^ source.hack meta.typedecl.php entity.name.type.typedecl.php
5+
# ^ source.hack meta.typedecl.php
6+
# ^ source.hack meta.typedecl.php keyword.operator.assignment.php
7+
# ^ source.hack meta.typedecl.php
8+
# ^^^^^^ source.hack meta.typedecl.php storage.type.shape.php
9+
> 'x' => int
10+
#^^^^ source.hack meta.typedecl.php storage.type.shape.php
11+
# ^ source.hack meta.typedecl.php storage.type.shape.php string.quoted.single.php punctuation.definition.string.begin.php
12+
# ^ source.hack meta.typedecl.php storage.type.shape.php string.quoted.single.php meta.string-contents.quoted.single.php
13+
# ^ source.hack meta.typedecl.php storage.type.shape.php string.quoted.single.php punctuation.definition.string.end.php
14+
# ^^^^ source.hack meta.typedecl.php storage.type.shape.php
15+
# ^^^ source.hack meta.typedecl.php storage.type.shape.php support.type.php
16+
>);
17+
#^ source.hack meta.typedecl.php storage.type.shape.php keyword.operator.key.php
18+
# ^ source.hack meta.typedecl.php punctuation.termination.expression.php
19+
>
20+
>function myfunction(
21+
#^^^^^^^^ source.hack meta.function.php storage.type.function.php
22+
# ^ source.hack meta.function.php
23+
# ^^^^^^^^^^ source.hack meta.function.php entity.name.function.php
24+
# ^ source.hack meta.function.php punctuation.definition.parameters.begin.php
25+
> int $anint,
26+
#^^^^ source.hack meta.function.php meta.function.arguments.php
27+
# ^^^ source.hack meta.function.php meta.function.arguments.php support.type.php
28+
# ^ source.hack meta.function.php meta.function.arguments.php
29+
# ^ source.hack meta.function.php meta.function.arguments.php variable.other.php punctuation.definition.variable.php
30+
# ^^^^^ source.hack meta.function.php meta.function.arguments.php variable.other.php
31+
# ^^ source.hack meta.function.php meta.function.arguments.php
32+
> shape(?'x'=>'a') $myshape = shape(),
33+
#^^^^ source.hack meta.function.php meta.function.arguments.php
34+
# ^^^^^^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php
35+
# ^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php
36+
# ^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php string.quoted.single.php punctuation.definition.string.begin.php
37+
# ^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php string.quoted.single.php meta.string-contents.quoted.single.php
38+
# ^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php string.quoted.single.php punctuation.definition.string.end.php
39+
# ^^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php
40+
# ^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php string.quoted.single.php punctuation.definition.string.begin.php
41+
# ^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php string.quoted.single.php meta.string-contents.quoted.single.php
42+
# ^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php string.quoted.single.php punctuation.definition.string.end.php
43+
# ^ source.hack meta.function.php meta.function.arguments.php storage.type.shape.php keyword.operator.key.php
44+
# ^ source.hack meta.function.php meta.function.arguments.php
45+
# ^ source.hack meta.function.php meta.function.arguments.php variable.other.php punctuation.definition.variable.php
46+
# ^^^^^^^ source.hack meta.function.php meta.function.arguments.php variable.other.php
47+
# ^ source.hack meta.function.php meta.function.arguments.php
48+
# ^ source.hack meta.function.php meta.function.arguments.php keyword.operator.assignment.php
49+
# ^ source.hack meta.function.php meta.function.arguments.php
50+
# ^^^^^ source.hack meta.function.php meta.function.arguments.php meta.function-call.php entity.name.function.php
51+
# ^ source.hack meta.function.php meta.function.arguments.php
52+
# ^ source.hack meta.function.php meta.function.arguments.php
53+
# ^^ source.hack meta.function.php meta.function.arguments.php
54+
> sometype $more,
55+
#^^^^ source.hack meta.function.php meta.function.arguments.php
56+
# ^^^^^^^^ source.hack meta.function.php meta.function.arguments.php support.class.php
57+
# ^ source.hack meta.function.php meta.function.arguments.php
58+
# ^ source.hack meta.function.php meta.function.arguments.php variable.other.php punctuation.definition.variable.php
59+
# ^^^^ source.hack meta.function.php meta.function.arguments.php variable.other.php
60+
# ^^ source.hack meta.function.php meta.function.arguments.php
61+
> int $other = 5
62+
#^^^^ source.hack meta.function.php meta.function.arguments.php
63+
# ^^^ source.hack meta.function.php meta.function.arguments.php support.type.php
64+
# ^ source.hack meta.function.php meta.function.arguments.php
65+
# ^ source.hack meta.function.php meta.function.arguments.php variable.other.php punctuation.definition.variable.php
66+
# ^^^^^ source.hack meta.function.php meta.function.arguments.php variable.other.php
67+
# ^ source.hack meta.function.php meta.function.arguments.php
68+
# ^ source.hack meta.function.php meta.function.arguments.php keyword.operator.assignment.php
69+
# ^ source.hack meta.function.php meta.function.arguments.php
70+
# ^ source.hack meta.function.php meta.function.arguments.php constant.numeric.php
71+
>): void {
72+
#^ source.hack meta.function.php punctuation.definition.parameters.end.php
73+
# ^ source.hack meta.function.php punctuation.definition.type.php
74+
# ^ source.hack meta.function.php
75+
# ^^^^ source.hack meta.function.php support.class.php
76+
# ^ source.hack meta.function.php
77+
# ^ source.hack punctuation.section.scope.begin.php
78+
>}
79+
#^ source.hack punctuation.section.scope.end.php
80+
>

0 commit comments

Comments
 (0)