diff --git a/Sources/SourceKitLSP/DocumentTokens.swift b/Sources/SourceKitLSP/DocumentTokens.swift index 98d9d762f..eb23dc011 100644 --- a/Sources/SourceKitLSP/DocumentTokens.swift +++ b/Sources/SourceKitLSP/DocumentTokens.swift @@ -96,6 +96,8 @@ extension SyntaxClassification { return (.number, []) case .stringLiteral: return (.string, []) + case .regexLiteral: + return (.regexp, []) case .poundDirectiveKeyword: return (.macro, []) case .buildConfigId, .objectLiteral: diff --git a/Tests/SourceKitLSPTests/SemanticTokensTests.swift b/Tests/SourceKitLSPTests/SemanticTokensTests.swift index c3a95da29..876159151 100644 --- a/Tests/SourceKitLSPTests/SemanticTokensTests.swift +++ b/Tests/SourceKitLSPTests/SemanticTokensTests.swift @@ -488,6 +488,17 @@ final class SemanticTokensTests: XCTestCase { ]) } + func testRegexSemanticTokens() { + let text = """ + let r = /a[bc]*/ + """ + let tokens = openAndPerformSemanticTokensRequest(text: text) + XCTAssertEqual(tokens, [ + Token(line: 0, utf16index: 0, length: 3, kind: .keyword), + Token(line: 0, utf16index: 4, length: 1, kind: .identifier), + Token(line: 0, utf16index: 8, length: 8, kind: .regexp), + ]) + } func testOperatorDeclaration() { let text = """