-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[IDE] Range info for accessor decl #17900
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
@swift-ci Please smoke test |
lib/AST/Decl.cpp
Outdated
continue; | ||
|
||
SourceLoc AttrStartLoc = Attr->getRangeWithAt().Start; | ||
if (getASTContext().SourceMgr.isBeforeInBuffer(VarLoc, AttrStartLoc)) |
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.
&& getASTContext().SourceMgr.isBeforeInBuffer(AttrStartLoc, Range.Start)
ff704d7
to
a58f570
Compare
@swift-ci Please smoke test |
test/IDE/range_info_declattr.swift
Outdated
subscript(idx: Int) -> Int { | ||
@available(*, unavailable) | ||
get { return 0 } | ||
} |
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.
You should probably have a test case with multiple attributes on the same accessor, just in case. (The code looks correct for that already, but still.)
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.
Added!
lib/AST/Decl.cpp
Outdated
SourceLoc AttrStartLoc = Attr->getRangeWithAt().Start; | ||
if (getASTContext().SourceMgr.isBeforeInBuffer(VarLoc, AttrStartLoc) && | ||
getASTContext().SourceMgr.isBeforeInBuffer(AttrStartLoc, Range.Start)) | ||
Range.Start = AttrStartLoc; |
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.
You can use SourceRange::widen
to avoid the second check. Slightly simpler.
Attributes on explicit accessor decl may have attributes. Only when the range contains those attributes, the range-info should report `SingleDecl`.
@swift-ci Please smoke test |
@jrose-apple Mind approving this? |
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, sorry, didn't realize you were waiting on me. Yes, this looks good.
Thank you! |
Revised version of #17239.
Attributes on explicit accessor decl may have attributes. Only when the range contains those attributes (but not attributes on
PatternBindingDecl
), the range-info should reportSingleDecl
.CC: @jrose-apple , @nkcsgexi