Skip to content

Commit 3d8f326

Browse files
committed
JT: handle generic arguments for #format_specializations_arguments
1 parent a85996c commit 3d8f326

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

tool/jt.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,22 +2329,27 @@ def split_arguments(line)
23292329
split_points = []
23302330
i += 1 while line[i] != '('
23312331
i += 1
2332-
brackets = 1
2332+
parens = 1
2333+
generic = 0
23332334
split_points << i # ( start of arguments
23342335

23352336

23362337
while i < line.size
23372338
case line[i]
23382339
when '('
2339-
brackets += 1
2340+
parens += 1
23402341
when ')'
2341-
brackets -= 1
2342-
if brackets == 0
2342+
parens -= 1
2343+
if parens == 0
23432344
split_points << i
23442345
break
23452346
end
2347+
when '<'
2348+
generic += 1
2349+
when '>'
2350+
generic -= 1
23462351
when ','
2347-
split_points << i if brackets == 1
2352+
split_points << i if parens == 1 && generic == 0
23482353
else
23492354
# nothing to do
23502355
end
@@ -2382,7 +2387,7 @@ def iterate(&update)
23822387
# look for end of annotation
23832388
while braces != 0
23842389
new_content << line
2385-
line = lines.shift
2390+
line = lines.shift
23862391
braces += count_braces(line)
23872392
end
23882393

@@ -2398,11 +2403,11 @@ def iterate(&update)
23982403
end
23992404

24002405
# look for whole declaration
2401-
braces = count_braces(line)
2406+
braces = count_braces(line)
24022407
declaration = [line]
24032408
while braces != 0
24042409
# new_content << line
2405-
line = lines.shift
2410+
line = lines.shift
24062411
braces += count_braces(line)
24072412
declaration << line
24082413
end

0 commit comments

Comments
 (0)