aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | Return to the status quo in #8129Dawer2021-04-181-0/+2
| | | | |
| * | | | Prevent adding useless match armsDawer2021-04-181-11/+27
| | | | |
| * | | | Test fill-match-arms assist: partial with wildcardsDawer2021-04-171-0/+34
| | | | |
| * | | | Fill partial match arms for a tuple of enumsDawer2021-04-161-17/+37
| | | | |
* | | | | Merge #8467bors[bot]2021-04-191-0/+227
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8467: Adds impl Deref assist r=jhgg a=jhgg This PR adds a new `generate_deref` assist that automatically generates a deref impl for a given struct field. Check out this gif: ![2021-04-11_00-33-33](https://user-images.githubusercontent.com/5489149/114296006-b38e1000-9a5d-11eb-9112-807c01b8fd0a.gif) -- I have a few Q's: - [x] Should I write more tests, if so, what precisely should I test for? - [x] I have an inline question on line 65, can someone provide guidance? :) - [x] I can implement this for `ast::TupleField` too. But should it be a separate assist fn, or should I try and jam both into the `generate_deref`? - [x] I want to follow this up with an assist on `impl $0Deref for T {` which would automatically generate a `DerefMut` impl that mirrors the Deref as well, however, I could probably use some pointers on how to do that, since I'll have to reach into the ast of `fn deref` to grab the field that it's referencing for the `DerefMut` impl. Co-authored-by: jake <[email protected]>
| * | | | implement field stuff toojake2021-04-191-22/+106
| | | | |
| * | | | Adds impl Deref assistjake2021-04-111-0/+143
| | |/ / | |/| |
* | | | Fill match arms for a tuple of a single enum.Dawer2021-04-161-10/+12
| |/ / |/| |
* | | Merge #8415bors[bot]2021-04-131-2/+46
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8415: Fix faulty assertion when extracting function with macro call r=matklad a=brandondong **Reproduction:** ```rust fn main() { let n = 1; let k = n * n; dbg!(n); } ``` 1. Select the second and third lines of the main function. Use the "Extract into function" code assist. 2. Panic occurs in debug, error is logged in release: "[ERROR ide_assists::handlers::extract_function] assertion failed: matches!(path, ast :: Expr :: PathExpr(_))". 3. Function generates successfully on release where the panic was bypassed. ```rust fn fun_name(n: i32) { let k = n * n; dbg!(n); } ``` **Cause:** - The generated function will take `n` as a parameter. The extraction logic needs to search the usages of `n` to determine whether it is used mutably or not. The helper `path_element_of_reference` is called for each usage but the second usage is a macro call and fails the `Expr::PathExpr(_)` match assertion. - The caller of `path_element_of_reference` does implicitly assume it to be a `Expr::PathExpr(_)` in how it looks at its parent node for determining whether it is used mutably. This logic will not work for macros. - I'm not sure if there are any other cases besides macros where it could be something other than a `Expr::PathExpr(_)`. I tried various examples and could not find any. **Fix:** - Update assertion to include the macro case. - Add a FIXME to properly handle checking if a macro usage requires mutable access. For now, return false instead of running the existing logic that is tailored for `Expr::PathExpr(_)`'s. Co-authored-by: Brandon <[email protected]>
| * | | Add macro testBrandon2021-04-111-0/+32
| | | |
| * | | Add FIXME for macro caseBrandon2021-04-081-0/+13
| | | |
| * | | Fix faulty assertion when extracting function with macro callBrandon2021-04-081-2/+1
| | | |
* | | | internal: don't use `#[should_panic]` for testsAleksey Kladov2021-04-131-16/+2
| |/ / |/| |
* | | Merge #8436bors[bot]2021-04-101-19/+109
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8436: Fix extract function's mutability of variables outliving the body r=matklad a=brandondong **Reproduction:** ```rust fn main() { let mut k = 1; let mut j = 2; j += 1; k += j; } ``` 1. Select the first to third lines of the main function. Use the "Extract into function" code assist. 2. The output is the following which does not compile because the outlived variable `k` is declared as immutable: ```rust fn main() { let (k, j) = fun_name(); k += j; } fn fun_name() -> (i32, i32) { let mut k = 1; let mut j = 2; j += 1; (k, j) } ``` 3. We would instead expect the output to be: ```rust fn main() { let (mut k, j) = fun_name(); k += j; } ``` **Fix:** - Instead of declaring outlived variables as immutable unconditionally, check for any mutable usages outside of the extracted function. Co-authored-by: Brandon <[email protected]>
| * | | Fix extract function's mutability of variables outliving the bodyBrandon2021-04-091-19/+109
| |/ /
* | | Insert unnamed consts to ChildBySource DynMapLukas Wirth2021-04-091-1/+1
| | |
* | | Merge #8207bors[bot]2021-04-081-11/+94
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | 8207: Show dbg remove assist on empty contents r=edwin0cheng a=ivan770 Closes #8185 Co-authored-by: ivan770 <[email protected]> Co-authored-by: ivan770 <[email protected]>
| * | Apply test style fixes to all empty remove_dbg testsivan7702021-03-291-21/+17
| | |
| * | Update crates/ide_assists/src/handlers/remove_dbg.rs ivan7702021-03-291-5/+9
| | | | | | | | | | | | | | | Apply standard test style fixes Co-authored-by: Aleksey Kladov <[email protected]>
| * | Replace empty dbg with unit in letexprs, better removal in blocksivan7702021-03-271-13/+72
| | |
| * | Replace match on option with ifivan7702021-03-271-3/+4
| | |
| * | Remove dbg expression and newline as wholeivan7702021-03-271-6/+28
| | |
| * | Show dbg remove assist on empty contentsivan7702021-03-261-8/+9
| | |
* | | Merge #8339bors[bot]2021-04-051-18/+55
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8339: fix: extract variable works in guards r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
| * | | fix: extract variable works in guardsAleksey Kladov2021-04-051-18/+55
| | |/ | |/| | | | | | | closes #8336
* | | Merge #8326bors[bot]2021-04-051-39/+50
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | 8326: Rewrite reorder fields assist to use mutable syntax trees r=matklad a=Veykril This also instead uses `Either` to use the typed `RecordPat` and `RecordExpr` nodes, this unfortunately gives a bit of code duplication Co-authored-by: Lukas Wirth <[email protected]>
| * | Rewrite reorder fields assist to use mutable syntax treesLukas Wirth2021-04-031-39/+50
| | |
* | | Convert Into to From assistGraeme Coupar2021-04-031-0/+355
|/ / | | | | | | | | | | | | | | | | | | | | | | This adds a "Convert Into to From" assist, useful since clippy has recently started adding lints on every `Into`. It covers converting the signature, and converting any `self`/`Self` references within the body to the correct types. It does assume that every instance of `Into` can be converted to a `From`, which I _think_ is the case now. Let me know if there's something I'm not thinking of and I can try and make it smarter.
* | Merge #8210bors[bot]2021-03-311-0/+149
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | 8210: Implement "Extract type alias" assist r=jonas-schievink a=jonas-schievink Co-authored-by: Jonas Schievink <[email protected]> Co-authored-by: Jonas Schievink <[email protected]>
| * | Don't use snippetsJonas Schievink2021-03-291-17/+12
| | |
| * | Use `find_node_at_range`Jonas Schievink2021-03-291-25/+3
| | |
| * | Snippet support in extract_type_aliasJonas Schievink2021-03-271-13/+24
| | |
| * | Implement "Extract type alias" assistJonas Schievink2021-03-261-0/+165
| |/
* | Merge #8267bors[bot]2021-03-311-0/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8267: Adding gifs and screenshots for features in manual r=matklad a=MozarellaMan For #6539 This includes most of gif or screenshot examples of most items in the "Features" header. With the exceptions of: - **On Typing Assists** - couldn't get it to work for a demo, I'm probably missing something? - **Structural search and replace** - looked to be already a visual example of the feature - **Workspace symbol** - wasn't sure how best to show this, all of the examples maybe? Also wasn't sure of the best code example to show it off - **Semantic Syntax Highlighting** - seemed obvious enough to not need a screenshot, but I could easily add this All the gifs/pngs are hosted in this [comment](https://github.com/rust-analyzer/rust-analyzer/issues/6539#issuecomment-809574840). Please let me know if any of them aren't suitable (and why) and I'll improve it! Or if you don't like the theme/font Co-authored-by: Ayomide Bamidele <[email protected]>
| * | Gifs and screenshots for features in manualAyomide Bamidele2021-03-311-0/+2
| | |
* | | Rename target_ty to self_tyLukas Wirth2021-03-292-2/+2
|/ /
* | Merge #8213bors[bot]2021-03-271-3/+14
|\ \ | | | | | | | | | | | | | | | | | | | | | 8213: Added support for const generics in impl generation r=Veykril a=ivan770 Closes #8211 Co-authored-by: ivan770 <[email protected]>
| * | Added support for const generics in impl generationivan7702021-03-271-3/+14
| |/
* / syntax: return owned string instead of leaking stringcynecx2021-03-264-5/+7
|/
* refine comment style of testshi-rustin2021-03-242-48/+48
|
* Merge #8168bors[bot]2021-03-241-7/+70
|\ | | | | | | | | | | | | | | 8168: correct `convert to guard return` let_stmt r=Veykril a=hi-rustin close https://github.com/rust-analyzer/rust-analyzer/issues/8074 Co-authored-by: hi-rustin <[email protected]>
| * correct `convert to guard return` let_stmthi-rustin2021-03-241-7/+70
| | | | | | | | | | | | | | | | fix fix add check
* | CleanupAleksey Kladov2021-03-231-67/+45
| |
* | Simplify codeAleksey Kladov2021-03-232-37/+15
| | | | | | | | changelog: skip
* | Use styleguide conforming import for ast nodesAleksey Kladov2021-03-231-34/+36
| |
* | Unify test styleAleksey Kladov2021-03-231-38/+52
| | | | | | | | changelog skip
* | Tweak assits API to fit mutable syntax treesAleksey Kladov2021-03-232-20/+12
|/ | | | changelog: skip
* rewrite merge use trees assist to use muatable syntax treesAleksey Kladov2021-03-222-37/+42
| | | | changelog internal
* clippy::complexity simplifications related to IteratorsMatthias Krüger2021-03-213-16/+10
|
* Less reallocationsKirill Bulatov2021-03-211-1/+0
|