Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the Tree-sitter dependency to v0.25.6 and adapts the Swift wrapper API to use opaque pointers and new encoding parameters.
- Upgraded the Tree-sitter Swift package version to 0.25.6.
- Replaced all
UnsafePointer<TSLanguage>usage withOpaquePointerfor language references. - Updated
TSInputinitializer to include a newdecodeparameter and added explicit UTF-16LE/BE string encoding support.
Comments suppressed due to low confidence (1)
Sources/Runestone/TreeSitter/TreeSitterTextInput.swift:24
- Providing
nilfor thedecodecallback may break parsing of non-ASCII text under UTF-16LE/BE encodings because Tree-sitter relies on a decode function to convert bytes to codepoints. Consider supplying a proper decode callback (as in swift-tree-sitter) or verifying that default behavior works for all target encodings.
return TSInput(payload: payload, read: read, encoding: encoding, decode: nil)
| return .utf8 | ||
| case TSInputEncodingUTF16: | ||
| return String.preferredUTF16Encoding | ||
| case TSInputEncodingUTF16LE: |
There was a problem hiding this comment.
The original TSInputEncodingUTF16 case was removed from stringEncoding, so any code still using TSInputEncodingUTF16 will fall through and return nil, causing silent parse failures. Consider explicitly handling or deprecating UTF16, or adding a mapping for it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here we go again, as a continuation of #401. 🙂
TSLanguagedoesn't seem to be publicly exported anymore on the latest version of tree-sitter (or its Swift package wrapper), so I've usedOpaquePointers, inspired by swift-tree-sitter's implementation. Eyeballing it, it didn't break anything for me, but please let me know what you think of this.