Skip to content

Commit 6c70ab0

Browse files
committed
Add codegen to formatter
1 parent 03f748b commit 6c70ab0

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

format.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,21 @@ def find_swiftformat(swift_format: str) -> Path:
8686

8787
def get_files_to_format() -> List[Path]:
8888
package_dir = Path(__file__).parent
89-
files_to_format: List[Path] = []
90-
for swift_file_path in (package_dir / "Sources").glob('**/*.swift'):
91-
if swift_file_path.match('**/generated/**') or \
92-
swift_file_path.match('**/gyb_generated/syntax_nodes/**') or \
93-
swift_file_path.match('**/gyb_generated/**'):
94-
# Don't format generated files
95-
continue
96-
files_to_format.append(swift_file_path)
97-
98-
for swift_file_path in (package_dir / "Tests").glob('**/*.swift'):
99-
if swift_file_path.match('**/Inputs/**'):
100-
# Don't format test input files
101-
continue
102-
files_to_format.append(swift_file_path)
103-
104-
return files_to_format
89+
files_to_format = set(package_dir.glob('**/*.swift'))
90+
files_to_exclude = set()
91+
92+
# Don't format gyb_generated files
93+
files_to_exclude.update(package_dir.glob('**/gyb_generated/**/*.swift'))
94+
# Don't generate lit_tests files
95+
files_to_exclude.update(package_dir.glob('**/lit_tests/**/*.swift'))
96+
# Don't format generated files
97+
files_to_exclude.update(package_dir.glob('**/generated/**/*.swift'))
98+
# Don't format .build folder and content
99+
files_to_exclude.update(package_dir.glob('**/.build/**/*.swift'))
100+
# Don't format test input files
101+
files_to_exclude.update(package_dir.glob('**/Inputs/**/*.swift'))
102+
103+
return list(files_to_format.difference(files_to_exclude))
105104

106105

107106
def main() -> None:

0 commit comments

Comments
 (0)