Skip to content

[CodeComplete] Complete argument labels after vararg #36814

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
Apr 9, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 8, 2021

Currently, if the code completion token is after a label that refers to a vararg, it is part of that VarargExpansionExpr, so we don’t suggest the subsequent parameter’s label.

Add special handling to detect this situation and suggest the parameter label.

Fixes rdar://76355192

@ahoppen ahoppen requested a review from rintaro April 8, 2021 10:21
@ahoppen
Copy link
Member Author

ahoppen commented Apr 8, 2021

@swift-ci Please test

Comment on lines 874 to 883
value.test("test", xArg: #^COMPLETE_AFTER_VARARG^#)
// COMPLETE_AFTER_VARARG: Begin completions
// COMPLETE_AFTER_VARARG-DAG: Pattern/ExprSpecific: {#yArg: Foo...#}[#Foo#];
// COMPLETE_AFTER_VARARG-DAG: Pattern/ExprSpecific: {#zArg: Foo...#}[#Foo#];
// COMPLETE_AFTER_VARARG: End completions
value.test("test", xArg: #^COMPLETE_AFTER_VARARG_WITH_PREV_PARAM^#)
// COMPLETE_AFTER_VARARG_WITH_PREV_PARAM: Begin completions
// COMPLETE_AFTER_VARARG_WITH_PREV_PARAM-DAG: Pattern/ExprSpecific: {#yArg: Foo...#}[#Foo#];
// COMPLETE_AFTER_VARARG_WITH_PREV_PARAM-DAG: Pattern/ExprSpecific: {#zArg: Foo...#}[#Foo#];
// COMPLETE_AFTER_VARARG_WITH_PREV_PARAM: End completions
Copy link
Member

@rintaro rintaro Apr 8, 2021

Choose a reason for hiding this comment

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

These tests don't look right. For xArg: #^HERE^#, expected suggestion are global expression completions, but not argument labels.
xArg: #^COMPLETE_AFTER_VARARG_WITH_PREV_PARAM^# is currently the same as COMPLETE_AFTER_VARARG . This probably meant xArg: .bar, #^HERE^# which expects argument labels and global expressions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course 🤦 Updated the tests to test the right thing and the PR to behave according to the updated tests.

Currently, if the code completion token is after a label that refers to a vararg, it is part of that VarargExpansionExpr, so we don’t suggest the subsequent parameter’s label.

Add special handling to detect this situation and suggest the parameter label.

Fixes rdar://76355192
@ahoppen ahoppen force-pushed the pr/complete-label-after-vararg branch from 242d7e2 to 7e536ff Compare April 8, 2021 17:33
@ahoppen
Copy link
Member Author

ahoppen commented Apr 8, 2021

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Apr 8, 2021

Build failed
Swift Test OS X Platform
Git Sha - 7e536ff

@ahoppen
Copy link
Member Author

ahoppen commented Apr 9, 2021

@swift-ci Please smoke test macOS

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

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

Thanks!

@ahoppen ahoppen merged commit 2922151 into swiftlang:main Apr 9, 2021
@ahoppen ahoppen deleted the pr/complete-label-after-vararg branch April 9, 2021 16:53
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