Skip to content

Commit 8b97daf

Browse files
committed
style: Handle access specifier indentation in formatting script
1 parent 0f0037d commit 8b97daf

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

scripts/cpp/convert_leading_spaces_to_tabs.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,21 @@ def process_file(filepath, dry_run=False, verbose=False):
273273
depth = get_indent_depth(parent)
274274

275275
# Special handling: access specifiers (public/private/protected)
276-
# For now, skip these - deferred to another PR
276+
# These sit at the class brace level, not indented inside the class body.
277277
if node.type in ('public', 'private', 'protected'):
278-
new_lines.append(line)
279-
skipped += 1
280-
if verbose:
281-
print(f" SKIP access spec L{line_idx+1}: {line.rstrip()[:80]}")
282-
continue
278+
access_spec = node.parent # access_specifier node
279+
if access_spec is not None and access_spec.type == 'access_specifier':
280+
field_list = access_spec.parent # field_declaration_list
281+
if field_list is not None:
282+
depth = get_indent_depth(field_list)
283283

284-
# Special handling: the colon after access specifier or case label
284+
# Special handling: the colon after access specifier
285285
if node.type == ':':
286286
parent = node.parent
287287
if parent is not None and parent.type == 'access_specifier':
288-
new_lines.append(line)
289-
skipped += 1
290-
continue
288+
field_list = parent.parent
289+
if field_list is not None:
290+
depth = get_indent_depth(field_list)
291291

292292
# Sanity check: if the line had significant indentation but we
293293
# computed depth 0, something is likely wrong (parse errors nearby,
@@ -368,7 +368,7 @@ def main():
368368

369369
action = "Would change" if args.dry_run else "Changed"
370370
print(f"\n{action} {total_changed} lines across {total_files_modified} files")
371-
print(f"Skipped {total_skipped} lines (continuations, access specifiers, ambiguous)")
371+
print(f"Skipped {total_skipped} lines (continuations, ambiguous)")
372372

373373

374374
if __name__ == '__main__':

0 commit comments

Comments
 (0)