File tree Expand file tree Collapse file tree 3 files changed +136
-132
lines changed Expand file tree Collapse file tree 3 files changed +136
-132
lines changed Original file line number Diff line number Diff line change @@ -180,9 +180,9 @@ struct RawSyntaxTokenView {
180
180
func formKind( ) -> TokenKind {
181
181
switch raw. rawData. payload {
182
182
case . parsedToken( let dat) :
183
- return TokenKind . fromRaw ( kind: dat. tokenKind, text: dat. tokenText)
183
+ return TokenKind . fromRaw ( kind: dat. tokenKind, text: String ( syntaxText : dat. tokenText) )
184
184
case . materializedToken( let dat) :
185
- return TokenKind . fromRaw ( kind: dat. tokenKind, text: dat. tokenText)
185
+ return TokenKind . fromRaw ( kind: dat. tokenKind, text: String ( syntaxText : dat. tokenText) )
186
186
case . layout( _) :
187
187
preconditionFailure ( " Must be invoked on a token " )
188
188
}
Original file line number Diff line number Diff line change @@ -231,24 +231,26 @@ for token in SYNTAX_TOKENS:
231
231
232
232
extension TokenKind {
233
233
/// If the `rawKind` has a `defaultText`, `text` can be empty.
234
- static func fromRaw( kind rawKind: RawTokenKind , text: SyntaxText ) -> TokenKind {
234
+ @_spi ( RawSyntax)
235
+ public static func fromRaw( kind rawKind: RawTokenKind , text: String ) -> TokenKind {
235
236
switch rawKind {
236
237
case . eof: return . eof
237
238
% for token in SYNTAX_TOKENS:
238
239
case . ${ token. swift_kind ( ) } :
239
240
% if token. text:
240
- assert ( text. isEmpty || rawKind. defaultText == text)
241
+ assert ( text. isEmpty || rawKind. defaultText. map ( String . init ) == text)
241
242
return . ${ token. swift_kind ( ) }
242
243
% else :
243
- return . ${ token. swift_kind ( ) } ( String ( syntaxText : text) )
244
+ return . ${ token. swift_kind ( ) } ( text)
244
245
% end
245
246
% end
246
247
}
247
248
}
248
249
249
250
/// Returns the `RawTokenKind` of this `TokenKind` and, if this `TokenKind`
250
251
/// has associated text, the associated text, otherwise `nil`.
251
- func decomposeToRaw( ) -> ( rawKind: RawTokenKind , string: String ? ) {
252
+ @_spi ( RawSyntax)
253
+ public func decomposeToRaw( ) -> ( rawKind: RawTokenKind , string: String ? ) {
252
254
switch self {
253
255
case . eof: return ( . eof, nil )
254
256
% for token in SYNTAX_TOKENS:
You can’t perform that action at this time.
0 commit comments