-
Notifications
You must be signed in to change notification settings - Fork 441
Audit public API on SyntaxProtocol
#1912
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
Conversation
This gives the file a little order and makes it easier to spot naming inconsistencies.
This property seems to be pretty useless and probably dates back to a completely different design of the syntax tree where implicit nodes were a thing.
@swift-ci Please test |
The position and range API on `SyntaxProtocol` was a little inconsistent and misleading. Clean it up so that we have `totalLength` (including trivia), `contentLength` (excluding trivia) and a matching pair for `byteRange`.
0de6b19
to
5bfa847
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
public var detached: Self { | ||
var detached: Self { |
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.
I very much dislike that we switch between visibility on the extension and visibility on each member here 😅. Ie. just below does the opposite.
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.
Let’s enable the swift-format rule that we don’t have an access level on an extension in a follow-up PR.
Sources/SwiftSyntax/Syntax.swift
Outdated
} | ||
|
||
/// The textual byte length of this node exluding leading and trailing trivia. | ||
@available(*, deprecated, message: "Use contentLength.utf8Length") |
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.
I wonder if the content
name could work for the other places we're using trimmed
right now? Or if this should be trimmedLength
? I'm not sure content
means "not including leading/trailing trivia" to me.
return totalLength.utf8Length | ||
} | ||
|
||
/// The textual byte length of this node exluding leading and trailing trivia. |
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.
/// The textual byte length of this node exluding leading and trailing trivia. | |
/// The textual byte length of this node excluding leading and trailing trivia. |
@swift-ci Please test |
@swift-ci Please test Windows |
First, re-arrange the properties in
SyntaxProtocol
to group them logically.Then, I found two areas of improvement:
isImplicit
SyntaxProtocol
SyntaxProtocol
was a little inconsistent and misleading. Clean it up so that we havetotalLength
(including trivia),contentLength
(excluding trivia) and a matching pair forbyteRange
.