code_clean: add 'remove_struct_qualifier' edit

Removes struct qualifier when it's not needed.
This commit is contained in:
Campbell Barton
2023-05-31 16:46:59 +10:00
parent 3672f9c437
commit e2cb52594a

View File

@@ -790,6 +790,28 @@ class edit_generators:
return edits
class remove_struct_qualifier(EditGenerator):
"""
Remove redundant struct qualifiers:
Replace:
struct Foo
With:
Foo
"""
@staticmethod
def edit_list_from_file(_source: str, data: str, _shared_edit_data: Any) -> List[Edit]:
edits = []
# Remove `struct`
for match in re.finditer(r"\bstruct\b", data):
edits.append(Edit(
span=match.span(),
content=' ',
content_fail=' __ALWAYS_FAIL__ ',
))
return edits
class remove_return_parens(EditGenerator):
"""
Remove redundant parenthesis around return arguments: