Skip to content

Commit 777520e

Browse files
authored
Merge pull request #2003 from natikgadzhi/lookahead/rename-is-to-at
Rename Parser.Lookahead functions from is* to at*
2 parents 6e66105 + 638a0f0 commit 777520e

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Sources/SwiftParser/Attributes.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ extension Parser {
176176
case .required:
177177
shouldParseArgument = true
178178
case .customAttribute:
179-
shouldParseArgument = self.withLookahead { $0.isCustomAttributeArgument() } && self.at(TokenSpec(.leftParen, allowAtStartOfLine: false))
179+
shouldParseArgument = self.withLookahead { $0.atCustomAttributeArgument() } && self.at(TokenSpec(.leftParen, allowAtStartOfLine: false))
180180
case .optional:
181181
shouldParseArgument = self.at(.leftParen)
182182
}
@@ -1091,7 +1091,7 @@ extension Parser {
10911091
// MARK: Lookahead
10921092

10931093
extension Parser.Lookahead {
1094-
mutating func isCustomAttributeArgument() -> Bool {
1094+
mutating func atCustomAttributeArgument() -> Bool {
10951095
var lookahead = self.lookahead()
10961096
lookahead.skipSingle()
10971097

@@ -1124,7 +1124,7 @@ extension Parser.Lookahead {
11241124
return false
11251125
}
11261126

1127-
if self.at(TokenSpec(.leftParen, allowAtStartOfLine: false)) && self.withLookahead({ $0.isCustomAttributeArgument() }) {
1127+
if self.at(TokenSpec(.leftParen, allowAtStartOfLine: false)) && self.withLookahead({ $0.atCustomAttributeArgument() }) {
11281128
self.skipSingle()
11291129
}
11301130

Sources/SwiftParser/Declarations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@ extension Parser {
19191919
let trailingClosure: RawClosureExprSyntax?
19201920
let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax?
19211921
if self.at(.leftBrace),
1922-
self.withLookahead({ $0.isValidTrailingClosure(.trailingClosure) })
1922+
self.withLookahead({ $0.atValidTrailingClosure(.trailingClosure) })
19231923
{
19241924
(trailingClosure, additionalTrailingClosures) =
19251925
self.parseTrailingClosures(.trailingClosure)

Sources/SwiftParser/Expressions.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ extension Parser {
734734
// If we can parse trailing closures, do so.
735735
let trailingClosure: RawClosureExprSyntax?
736736
let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax?
737-
if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.isValidTrailingClosure(flavor) }) {
737+
if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.atValidTrailingClosure(flavor) }) {
738738
(trailingClosure, additionalTrailingClosures) = self.parseTrailingClosures(flavor)
739739
} else {
740740
trailingClosure = nil
@@ -770,7 +770,7 @@ extension Parser {
770770
// If we can parse trailing closures, do so.
771771
let trailingClosure: RawClosureExprSyntax?
772772
let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax?
773-
if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.isValidTrailingClosure(flavor) }) {
773+
if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.atValidTrailingClosure(flavor) }) {
774774
(trailingClosure, additionalTrailingClosures) = self.parseTrailingClosures(flavor)
775775
} else {
776776
trailingClosure = nil
@@ -793,7 +793,7 @@ extension Parser {
793793
}
794794

795795
// Check for a trailing closure, if allowed.
796-
if self.at(.leftBrace) && self.withLookahead({ $0.isValidTrailingClosure(flavor) }) {
796+
if self.at(.leftBrace) && self.withLookahead({ $0.atValidTrailingClosure(flavor) }) {
797797
// FIXME: if Result has a trailing closure, break out.
798798
// Add dummy blank argument list to the call expression syntax.
799799
let list = RawLabeledExprListSyntax(elements: [], arena: self.arena)
@@ -1321,7 +1321,7 @@ extension Parser {
13211321
// Parse the optional trailing closures.
13221322
let trailingClosure: RawClosureExprSyntax?
13231323
let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax?
1324-
if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.isValidTrailingClosure(flavor) }) {
1324+
if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.atValidTrailingClosure(flavor) }) {
13251325
(trailingClosure, additionalTrailingClosures) = self.parseTrailingClosures(flavor)
13261326
} else {
13271327
trailingClosure = nil
@@ -1915,7 +1915,7 @@ extension Parser {
19151915
// Parse labeled trailing closures.
19161916
var elements = [RawMultipleTrailingClosureElementSyntax]()
19171917
var loopProgress = LoopProgressCondition()
1918-
while self.withLookahead({ $0.isStartOfLabelledTrailingClosure() }) && self.hasProgressed(&loopProgress) {
1918+
while self.withLookahead({ $0.atStartOfLabelledTrailingClosure() }) && self.hasProgressed(&loopProgress) {
19191919
let (unexpectedBeforeLabel, label) = self.parseArgumentLabel()
19201920
let (unexpectedBeforeColon, colon) = self.expect(.colon)
19211921
let closure = self.parseClosureExpression()
@@ -1937,7 +1937,7 @@ extension Parser {
19371937
}
19381938

19391939
extension Parser.Lookahead {
1940-
mutating func isStartOfLabelledTrailingClosure() -> Bool {
1940+
mutating func atStartOfLabelledTrailingClosure() -> Bool {
19411941
// Fast path: the next two tokens must be a label and a colon.
19421942
// But 'default:' is ambiguous with switch cases and we disallow it
19431943
// (unless escaped) even outside of switches.
@@ -1967,12 +1967,12 @@ extension Parser.Lookahead {
19671967
/// where the parser requires an expr-basic (which does not allow them). We
19681968
/// handle this by doing some lookahead in common situations. And later, Sema
19691969
/// will emit a diagnostic with a fixit to add wrapping parens.
1970-
mutating func isValidTrailingClosure(_ flavor: Parser.ExprFlavor) -> Bool {
1970+
mutating func atValidTrailingClosure(_ flavor: Parser.ExprFlavor) -> Bool {
19711971
precondition(self.at(.leftBrace), "Couldn't be a trailing closure")
19721972

19731973
// If this is the start of a get/set accessor, then it isn't a trailing
19741974
// closure.
1975-
guard !self.withLookahead({ $0.isStartOfGetSetAccessor() }) else {
1975+
guard !self.withLookahead({ $0.atStartOfGetSetAccessor() }) else {
19761976
return false
19771977
}
19781978

Sources/SwiftParser/Lookahead.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ extension Parser.Lookahead {
246246
// MARK: Lookahead
247247

248248
extension Parser.Lookahead {
249-
mutating func isStartOfGetSetAccessor() -> Bool {
249+
mutating func atStartOfGetSetAccessor() -> Bool {
250250
precondition(self.at(.leftBrace), "not checking a brace?")
251251

252252
// The only case this can happen is if the accessor label is immediately after

0 commit comments

Comments
 (0)