-
Notifications
You must be signed in to change notification settings - Fork 28
/
rewriter.swift
45 lines (36 loc) · 1.3 KB
/
rewriter.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import SwiftRewriter
/// Global rewriter.
var rewriter: Rewriter {
return
// Comment
HeaderCopyrightTrimmer()
// Move
>>> ImportSorter()
// >>> ExtensionIniter() // not useful for everyone
// Token
>>> DecimalLiteralUnderscorer()
>>> SemicolonTrimmer()
// Newline (whitespace)
// >>> ExtraNewliner() // not useful for everyone
>>> ElseNewliner(newline: false)
>>> MethodChainNewliner()
// Indent (whitespace)
>>> Indenter(.init(
perIndent: .spaces(4),
shouldIndentSwitchCase: false,
shouldIndentIfConfig: false,
skipsCommentedLine: true
))
// Space (whitespace)
// >>> ExtraSpaceTrimmer() // may disturb manually-aligned code
>>> ColonSpacer(spaceBefore: false, spaceAfter: true)
>>> TernaryExprSpacer()
>>> BinaryOperatorSpacer(spacesAround: true)
// Ignore to not distrub user-aligned multiple assignments
// TODO: Improve multiple assignment alignment
// >>> EqualSpacer(spacesAround: true)
>>> ArrowSpacer(spaceBefore: true, spaceAfter: true)
>>> LeftBraceSpacer(spaceBefore: true)
>>> LeftParenSpacer(spaceBefore: true)
>>> TrailingSpaceTrimmer()
}