Skip to content

[CursorInfo] Pass primary path to allow comparing previous ASTs #66907

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 1 commit into from
Jun 26, 2023

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Jun 23, 2023

Update the cursor requests to also pass in their primary file. Snapshots should be compared using this file, not the input buffer name. This fixes AST re-use when the AST is usable with snapshots.

Resolves rdar://110344363.

@bnbarham bnbarham requested review from ahoppen and rintaro as code owners June 23, 2023 23:20
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@bnbarham bnbarham changed the title [Test] Update cursor info test to actually check result [CursorInfo] Pass primary path to allow comparing previous ASTs Jun 24, 2023
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@bnbarham bnbarham requested a review from rintaro June 24, 2023 02:44
Comment on lines -1432 to +1435
InputFile, /*IsRealpath=*/true))
PrimaryFilePath, /*IsRealpath=*/true))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the most significant change. InputFile is almost always empty, except in the case of generated buffers (eg. expanded macros). It should have been using the primary file path, which wasn't being passed in. So most of the change is just passing it to all the various callers.

Update the cursor requests to also pass in their primary file. Snapshots
should be compared using this file, not the input buffer name. This
fixes AST re-use when the AST is usable with snapshots.

Resolves rdar://110344363.
// RUN: -req=cursor -offset=5 %t/func.swift -- %t/func.swift == \
// RUN: -req=edit -offset=0 -length=0 -replace="// some comment\n" -req-opts=enablesyntaxmap=0,enablesubstructure=0,enablediagnostics=0 %t/func.swift -- %t/func.swift == \
// RUN: -req=cursor -offset=21 %t/func.swift -- %t/func.swift
// RUN: -req=cursor -offset=5 %t/func.swift -- %t/func.swift
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just converts it back to before the previous PR.

@bnbarham
Copy link
Contributor Author

@swift-ci please test

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.

Nice find

@ahoppen
Copy link
Member

ahoppen commented Jun 26, 2023

@swift-ci Please test macOS

@bnbarham bnbarham merged commit 93ec785 into swiftlang:main Jun 26, 2023
@bnbarham bnbarham deleted the fix-reuse-test branch June 26, 2023 17:50
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.

3 participants