square / Cleanse

Lightweight Swift Dependency Injection Framework
Other
1.78k stars 90 forks source link

[cleansec] Sanitize -dump-ast spaced newlines. #161

Closed sebastianv1 closed 4 years ago

sebastianv1 commented 4 years ago

Some -dump-ast outputs have an irregularity where particular nodes have incorrect indentation, thus causing to be grouped under the wrong parent. This irregularity materializes as a newline with only n whitespace characters that should be prepended to the following line.

This change modifies sanitize(lines:) to account for this possibility. Introduces a helper flatMapScanPrevious which allows for scanning the previous element within flatMap.