[SourceKit/CodeFormat] Indentation fixes for multi-line string, UnresolvedSpecializeExpr, and trailing target handling. #31098
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a bug were we were indenting within a multi-line string when we shouldn't have been. The checks for walking into an AST node or not were based on their end source loc, which is the start of their last token. If that token was a multi-line string and line being indented was within it, we we wouldn't walk into the node, and so never set the flag to indicate we were attempting to indent within a string.
We weren't handling UnresolvedSpecializeExpr when determining if an expression was 'outdenting' or not, so we ended up indenting the filter call below when we shouldn't have:
It's now handled correctly.
Fixes up ListAligner (and the code using it) to handle trailing indentation targets in many more cases. This makes the as-you-type indentation more consistent with select-and-reindent-after-you're-done indentation. Hitting enter after a comma in an incomplete list, or after an empty list that requires at least one element now give the correct indentation in many more cases (including guard/if/while conditions, and enum case elements). A few lists still don't handle trailing indentation targets properly, though, because the parser drops them from the AST when incomplete or empty.
Resolves rdar://problem/62061741