-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Include AccessLevel attributes in structure (SR-5978) #12086
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
[SourceKit] Include AccessLevel attributes in structure (SR-5978) #12086
Conversation
static UIdent Attr_FilePrivate("source.decl.attribute.fileprivate"); | ||
static UIdent Attr_Internal("source.decl.attribute.internal"); | ||
static UIdent Attr_Public("source.decl.attribute.public"); | ||
static UIdent Attr_Open("source.decl.attribute.open"); |
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.
Any reason we are not adding these to ProtocolUIDs.def?
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.
Attributes are defined in Attr.def
. The way that AccessLevel attributes work is via DECL_ATTR_ALIAS
, which forces us to explicitly check the AccessLevel and pick the right UID.
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.
ah, OK. Thanks for the explanation!
static UIdent Attr_FilePrivate("source.decl.attribute.setter_access.fileprivate"); | ||
static UIdent Attr_Internal("source.decl.attribute.setter_access.internal"); | ||
static UIdent Attr_Public("source.decl.attribute.setter_access.public"); | ||
static UIdent Attr_Open("source.decl.attribute.setter_access.open"); |
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.
Same for these new keys.
static UIdent Attr_Public("source.decl.attribute.setter_access.public"); | ||
static UIdent Attr_Open("source.decl.attribute.setter_access.open"); | ||
|
||
switch (cast<AbstractAccessControlAttr>(Attr)->getAccess()) { |
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.
Is there a way we can share the two switch statements? It seems to me a logic duplication.
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 agree that there's some logic duplication, but I can't think of a way of sharing those and being easier to read at the same time.
@swift-ci please smoke test |
472fd78
to
c8a677f
Compare
@swift-ci please smoke test |
c8a677f
to
b5ed790
Compare
@swift-ci please smoke test |
ping @nkcsgexi |
This PR includes AccessLevel attributes inside
key.attributes
in structures.This would make possible for tools like SwiftLint to get the ranges of these attributes, which can be useful for several rules:
private
,mutating
,final
, etc) of declarationsprivate(set) private foo: Int
)This PR also adds attributes for setter AccessLevel in 472fd78c43203a6c746db720373c79352a066a29. I'm not sure if this is the best way to do it, creating attributes like
source.decl.attribute.setter_access.private
, so feedbacks are welcome!Resolves SR-5978.
// cc @nkcsgexi