Skip to content

[SourceKit] Include generated macro buffers in diagnostic responses #65472

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

Merged
merged 4 commits into from
May 3, 2023

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Apr 27, 2023

Introduce a new key generated_buffers, which stores an array of generated buffers. These include the buffer text, as well as its original location and any parent buffers.

While here, also fix rdar://107281079 such that only apply the filename fallback logic to the pretty-printed Decl case. We ought to remove this fallback once the editor can handle it though.

rdar://107281079
rdar://107952288

@hamishknight hamishknight requested a review from bnbarham April 27, 2023 20:32
if (auto Info = SM.getGeneratedSourceInfo(*BufferID)) {
// Don't include this information for replaced function body buffers, as
// they'll just be referencing the original file.
// FIXME: Does this mean that the location information we'll be giving
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReplacedFunctionBody only happens for completion/cursor info at the moment. So we should never end up with that case here. You could add an assertion if you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually hit this case when doing multiple compile requests

Copy link
Contributor

@bnbarham bnbarham Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting. @rintaro despite you just talking compile I didn't think about it here. It does seem like we would be messing up diagnostics then, do we actually send diagnostics back there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But I didn't think much about diagnostics for compile requests. In our intended use cases, I thought we only wanted to know if there's any error or not (succeeded or not). But anyway compile request hasn't been maintained well, and probably requires major refinements.

@hamishknight hamishknight force-pushed the buffering branch 2 times, most recently from 3e86ff3 to 7983719 Compare April 28, 2023 13:17
@hamishknight hamishknight marked this pull request as ready for review April 28, 2023 13:18
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me

@hamishknight hamishknight force-pushed the buffering branch 2 times, most recently from 7f89aa8 to 9570c77 Compare April 28, 2023 19:07
Use this to simplify the writing of ranges into
SourceKit responses.
This could cause us to double up on the same note
for nested macro expansions, as we'd generate the
note, then when recursing back through the function
we'd compute the same note again. Also remove the
seemingly unused `lastBufferID` param.
Introduce a new key `generated_buffers`, which
stores an array of generated buffers. These
include the buffer text, as well as its original
location and any parent buffers.

While here, also fix rdar://107281079 such that
only apply the filename fallback logic to the
pretty-printed Decl case. We ought to remove this
fallback once the editor can handle it though.

rdar://107281079
rdar://107952288
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@bnbarham
Copy link
Contributor

bnbarham commented May 2, 2023

Are the double diagnostics fixed after #65519?

@hamishknight
Copy link
Contributor Author

Yeah, I updated the tests

@hamishknight hamishknight merged commit 2338b4c into swiftlang:main May 3, 2023
@hamishknight hamishknight deleted the buffering branch May 3, 2023 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants