File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,19 @@ public enum TokenKind: Codable {
45
45
}
46
46
}
47
47
48
+ public var isKeyword : Bool {
49
+ switch self {
50
+ case . eof: return false
51
+ % for token in SYNTAX_TOKENS:
52
+ % if token. is_keyword:
53
+ case . ${ token. swift_kind ( ) } : return true
54
+ % else :
55
+ case . ${ token. swift_kind ( ) } : return false
56
+ % end
57
+ % end
58
+ }
59
+ }
60
+
48
61
/// Keys for serializing and deserializing token kinds.
49
62
enum CodingKeys : String , CodingKey {
50
63
case kind, text
Original file line number Diff line number Diff line change
1
+ import XCTest
2
+ import SwiftSyntax
3
+
4
+ public class TokenSyntaxTestCase : XCTestCase {
5
+ public func testKeywordKinds( ) {
6
+ XCTAssertTrue ( TokenKind . operatorKeyword. isKeyword)
7
+ XCTAssertTrue ( TokenKind . funcKeyword. isKeyword)
8
+ XCTAssertFalse ( TokenKind . leftAngle. isKeyword)
9
+ XCTAssertFalse ( TokenKind . rightAngle. isKeyword)
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments