-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SwiftSyntax] Simplify AbsolutePosition offset calculation and support columns #16131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SwiftSyntax] Simplify AbsolutePosition offset calculation and support columns #16131
Conversation
/// Specifically, walks through the trivia and keeps track of every newline | ||
/// to give a number of how many newlines and UTF8 characters appear in the | ||
/// trivia, along with the UTF8 offset of the last column. | ||
func characterSizes() -> (lines: Int, lastColumn: Int, utf8Length: Int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly, this code was never called.
@nkcsgexi I'm wondering if we even need the utf-16 encoding. |
@harlanhaskins if we have the character offset, then we don't need utf16-based offset i presume. The idea is utf16-based offset is easier to bridge to character offset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The calculation is a little bit wrong, I'm investigating now. |
} | ||
|
||
internal func add(columns: Int) { | ||
print("adding \(columns) column bytes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove before merging
Wow, very simple bug. @swift-ci please smoke test |
This patch simplifies the calculation and structure of AbsolutePosition, in preparation for DiagnosticEngine changes to easily create SourceLocations.