File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 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 {
4545 }
4646 }
4747
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+
4861 /// Keys for serializing and deserializing token kinds.
4962 enum CodingKeys : String , CodingKey {
5063 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