aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src
Commit message (Collapse)AuthorAgeFilesLines
* Remove more unreachable pubsAleksey Kladov2020-11-022-5/+5
|
* Merge #6257bors[bot]2020-10-261-11/+11
|\ | | | | | | | | | | | | | | 6257: Don't suggest extracting out 1-tuple enum variants r=matklad a=repnop Fixes #6241. Co-authored-by: Wesley Norris <[email protected]>
| * Don't suggest extracting out 1-tuple enum variantsWesley Norris2020-10-261-11/+11
| | | | | | | | Fixes #6241.
* | Better ordering of assistsAleksey Kladov2020-10-261-2/+3
| |
* | Merge #6333bors[bot]2020-10-261-7/+80
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | 6333: Don't interpret type path as part of visibility. r=matklad a=ArifRoktim This closes #5902. I only check that the next token isn't equal to `T![:]`, instead of the next two not being equal to `T![::]`. Is that ok? Co-authored-by: Arif Roktim <[email protected]>
| * | Allow assist move_arm_cond_to_match_guard inside blocksArif Roktim2020-10-241-7/+80
| | |
* | | Keep parens around in remove-dbg for range expressionsLukas Wirth2020-10-251-8/+9
| | |
* | | Don't keep parens around in remove-dbgLukas Wirth2020-10-251-1/+61
| | |
* | | Don't keep parens around with remove-dbg when encountering method chainingLukas Wirth2020-10-251-0/+20
| | |
| | |
| \ \
*-. \ \ Merge #6331 #6342bors[bot]2020-10-2411-131/+17
|\ \ \ \ | | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6331: correct hover text for items with doc attribute with raw strings r=matklad a=JoshMcguigan Fixes #6300 by improving the handling of raw string literals in attribute style doc comments. This still has a bug where it could consume too many `"` at the start or end of the comment text, just as the original code had. Not sure if we want to fix that as part of this PR or not? If so, I think I'd prefer to add a unit test for either the `as_simple_key_value` function (I'm not exactly sure where this would belong / how to set this up) or create a `fn(&SmolStr) -> &SmolStr` to unit test by factoring out the `trim` operations from `as_simple_key_value`. Thoughts on this? 6342: Shorter dependency chain r=matklad a=popzxc Continuing implementing suggestions from the `Completion refactoring` zulip thread. This PR does the following: - Removes dependency of `completions` on `assists` by moving required functionality into `ide_db`. - Moves completely `call_info` crate into `ide_db` as it looks like it fits perfect there. - Adds a bunch of new tests and docs. - Adds the re-export of `base_db` to the `ide_db` and removes direct dependency on `base_db` from other crates. The last point is controversial, I guess, but I noticed that in places where `ide_db` is used, `base_db` is also *always* used. Thus I think the dependency on the `base_db` is implied by the fact of `ide_db` interfaces, and thus it makes sense to just provide `base_db` out of the box. Co-authored-by: Josh Mcguigan <[email protected]> Co-authored-by: Igor Aleksanov <[email protected]>
| | * | Re-export base_db from ide_dbIgor Aleksanov2020-10-246-6/+6
| | | |
| | * | Remove dependency on 'assists' from 'completion' crateIgor Aleksanov2020-10-245-125/+11
| |/ /
* / / Fix indentation of inserted use statementsFlorian Diebold2020-10-241-34/+132
|/ /
* | generate_impl assist respect cfg attributes #6312Benjamin Coenen2020-10-221-2/+40
| | | | | | | | Signed-off-by: Benjamin Coenen <[email protected]>
* | Merge #6256bors[bot]2020-10-203-0/+160
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | 6256: Assist: replace string with char r=bnjjj a=bnjjj close #6252 Co-authored-by: Benjamin Coenen <[email protected]> Co-authored-by: Coenen Benjamin <[email protected]>
| * | Update crates/assists/src/handlers/replace_string_with_char.rsCoenen Benjamin2020-10-201-1/+1
| | | | | | | | | Co-authored-by: Aleksey Kladov <[email protected]>
| * | Assist: replace string with charBenjamin Coenen2020-10-202-8/+39
| | | | | | | | | | | | Signed-off-by: Benjamin Coenen <[email protected]>
| * | replace_string_with_char #6252Benjamin Coenen2020-10-162-0/+129
| |/ | | | | | | Signed-off-by: Benjamin Coenen <[email protected]>
* | Merge #6172bors[bot]2020-10-205-24/+1087
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6172: Add qualify path assist r=matklad a=Veykril This implements a `qualify_path` assist which works quite similar to the `auto_import` assist but instead of adding imports to the file it well, qualifies the path. This PR also moves out the `AutoImportAssets` struct and functions from `auto_import` into a utils submodule as most of this is now shared between `auto_import` and `qualify_path`. Changes made to `AutoImportAssets` are solely in its `search_for_imports` function which now takes a prefixed parameter to discern between using `find_use_path_prefixed` and `find_use_path` as the former is the required behavior by `auto_import` and the latter by this assist. For missing imported traits instead of importing this will qualify the path with a trait cast as in: ```rust test_mod::TestStruct::TEST_CONST<|> ``` becomes ```rust <test_mod::TestStruct as test_mod::TestTrait>::TEST_CONST ``` and for trait methods ideally it would do the following: ```rust let test_struct = test_mod::TestStruct {}; test_struct.test_meth<|>od() ``` becomes ```rust let test_struct = test_mod::TestStruct {}; test_mod::TestTrait::test_method(&test_struct) ``` Fixes #4124. Co-authored-by: Lukas Wirth <[email protected]>
| * | De-duplicate `add_group` callsite in qualify_pathLukas Wirth2020-10-161-121/+108
| | |
| * | Properly qualify trait methods in qualify_path assistLukas Wirth2020-10-154-70/+115
| | |
| * | Add mark tests to qualify_path assistLukas Wirth2020-10-141-0/+9
| | |
| * | Add qualify path assistLukas Wirth2020-10-142-0/+1022
| | |
* | | Don't rely on display names in inlay_hintsAleksey Kladov2020-10-203-13/+16
| | |
* | | Rename declaration_name -> display_nameAleksey Kladov2020-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Declaration names sounds like a name of declaration -- something you can use for analysis. It empathically isn't, and is just a label displayed in various UI. It's important not to confuse the two, least we accidentally mix semantics with UI (I believe, there's already a case of this in the FamousDefs at least).
* | | Minor, rename featureAleksey Kladov2020-10-191-1/+1
| | |
* | | Change visibility works for type aliasesAleksey Kladov2020-10-182-5/+19
| |/ |/|
* | More idiomatic classification APIAleksey Kladov2020-10-152-4/+4
| |
* | Document auto_import as a featureLukas Wirth2020-10-151-0/+55
|/
*-. Merge #6207 #6224 #6226 #6227bors[bot]2020-10-143-241/+297
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6207: Extract ImportAssets out of auto_import r=matklad a=Veykril See https://github.com/rust-analyzer/rust-analyzer/pull/6172#issuecomment-707182140 I couldn't fully pull out `AssistContext` as `find_node_at_offset_with_descend`: https://github.com/rust-analyzer/rust-analyzer/blob/81fa00c5b5d5ffb559a39c7ff5190a2519a8ea61/crates/assists/src/assist_context.rs#L90-L92 requires the `SourceFile` which is private in it and I don't think making it public just for this is the right call? 6224: :arrow_up: salsa r=matklad a=matklad bors r+ 🤖 6226: Add reminder to update lsp-extensions.md r=matklad a=matklad bors r+ 🤖 6227: Reduce bors timeout r=matklad a=matklad bors r+ 🤖 Co-authored-by: Lukas Wirth <[email protected]> Co-authored-by: Aleksey Kladov <[email protected]>
* | | Fix stackoverflow in insert_use::recursive_mergeLukas Wirth2020-10-143-2/+53
| |/ |/|
* | Fix MergeBehaviour::Full not working when merging nested long pathsLukas Wirth2020-10-132-4/+33
| |
| * Slightly cleanup import_assets moduleLukas Wirth2020-10-132-62/+84
| |
| * Adhere to style guidelines in import_assetsLukas Wirth2020-10-132-43/+45
| |
| * Extract ImportAssets out of auto_importLukas Wirth2020-10-133-241/+273
|/
* Merge #6130 #6135bors[bot]2020-10-122-67/+69
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6130: Items case quick fix (snake_case / UPPER_SNAKE_CASE / CamelCase) r=matklad a=popzxc Resolves #4598. After a third try, it finally works. Boy, it appeared tougher than it seemed. Initially I thought like "Ha, `rustc` already tells us where idents are named incorrectly. It shouldn't be that hard, should it?". Well, the problems with the information provided by `rustc` appeared shortly: - `rustc` warnings are `flycheck` warnings, which are slightly aside from our diagnostics with fixes. When we map flycheck diagnostic to LSP, we can convert it into a fix, but only if it's marked as `Applicability::MachineApplicable`. Name case fix is marked `Applicability::MaybeIncorrect`, and for a reason: it only suggest to rename symbol under cursor, without tracking any references. - Warning spawned by `rustc` are identified by string labels rather than enum. It means that if one day the diagnostic will be renamed in `rustc`, `rust-analyzer` code will still compile, but won't find the required diagnostic by name anymore. If by chance this will happen when some unlucky guy will decide to create their first pull request, they'll be confused by suddenly failing tests (likely) not related to their changes. - Even if we'll try to build fixes atop of `rustc` warnings, we'll have to do it in the `rust_analyzer::diagnostics::to_proto` module, which is far less convenient for that matter than `ide` crate. That's why I decided that it's worth a separate `rust-analyzer` diagnostic, which will implement `DiagnosticWithFix` trait. After that, I discovered that currently `hir_ty::diagnostics` only check `DefWithBody` types, like function bodies. I had to add support for diagnostics which look at any `ModuleDef`. And of course, since I'd added a lot of new functionality, it required extensive testing. That explains why the diff is so big for a (looking) relatively small feature. I hope that this PR doesn't only add a small feature, but also creates a base for building another features. ## Example: ![case_quick_fix](https://user-images.githubusercontent.com/12111581/95008475-e07ee780-0622-11eb-9978-62a9ea0e7782.gif) P.S. My eyes were bleeding when I had to write the code for the example... 6135: when generating new function, focus on return type instead of body r=matklad a=bnjjj I made a little change when we use the assist to generate a new function, instead of focusing on the function body, it will focus on return type Co-authored-by: Igor Aleksanov <[email protected]> Co-authored-by: Benjamin Coenen <[email protected]>
| * when generating new function, focus on return type instead of bodyBenjamin Coenen2020-10-082-67/+69
| | | | | | | | Signed-off-by: Benjamin Coenen <[email protected]>
* | adt: correctly inherit field visibility from enumJonas Schievink2020-10-091-6/+4
|/ | | | | | | Previously, "find all references" on a variant field wouldn't find any references outside the defining module. This is because variant fields were incorrectly assumed to be private, like struct fields without explicit visibility, but they actually inherit the enum's visibility.
* Clean up inlay_hintsLukas Wirth2020-10-071-1/+12
|
* Shorten iterator hints for std::iter iterators behind referencesLukas Wirth2020-10-071-1/+1
|
* Shorten iterator chain hintsLukas Wirth2020-10-071-7/+34
|
* Move IntoIterator into FamousDefsLukas Wirth2020-10-071-8/+15
|
* Use FamousDefs for shorten_iterator hintLukas Wirth2020-10-061-12/+49
|
* Move ModPath->ast::Path function to IDE layerAleksey Kladov2020-10-066-20/+62
| | | | closes #6092
* Merge #6139bors[bot]2020-10-062-7/+14
|\ | | | | | | | | | | | | | | | | | | | | | | 6139: Make find_path_prefixed configurable r=matklad a=Veykril This makes `find_path_prefixed` more configurable allowing one to choose whether it always returns absolute paths, self-prefixed paths or to ignore local imports when building the path. The config names are just thrown in here, taking better names if they exist :) This should fix #6131 as well? Co-authored-by: Lukas Wirth <[email protected]>
| * Make ImportPrefix a configuration optionLukas Wirth2020-10-052-7/+14
| |
* | Do not leave braces for colons in dbg!Kirill Bulatov2020-10-061-2/+7
| |
* | Merge #6111bors[bot]2020-10-054-5/+738
|\ \ | |/ |/| | | | | | | | | | | | | | | | | 6111: Add assist for converting the base of integer literals. r=SomeoneToIgnore a=vlakreeh This PR adds an assist similar to Intellij's [convert number to](https://i.imgur.com/JH6wstP.png). It also does a small refactor to [assists/src/tests.rs](https://github.com/rust-analyzer/rust-analyzer/blob/fc34403018079ea053f26d0a31b7517053c7dd8c/crates/assists/src/tests.rs) to add the ability to specify the resolved assist for a specific action within an assist group. ## Demo ![Demo of the assist in action](https://i.imgur.com/MBhdPFH.gif) Co-authored-by: vlakreeh <[email protected]>
| * Add tests for convert integer literal assistvlakreeh2020-09-301-4/+570
| |
| * Add ability to specify ResolvedAssist by labelvlakreeh2020-09-291-5/+22
| |