13
13
import SwiftSyntax
14
14
15
15
extension Trivia {
16
- public var numberOfComments : Int {
16
+ var numberOfComments : Int {
17
17
var count = 0
18
18
for piece in self {
19
19
switch piece {
@@ -27,15 +27,15 @@ extension Trivia {
27
27
}
28
28
29
29
/// Returns whether the trivia contains at least 1 `lineComment`.
30
- public var hasLineComment : Bool {
30
+ var hasLineComment : Bool {
31
31
return self . contains {
32
32
if case . lineComment = $0 { return true }
33
33
return false
34
34
}
35
35
}
36
36
37
37
/// Returns this set of trivia, without any whitespace characters.
38
- public func withoutSpaces( ) -> Trivia {
38
+ func withoutSpaces( ) -> Trivia {
39
39
return Trivia (
40
40
pieces: filter {
41
41
if case . spaces = $0 { return false }
@@ -45,7 +45,7 @@ extension Trivia {
45
45
}
46
46
47
47
/// Returns this set of trivia, without any leading spaces.
48
- public func withoutLeadingSpaces( ) -> Trivia {
48
+ func withoutLeadingSpaces( ) -> Trivia {
49
49
return Trivia (
50
50
pieces: Array ( drop {
51
51
if case . spaces = $0 { return false }
@@ -55,7 +55,7 @@ extension Trivia {
55
55
}
56
56
57
57
/// Returns this set of trivia, without any newlines.
58
- public func withoutNewlines( ) -> Trivia {
58
+ func withoutNewlines( ) -> Trivia {
59
59
return Trivia (
60
60
pieces: filter {
61
61
if case . newlines = $0 { return false }
@@ -66,7 +66,7 @@ extension Trivia {
66
66
/// Returns this trivia, excluding the last newline and anything following it.
67
67
///
68
68
/// If there is no newline in the trivia, it is returned unmodified.
69
- public func withoutLastLine( ) -> Trivia {
69
+ func withoutLastLine( ) -> Trivia {
70
70
var maybeLastNewlineOffset : Int ? = nil
71
71
for (offset, piece) in self . enumerated ( ) {
72
72
switch piece {
@@ -82,30 +82,30 @@ extension Trivia {
82
82
83
83
/// Returns this set of trivia, with all spaces removed except for one at the
84
84
/// end.
85
- public func withOneTrailingSpace( ) -> Trivia {
85
+ func withOneTrailingSpace( ) -> Trivia {
86
86
return withoutSpaces ( ) + . spaces( 1 )
87
87
}
88
88
89
89
/// Returns this set of trivia, with all spaces removed except for one at the
90
90
/// beginning.
91
- public func withOneLeadingSpace( ) -> Trivia {
91
+ func withOneLeadingSpace( ) -> Trivia {
92
92
return . spaces( 1 ) + withoutSpaces( )
93
93
}
94
94
95
95
/// Returns this set of trivia, with all newlines removed except for one.
96
- public func withOneLeadingNewline( ) -> Trivia {
96
+ func withOneLeadingNewline( ) -> Trivia {
97
97
return . newlines( 1 ) + withoutNewlines( )
98
98
}
99
99
100
100
/// Returns this set of trivia, with all newlines removed except for one.
101
- public func withOneTrailingNewline( ) -> Trivia {
101
+ func withOneTrailingNewline( ) -> Trivia {
102
102
return withoutNewlines ( ) + . newlines( 1 )
103
103
}
104
104
105
105
/// Walks through trivia looking for multiple separate trivia entities with
106
106
/// the same base kind, and condenses them.
107
107
/// `[.spaces(1), .spaces(2)]` becomes `[.spaces(3)]`.
108
- public func condensed( ) -> Trivia {
108
+ func condensed( ) -> Trivia {
109
109
guard var prev = first else { return self }
110
110
var pieces = [ TriviaPiece] ( )
111
111
for piece in dropFirst ( ) {
@@ -136,7 +136,7 @@ extension Trivia {
136
136
}
137
137
138
138
/// Returns `true` if this trivia contains any newlines.
139
- public var containsNewlines : Bool {
139
+ var containsNewlines : Bool {
140
140
return contains (
141
141
where: {
142
142
if case . newlines = $0 { return true }
@@ -145,7 +145,7 @@ extension Trivia {
145
145
}
146
146
147
147
/// Returns `true` if this trivia contains any spaces.
148
- public var containsSpaces : Bool {
148
+ var containsSpaces : Bool {
149
149
return contains (
150
150
where: {
151
151
if case . spaces = $0 { return true }
@@ -156,7 +156,7 @@ extension Trivia {
156
156
157
157
/// Returns `true` if this trivia contains any backslahes (used for multiline string newline
158
158
/// suppression).
159
- public var containsBackslashes : Bool {
159
+ var containsBackslashes : Bool {
160
160
return contains (
161
161
where: {
162
162
if case . backslashes = $0 { return true }
0 commit comments