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
INT & ANN: Implement intention and fix for struct fields expansion instead of ..
#3996
Conversation
Although this is a draft proposals and ideas are welcome. |
src/test/kotlin/org/rust/ide/annotator/fixes/ExpandStructFieldsFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/intentions/ExpandStructFieldsIntention.kt
Outdated
Show resolved
Hide resolved
7e676ed
to
b5bc990
Compare
..
..
b427da8
to
eca72aa
Compare
a6cc04a
to
72371fe
Compare
ad0a73b
to
36f9583
Compare
src/main/kotlin/org/rust/ide/annotator/fixes/ExpandStructFieldsFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/annotator/fixes/ExpandStructFieldsFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/intentions/ExpandStructFieldsIntention.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/annotator/fixes/ExpandStructFieldsFix.kt
Outdated
Show resolved
Hide resolved
72ee5e2
to
7278d7f
Compare
71cb5e5
to
b13c2c7
Compare
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.
Also take into account the case let Foo(a, .., b)
in the intention tests, looks like now it throws an exception
src/main/kotlin/org/rust/ide/annotator/fixes/ExpandStructFieldsFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/intentions/ExpandStructFieldsIntention.kt
Outdated
Show resolved
Hide resolved
b13c2c7
to
7941287
Compare
src/main/kotlin/org/rust/ide/intentions/ExpandStructFieldsIntention.kt
Outdated
Show resolved
Hide resolved
c8ab108
to
ef5e5a9
Compare
d1efbca
to
0316e0e
Compare
0316e0e
to
b0eac1c
Compare
bors r+ |
3996: INT & ANN: Implement intention and fix for struct fields expansion instead of `..` r=vlad20012 a=shevtsiv <!-- Hello and thank you for the pull request! We don't have any strict rules about pull requests, but you might check https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md for some hints! Note that we need an electronic CLA for contributions: https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md#cla After you sign the CLA, please add your name to https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTORS.txt :) --> In this pull request I intend to do the following: 1) Create E0023 and E0027 error classes and implement analysis for them. 2) Create fix for those errors. 3) Create intention for struct fields expansion. 4) Create a module with shared code for using it in the fix and intention. Once these steps are complete I will squash all the commits and #3928 should be closed after merge. 4094: TY&RES: implement hygiene & infer types in macros r=undin a=vlad20012 Now we take into account any custom macros in type inference Co-authored-by: shevtsiv <rostykshevtsiv@gmail.com> Co-authored-by: vlad20012 <beskvlad@gmail.com>
Build failed (retrying...) |
3996: INT & ANN: Implement intention and fix for struct fields expansion instead of `..` r=vlad20012 a=shevtsiv <!-- Hello and thank you for the pull request! We don't have any strict rules about pull requests, but you might check https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md for some hints! Note that we need an electronic CLA for contributions: https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md#cla After you sign the CLA, please add your name to https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTORS.txt :) --> In this pull request I intend to do the following: 1) Create E0023 and E0027 error classes and implement analysis for them. 2) Create fix for those errors. 3) Create intention for struct fields expansion. 4) Create a module with shared code for using it in the fix and intention. Once these steps are complete I will squash all the commits and #3928 should be closed after merge. Co-authored-by: shevtsiv <rostykshevtsiv@gmail.com>
val declaration = patStruct.path.reference.deepResolve() as? RsFieldsOwner ?: return | ||
val hasTrailingComma = patStruct.rbrace.getPrevNonCommentSibling()?.elementType == RsElementTypes.COMMA | ||
patStruct.dotdot?.delete() | ||
val existingFields = patStruct.patFieldList |
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.
Does this patFieldList
return _
patterns as well?
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.
Does this
patFieldList
return_
patterns as well?
Yes, this patFieldList
also includes underscores, but the patTupleStruct.childrenOfType<RsPatIdent>()
that was used below does not do this. That's why _
were considered wrong fields.
Thank you for the report!
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.
but the patTupleStruct.childrenOfType() that was used below does not do this.
Oh! I didn't catch that. Thanks for your fix!
6465: ANN: support fields under `cfg` attribute in E0023 detection r=vlad20012 a=vlad20012 ... and `Add missing fields` quick fix. Improves #3996 to better work with fields under `#[cfg]` changelog: Fix `cfg` attributes support in `E0023` detection and a corresponding quick fix. 6466: Support function parameters under cfg attributes r=ortem a=vlad20012 Fixes #6148 Correctly handle function parameters under `cfg` attributes in type inference and annotators. Works for: ```rust fn foo( #[cfg(foo)] a: u8, #[cfg(not(foo))] a: i8, ) {} ``` Note that it doesn't works `implement members` quick fix/action because it doesn't support any attributes at all. it should be fixed separately. `self` parameter can also be under cfg. This case is not covered. ### Implementation details There is `RsFunction.valueParameters` that resturns function parameter list after `cfg` evaluation and should be used in type inference/inspections/annotatos/etc, and there is `RsFunction.rawValueParameters` that resturns function parameter list **without** `cfg` evaluation and should be used in PSI manipulations changelog: Support function parameters under `#[cfg()]` attributes 6467: Show cfg-disabled items grayed in structure view r=Undin a=vlad20012 ![image](https://user-images.githubusercontent.com/3221931/100754317-0135a480-33fc-11eb-8c5b-c1a545358046.png) Co-authored-by: vlad20012 <beskvlad@gmail.com>
In this pull request I intend to do the following:
Once these steps are complete I will squash all the commits and #3928 should be closed after merge.