You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deprecate ByteSourceRange in favor of Range<AbsolutePosition>
While being a little more verbose, this has a few advantages:
- We only have a single type to represent ranges in SwiftSyntax instead of `Range<AbsolutePosition>` and `ByteSourceRange`, both of which we needed to use in sourcekit-lsp
- Unifying the convenience functions on the two results in a single type that has all the convenience functions, instead of spreading them to two distinct sets
- The use of `AbsolutePosition` and `SourceLength` makes type-system guarantees that these are UTF-8 byte positions / length, making it harder to accidentally add eg. UTF-16 lengths with UTF-8 lengths.
rdar://125624626
Copy file name to clipboardExpand all lines: Release Notes/600.md
+31
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,10 @@
75
75
- Description: With the change to parse `#if canImport(MyModule, _version: 1.2.3)` as a function call instead of a dedicated syntax node, `1.2.3` natively gets parsed as a member access `3` to the `1.2` float literal. This property allows the reinterpretation of such an expression as a version tuple.
- Description: Instead of parsing `canImport` inside `#if` directives as a special expression node, parse it as a functionc call expression. This is in-line with how the `swift(>=6.0)` and `compiler(>=6.0)` directives are parsed.
-`ByteSourceRange` deprecated in favor of `Range<AbsolutePosition>`
124
+
- Description: Instead of having a dedicated range type in SwiftSyntax, use `Range<AbsolutePosition>` instead. `Range<AbsolutePosition>` has deprecated compatibility layers to make it API-compatible with `ByteSourceRange`
- Migration steps: Use `if case .backslash = triviaPiece` instead
158
174
175
+
-`ByteSourceRange.length` changed from `Int` to `SourceLength`
176
+
- Description: `ByteSourceRange` has been deprecated and declared as a typealias for `Range<AbsolutePosition>`. At the same time, `Range<AbsolutePosition>` gained `length: SourceLength` that provides type-system information about the kind of length (UTF-8 byte length).
-`IncrementalEdit.replacementLength` changed from `Int` to `SourceLength`
180
+
- Description: The type of `IncrementalEdit.replacementLength` has been changed from `Int` to `SourceLength` which provides type-system information about the kind of length (UTF-8 byte length).
-`SyntaxProtocol.classifications(in:)` and `SyntaxProtocol.classification(at:)` take positions relative to the root of the syntax tree instead of relative to the start of the node
186
+
- Description: With the deprecation of `ByteSourceRange` in favor of `Range<AbsolutePosition>`, the `AbsolutePosition`s passed as the range are measured from the start of the syntax tree instead of the start of the current node.
0 commit comments