Skip to content

Commit a962805

Browse files
committed
Remove isToken and isCollection from SyntaxProtocol
These getters were redundant with other ways to check the properties.
1 parent 2d1b8e8 commit a962805

File tree

5 files changed

+4
-17
lines changed

5 files changed

+4
-17
lines changed

Sources/SwiftParserDiagnostics/MissingNodesError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ extension ParseDiagnosticsGenerator {
347347
missingNodes += [sibling]
348348
} else if sibling.isMissingAllTokens && sibling.hasTokens {
349349
missingNodes += [sibling]
350-
} else if sibling.isCollection && sibling.children(viewMode: .sourceAccurate).count == 0 {
350+
} else if sibling.kind.isSyntaxCollection && sibling.children(viewMode: .sourceAccurate).count == 0 {
351351
// Skip over any syntax collections without any elements while looking ahead for further missing nodes.
352352
} else {
353353
// Otherwise we have found a present node, so stop looking ahead.

Sources/SwiftSyntax/Syntax.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,6 @@ public extension SyntaxProtocol {
243243
return SyntaxChildrenIndex(self.data.absoluteInfo)
244244
}
245245

246-
/// Whether or not this node is a token one.
247-
var isToken: Bool {
248-
return raw.isToken
249-
}
250-
251-
/// Whether or not this node represents an SyntaxCollection.
252-
var isCollection: Bool {
253-
// We need to provide a custom implementation for is(SyntaxCollection.self)
254-
// since SyntaxCollection has generic or self requirements and can thus
255-
// not be used as a method argument.
256-
return raw.kind.isSyntaxCollection
257-
}
258-
259246
/// Whether the tree contained by this layout has any
260247
/// - missing nodes or
261248
/// - unexpected nodes or

Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public extension SyntaxProtocol {
118118
return .nodeType
119119
}
120120

121-
if isToken {
121+
if self.is(TokenSyntax.self) {
122122
if let token = Syntax(self).as(TokenSyntax.self), let baselineToken = Syntax(baseline).as(TokenSyntax.self) {
123123
if token.presence != baselineToken.presence {
124124
return .presence

Sources/_SwiftSyntaxTestSupport/SyntaxProtocol+Initializer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ extension SyntaxProtocol {
114114

115115
private func debugInitCallExpr(includeTrivia: Bool) -> ExprSyntax {
116116
let mirror = Mirror(reflecting: self)
117-
if self.isCollection {
117+
if self.kind.isSyntaxCollection {
118118
let typeName = String(describing: type(of: self))
119119
return ExprSyntax(
120120
FunctionCallExprSyntax(callee: IdentifierExprSyntax(identifier: .identifier(typeName))) {

Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class SyntaxCollectionsTests: XCTestCase {
2929
])
3030

3131
let newArrayElementList = arrayElementList.appending(integerLiteralElement(1))
32-
XCTAssert(newArrayElementList.isCollection)
32+
XCTAssert(newArrayElementList.kind.isSyntaxCollection)
3333
XCTAssertEqual(newArrayElementList.count, 2)
3434
XCTAssertNotNil(newArrayElementList.child(at: 1))
3535
XCTAssert(!newArrayElementList.child(at: 1)!.isCollection)

0 commit comments

Comments
 (0)