Commit Graph

896 Commits

Author SHA1 Message Date
Kirill Bulatov
8089a227f4 Tests added 2021-05-03 18:40:04 +03:00
Kirill Bulatov
28293d370f Add docs and use better naming 2021-05-03 18:16:35 +03:00
Kirill Bulatov
1679a376f3 Resolve single assist only 2021-05-03 18:03:28 +03:00
Kirill Bulatov
e5cdcb8b12 Add a way to resolve certain assists 2021-05-03 17:14:49 +03:00
Aleksey Kladov
cd69307aee fix: don't duplicate Progerss::Finised for cache priming 2021-05-02 21:45:00 +03:00
Aleksey Kladov
1a01a5ae19 internal: fix naming polarity
Type Constructors have *parameters*, when they are substituted with type
*arguments*, we have a type.
2021-04-30 11:55:59 +03:00
m5tfi
5778ab1e41 add folding for where clauses 2021-04-30 10:18:36 +02:00
Bastian Kersting
421cf9a1bd Fixed formatting 2021-04-26 11:37:28 +02:00
Bastian Kersting
336b81abd7 Added mutable semantic token modifier for &mut self methods 2021-04-26 09:24:18 +02:00
Danny Zhu
09fc5e1dd7 Check more carefully for cases where a rename can't be done
Attempting to rename an element of a tuple field would previously
replace the type with the new name, which doesn't make sense; now it
fails instead.

The check is done in both `prepare_rename` and `rename` so that the case
is caught before the user is prompted for a new name. Some other
existing failure cases are also now additionally checked in
`prepare_rename`.
2021-04-25 14:08:56 -07:00
Lukas Wirth
1e88f5ec8e Simplify highlight token match guards 2021-04-23 17:27:18 +02:00
Lukas Wirth
ef6f596b4b Sort HlMod variants and ALL const 2021-04-23 17:24:58 +02:00
Lukas Wirth
c005ce60a0 Tag yield and await as ControlFlow in semantic highlighting 2021-04-23 17:24:45 +02:00
Aleksey Kladov
cdfe5a8be0 fix: no more Registering progress handler for token rustAnalyzer/Indexing failed. 2021-04-20 22:54:05 +03:00
bors[bot]
b6a7276c54
Merge #8586
8586: Replace SyntaxRewriter usage with ted in eager::eager_macro_recur r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 18:03:56 +00:00
Lukas Wirth
952fc23694 Replace SyntaxRewriter with ted in exppand_macro::expand_macro_recur 2021-04-19 19:43:26 +02:00
bors[bot]
2b5f35ca4b
Merge #8582
8582: Fix typo: comparision -> comparison r=kjeremy a=stanciuadrian

Closes #8576 

Co-authored-by: Adrian Stanciu <stanciu.adrian@gmail.com>
2021-04-19 15:47:18 +00:00
Adrian Stanciu
1c75d8975c Fix typo: comparision -> comparison 2021-04-19 18:44:38 +03:00
Lukas Wirth
6142afeafd Support crates/module roots in external_docs 2021-04-19 15:50:04 +02:00
Lukas Wirth
2f62c0117a Check for rust doc code attributes like rustdoc does 2021-04-19 13:32:52 +02:00
Lukas Wirth
8a959497b1 Don't require all doc fences to be valid for identifying rust code 2021-04-19 11:41:45 +02:00
bors[bot]
75bf832899
Merge #8540
8540: Prevent being able to rename items that are not part of the workspace r=Veykril a=Veykril

This change causes renames that happen on items coming from crates outside the workspace to fail. I believe this should be the right approach, but usage of cargo's workspace might not be entirely correct for preventing these kinds of refactoring from touching things they shouldn't. I'm not entirely sure?

cc #6623, this is one of the bigger footguns when it comes to refactoring, especially in combination with import aliases people tend to rename items coming from a crates dependency which this prevents.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 07:57:40 +00:00
Lukas Wirth
c447a795ab Prevent being able to rename items that are not part of the workspace 2021-04-18 12:44:00 +02:00
Chayim Refael Friedman
6c287e1504 Accept E<error_number> notation in doctests
```compile_fail,E0000
```

The code was stolen from rustdoc at 392ba2ba1a/src/librustdoc/html/markdown.rs (L866-L867)
2021-04-18 06:15:40 +03:00
Jonas Schievink
ff858376aa Include path in unresolved-macro-call diagnostic 2021-04-16 15:48:03 +02:00
Jonas Schievink
30aae2cefb Move cursor position when using item movers 2021-04-14 00:03:04 +02:00
Jonas Schievink
43071e81a6 internal: follow test style guide in typing.rs 2021-04-13 14:31:05 +02:00
bors[bot]
03e0bf7f55
Merge #8354
8354: Distinguishing between different operators in semantic highlighting r=matklad a=chetankhilosiya



Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
2021-04-13 11:46:23 +00:00
bors[bot]
0c02208fd8
Merge #8489
8489: Indent block expressions on enter r=matklad a=jonas-schievink

This improves on https://github.com/rust-analyzer/rust-analyzer/pull/8388 by also indenting the created block expression on enter.

![on enter](https://user-images.githubusercontent.com/1786438/114444123-cb38d600-9bce-11eb-8af2-8e8d1c0f9908.gif)


Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-13 10:06:36 +00:00
bors[bot]
d8120ed1a0
Merge #8500
8500: internal: fix flakiness of accidentally quadratic test r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-13 09:56:45 +00:00
Aleksey Kladov
327323ad25 internal: fix flakiness of accidentally quadratic test 2021-04-13 12:56:24 +03:00
Aleksey Kladov
db2a989565 internal: don't use #[should_panic] for tests 2021-04-13 12:21:59 +03:00
Aleksey Kladov
06a633ff42 feat: improve performance by delaying computation of fixes for diagnostics 2021-04-13 12:09:04 +03:00
Aleksey Kladov
04b5fcfdb2 Ensure that listing&resolving code actions use the same set of actions 2021-04-13 11:27:00 +03:00
Jonas Schievink
a8ca4666f1 Add a cov_mark 2021-04-13 00:51:10 +02:00
Jonas Schievink
89f015ead9 Simplify multiline check 2021-04-12 21:41:44 +02:00
Jonas Schievink
dd1832c016 Indent block expressions on enter 2021-04-12 20:35:38 +02:00
Jakub Kądziołka
2f60cec3ac
Fix typo: liner -> linear
🙈
2021-04-12 20:20:25 +02:00
Aleksey Kladov
426d098bd6 internal: prepare for lazy diagnostics 2021-04-12 17:58:01 +03:00
Jonas Schievink
e2c1da36f5 Support macros in pattern position 2021-04-11 01:25:50 +02:00
Aleksey Kladov
e012efca27 Let's try testing for "is not quadratic" condition 2021-04-10 12:43:07 +03:00
Jonas Schievink
ac980e96e5 Shrink unlinked-file diagnostic to 3 characters 2021-04-09 14:22:38 +02:00
bors[bot]
354151df35
Merge #8429
8429: 8425: Added documentation for on enter covering //! doc comments. r=jonas-schievink a=chetankhilosiya

Also added passing test case.

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
2021-04-08 23:33:36 +00:00
Chetan Khilosiya
4a9dd149aa 8024: Added the trait modifier for assoc types. 2021-04-09 01:00:35 +05:30
Chetan Khilosiya
a8b5400cc6 8425: Added documentation for on enter covering //! doc comments.
Also added passing test case.
2021-04-09 00:31:07 +05:30
Chetan Khilosiya
b232549653 8279: Fix the not operator use and test case fix. 2021-04-08 22:58:26 +05:30
Chetan Khilosiya
1735b3ef6a 8279: Added initial implementation for
Operator semantic highlighting.
2021-04-08 22:58:26 +05:30
bors[bot]
94d9fc2a28
Merge #8421
8421: Reduce allocations in "Expand macro" formatter r=edwin0cheng a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-04-08 15:43:30 +00:00
Laurențiu Nicola
48b946bde1 Reduce allocations in Expand macro 2021-04-08 17:37:43 +03:00
Lukas Wirth
4b555ab1d9 Emit folding ranges for multiline array literals 2021-04-08 00:12:11 +02:00
Jonas Schievink
d789cf8f31 Document } insertion 2021-04-07 17:19:42 +02:00
Jonas Schievink
39d59fb06f Make better use of stdx::always 2021-04-07 16:44:25 +02:00
Jonas Schievink
3f599ae4ed Rewrite, reparse modified file 2021-04-07 16:38:04 +02:00
Jonas Schievink
17a1011a12 simplify 2021-04-07 16:38:04 +02:00
Jonas Schievink
d75cacc601 Use stdx::always 2021-04-07 16:38:04 +02:00
Jonas Schievink
61e292fab1 Complete braces more aggressively 2021-04-07 16:38:04 +02:00
Jonas Schievink
36cd724b7b Autoclose blocks when typing { 2021-04-07 16:38:04 +02:00
Emmanuel Thompson
35bec31bca Add space after lifetime
In macro expansion, this lead to invalid syntax
2021-04-06 23:22:44 -04:00
bors[bot]
c2be91dcd8
Merge #8245
8245: Properly resolve intra doc links in hover and goto_definition r=matklad a=Veykril

Unfortunately involves a bit of weird workarounds due to pulldown_cmark's incorrect lifetimes on `BrokenLinkCallback`... I should probably open an issue there asking for the fixes to be pushed to a release since they already exist in the repo for quite some time it seems.

Fixes #8258, Fixes #8238

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-05 12:30:20 +00:00
Florian Diebold
cd227f581e Add and start using TraitRef and ProjectionTy builders 2021-04-04 13:16:38 +02:00
Edwin Cheng
b636080f67 Fix joinLines panic if run on the empty last line 2021-04-03 11:20:16 +08:00
Jonas Schievink
7ceaba21df Only populate prelude for crate-level DefMaps 2021-04-02 19:00:26 +02:00
bors[bot]
5ef0c7a213
Merge #8283
8283: Resolve associated types r=flodiebold a=Veykril

Prior we were only resolving paths until the first type was found, then discarding the result if the path wasn't fully consumed. That of course causes associated types to not resolve. Fixes #5003

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-01 21:11:06 +00:00
Lukas Wirth
9fe10a9606 Resolve associated types with type anchors 2021-04-01 21:52:07 +02:00
Lukas Wirth
444f6caaba Resolve associated types 2021-04-01 21:31:25 +02:00
Ayomide Bamidele
7bea1d8bfe Additional syntax highlighting screenshot in manual 2021-03-31 18:45:15 +01:00
Ayomide Bamidele
4296cc3318 Gif of "let = " typing assist 2021-03-31 16:39:04 +01:00
Ayomide Bamidele
d82176c146 Gifs and screenshots for features in manual (syntax highlighting and typing) 2021-03-31 16:20:54 +01:00
bors[bot]
55d7d71590
Merge #8267
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 <48062697+MozarellaMan@users.noreply.github.com>
2021-03-31 10:01:56 +00:00
Ayomide Bamidele
276022682b Gifs and screenshots for features in manual 2021-03-31 00:08:10 +01:00
Lukas Wirth
8d786dc4c3 Replace Range<usize> usage with TextRange 2021-03-30 22:42:21 +02:00
Chetan Khilosiya
518c9c7548 Revert "8024: Added test case for highlighting trait items."
This reverts commit d7dcd41801.
2021-03-31 01:46:01 +05:30
Chetan Khilosiya
d0fcd5c5e0 8024: Fix for function name change. 2021-03-31 00:47:37 +05:30
Chetan Khilosiya
d7dcd41801 8024: Added test case for highlighting trait items. 2021-03-31 00:31:15 +05:30
Chetan Khilosiya
56f624532a 8024: Updated the implementation for trait modifier.
Fixed the test cases.
2021-03-31 00:31:15 +05:30
Chetan Khilosiya
f269fe7156 8024: Added the trait modifier for methods
method in impls and method calls will have trait modifier.
2021-03-31 00:31:15 +05:30
bors[bot]
fd7c454d51
Merge #8186
8186: Lower traits to `TraitRef` instead of `TypeRef` r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-30 16:45:05 +00:00
Lukas Wirth
bb56b7a75c Use new new docs string source mapping in goto_def and hover 2021-03-30 18:27:16 +02:00
Lukas Wirth
9a327311e4 Implement basic Documentation source to syntax range mapping 2021-03-30 17:20:43 +02:00
Lukas Wirth
9df78ec4a4 Properly resolve intra doc links in hover and goto_definition 2021-03-30 14:03:32 +02:00
ivan770
4fcba8b1bf
Fix code style 2021-03-30 12:58:41 +02:00
ivan770
6ef6e4dee1
Improved node lookup algorithm, added more movable nodes 2021-03-30 12:44:09 +02:00
Jonas Schievink
41c7448e12 Accurately classify assoc. types in paths 2021-03-30 02:09:17 +02:00
Lukas Wirth
6b8358d4d9 Remove code duplication in highlight injection 2021-03-29 20:11:28 +02:00
Lukas Wirth
c2a63b97a8 Rename target_ty to self_ty 2021-03-29 17:47:47 +02:00
Ayomide Bamidele
8e11796dc5 formatting fix 2021-03-29 12:56:02 +01:00
Ayomide Bamidele
a813062ed2 Folding range for statics 2021-03-29 12:20:26 +01:00
Ayomide Bamidele
391be07298 Folding range for consts 2021-03-29 12:17:19 +01:00
Ayomide Bamidele
23601454fe New FoldKinds - Consts, Statics 2021-03-29 11:49:14 +01:00
Ayomide Bamidele
f6702dda9a Test cases for folding consts and statics 2021-03-29 11:43:03 +01:00
bors[bot]
ae7de296ae
Merge #8222
8222: Don't mark unlinked file diagnostic as unused r=lnicola a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8215, at least on VS Code

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-29 07:30:28 +00:00
bors[bot]
bb1d925dab
Merge #8212
8212: Basic support macro 2.0 r=jonas-schievink a=edwin0cheng

Turn out it is quite straight forward :)

r @jonas-schievink 

![m2](https://user-images.githubusercontent.com/11014119/112712565-6eb99380-8f0b-11eb-88de-5d7f974dfe6d.png)


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-28 15:43:11 +00:00
Jonas Schievink
bd18e5fa87 Don't mark unlinked file diagnostic as unused 2021-03-28 03:56:03 +02:00
Lukas Wirth
c9e479870b Prefer add mod declaration to lib.rs over file.rs in UnlinkedFile fix 2021-03-27 23:43:07 +01:00
Edwin Cheng
eedadd7024 Add support for doc on hover for macro 2.0 2021-03-27 14:57:11 +08:00
Edwin Cheng
4520002b63 Unleash macro 2.0 in hightlight and more 2021-03-27 14:42:49 +08:00
cynecx
5ff3299dd6 syntax: return owned string instead of leaking string 2021-03-26 18:30:59 +01:00
ivan770
50e28aec25
Ignore main functions not in root module 2021-03-26 16:04:53 +02:00
Jonas Schievink
37c6ce34a9 Document unlinked-file diagnostic 2021-03-24 22:18:17 +01:00
Brandon
903a2e98f9 Clean up implementation 2021-03-24 00:47:55 -07:00
Brandon
0d063b8d21 Fix MISSING: command error with macros 2021-03-24 00:00:38 -07:00
bors[bot]
c6d6a7d412
Merge #8178
8178: Show item info when hovering intra doc links r=Veykril a=Veykril

![r4uIITP0IZ](https://user-images.githubusercontent.com/3757771/112197618-91e2fb00-8c0c-11eb-9edc-a7923214d2b6.gif)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-23 19:58:03 +00:00
Lukas Wirth
caaeb92882 Cleanup intra_doc_link parsing 2021-03-23 20:56:38 +01:00
Lukas Wirth
8b0d0bd9c7 Show item info when hovering intra doc links 2021-03-23 19:57:04 +01:00
Lukas Wirth
6bdf505d7c simplify 2021-03-23 17:49:06 +01:00
Lukas Wirth
638dcac092 Make more use of the HIR in rename::rename_to_self 2021-03-23 16:54:21 +01:00
Lukas Wirth
bad4e48672 Set up a search scope when searching for mbe macro references 2021-03-23 11:32:10 +01:00
bors[bot]
d4fa6721af
Merge #8054
8054: Item movers r=matklad a=ivan770

Closes #6823

https://user-images.githubusercontent.com/14003886/111331579-b4f43480-8679-11eb-9af0-e4dabacc4923.mp4

Implementation issues:
- [ ] Most of items are non-movable, since _movability_ of any item has to be determined manually. Common ones are movable though
- [x] Cursor should move with the item

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2021-03-22 13:08:45 +00:00
Matthias Krüger
ae7e55c1dd clippy::complexity simplifications related to Iterators 2021-03-21 13:13:34 +01:00
Lukas Wirth
38048c35d8 Don't use an untyped String for ActiveParam tracking 2021-03-20 23:22:09 +01:00
Jonas Schievink
636de3c709 Add AttrsWithOwner and clean up source_map 2021-03-19 21:23:57 +01:00
Jonas Schievink
fc5f73de45 Move AttrsOwnerNode to syntax and make it public 2021-03-19 20:05:17 +01:00
ivan770
d331155f8d
Remove needless lifetime 2021-03-19 17:01:39 +02:00
ivan770
2794cc7b00
Added more movable lists 2021-03-19 16:43:47 +02:00
bors[bot]
7200b994c9
Merge #8097
8097: Parse extended_key_value_attributes r=jonas-schievink a=Veykril

Companion PR https://github.com/rust-analyzer/ungrammar/pull/31

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-19 11:38:40 +00:00
ivan770
0a2d221d47
Added arglist mover 2021-03-19 10:28:09 +02:00
Lukas Wirth
4771a56791 Parse extended_key_value_attributes 2021-03-19 02:13:46 +01:00
Lukas Wirth
8c0f454d11 Use a highlight modifier for intra doc links 2021-03-18 22:32:07 +01:00
bors[bot]
b70bea0d79
Merge #8083
8083: Track source file IDs in source mapping of Attrs r=jonas-schievink a=Veykril

Fixes the panics/incorrect injection highlighting of outline module declarations until we figure out a nicer source mapping strategy for attributes.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-18 19:26:10 +00:00
Jonas Schievink
4390125314 Add test for goto def on proc macro invocation 2021-03-18 17:24:17 +01:00
Jonas Schievink
c05a1a6e37 Store an AstId for procedural macros 2021-03-18 16:11:18 +01:00
Lukas Wirth
d41a1690d2 Track source file IDs in source mapping of Attrs 2021-03-18 13:16:27 +01:00
ivan770
f62944f416
Remove prioritization, add more movable items 2021-03-18 11:22:28 +02:00
ivan770
b67a91b960
Fix code after rowan version bump 2021-03-18 11:22:28 +02:00
ivan770
a154ef7ca1
Remove movable array, improve client code 2021-03-18 11:22:27 +02:00
ivan770
7d60458495
Item up and down movers 2021-03-18 11:22:27 +02:00
Lukas Wirth
9763f0a6bd Semantic highlight intradoclinks in documentation 2021-03-17 21:00:01 +01:00
bors[bot]
ec10835d60
Merge #8069
8069: Inject highlight into block doc comments r=Veykril a=Veykril

bors r+
Closes https://github.com/rust-analyzer/rust-analyzer/issues/6873

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-17 18:20:25 +00:00
Lukas Wirth
37964f9fef Inject highlight into block doc comments 2021-03-17 19:12:28 +01:00
Lukas Wirth
5481c78f32 Check whether cursor is on and not between intra doc links in goto_definition 2021-03-17 17:24:16 +01:00
Lukas Wirth
5734b347dd Fix incorrect newline emission in Attrs::docs 2021-03-17 17:00:08 +01:00
Lukas Wirth
ec824a92d0 Better handling of block doc comments 2021-03-17 14:48:57 +01:00
bors[bot]
0fbfab3b45
Merge #8059
8059: Move doc-comment highlight injection from AST to HIR r=matklad,jonas-schievink a=Veykril

Fixes #5016

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-17 11:13:54 +00:00
Lukas Wirth
cdfb5c353f Remove quadratic attr source lookup 2021-03-17 11:22:40 +01:00
Matthias Krüger
048dad8c2e don't clone types that are copy (clippy::clone_on_copy) 2021-03-17 01:56:31 +01:00
Matthias Krüger
966c23f529 avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
2021-03-17 01:27:56 +01:00
Lukas Wirth
c766492d26 Properly handle doc attributes in doc-comment highlight injection 2021-03-16 21:15:26 +01:00
Lukas Wirth
acc6458390 Replace trait object boxing with extra AttrsOwnerNode 2021-03-16 19:06:58 +01:00
Lukas Wirth
11e9bc60a2 Move doc-comment highlight injection from AST to HIR 2021-03-16 18:57:47 +01:00
bors[bot]
00c80b208b
Merge #8055
8055: Implement HirDisplay for some more types r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-16 15:48:35 +00:00
bors[bot]
a69f7ce312
Merge #8053
8053: Remove ShortLabel r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-16 15:40:06 +00:00
Lukas Wirth
4d1e1daa31 Implement HirDisplay for some more types 2021-03-16 16:36:34 +01:00
bors[bot]
979e788957
Merge #8034
8034: Implement Crate::transitive_reverse_dependencies r=matklad a=Veykril

changelog internal Implement Crate::transitive_reverse_dependencies

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-16 14:54:12 +00:00
Lukas Wirth
4628d94e74 Remove ShortLabel 2021-03-16 15:44:31 +01:00
Lukas Wirth
75fafd6fcc Add new_source_root meta to test fixtures 2021-03-16 15:28:02 +01:00
bors[bot]
c49b5b7468
Merge #7498
7498: Clone for update r=matklad a=matklad

rowan counterpart https://github.com/rust-analyzer/rowan/pull/93

#6857

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-16 13:14:48 +00:00
Aleksey Kladov
f5a81ec468 Upgrade rowan
Notably, new rowan comes with support for mutable syntax trees.
2021-03-16 16:10:49 +03:00
bors[bot]
1a82af3527
Merge #7900 #8000
7900: show function params in completion detail r=matklad a=JoshMcguigan

This resolves #7842 by updating the detail for function completions from `-> T` to `fn(T, U) -> V`. I added an expicit unit test for this, `ide_completion::render::fn_detail_includes_args_and_return_type`, which passes.

Lots of other unit tests fail (~60 of them) due to this change, although I believe the failures are purely cosmetic (they were testing the exact format of this output). I'm happy to go update those tests, but before I do that I'd like to make sure this is in fact the format we want for the detail?

edit - I realized `UPDATE_EXPECT=1 cargo test` automatically updates `expect!` tests. Big 👍 to whoever worked on that! So I'll go ahead and update all these tests soon. But I still would like to confirm `fn(T, U) -> V` is the desired content in the `detail` field. 

8000: Use hir formatter for hover text r=matklad a=oxalica

Fix #2765 , (should) fix #4665

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: oxalica <oxalicc@pm.me>
2021-03-16 08:05:24 +00:00
bors[bot]
d38fd77845
Merge #8028
8028: Return multiple modules in `parent_module` feature r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-15 17:50:20 +00:00
Lukas Wirth
e97cd709cd Implement Crate::transitive_reverse_dependencies 2021-03-15 18:28:31 +01:00
oxalica
455b418263
Update tests 2021-03-16 01:24:26 +08:00
oxalica
7c855c940a
Clean usage of ShortLabel 2021-03-16 01:05:56 +08:00
oxalica
87171238c6
Use hir formatter more 2021-03-16 01:04:33 +08:00
oxalica
ef416e0154
Impl HirDisplay for function hover message 2021-03-16 01:04:20 +08:00
oxalica
ef48d1ca3b
Add test for hover of macro expanded function 2021-03-16 01:01:24 +08:00
bors[bot]
5f6d71cf0c
Merge #8029
8029: Enable thread-local coverage marks r=JoshMcguigan a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-03-15 14:42:26 +00:00
Lukas Wirth
2e3c156b0e Return multiple modules in parent_module 2021-03-15 15:15:40 +01:00
bors[bot]
f2c39d0cdf
Merge #8020
8020: Power up goto_implementation r=matklad a=Veykril

by allowing it to be invoked on references of names, now showing all (trait)
implementations of the given type in all crates instead of just the defining
crate as well as including support for builtin types

![image](https://user-images.githubusercontent.com/3757771/111144403-52bb0700-8587-11eb-9205-7a2a5b8b75a3.png)
Example screenshot of `impl`s of Box in `log`, `alloc`, `std` and the current crate. Before you had to invoke it on the definition where it would only show the `impls` in `alloc`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-15 14:08:26 +00:00
Laurențiu Nicola
88cee24c6c Enable thread-local coverage marks 2021-03-15 16:02:50 +02:00
bors[bot]
b245e8d115
Merge #8015
8015:  Introduce Semantics::visit_file_defs r=matklad a=Veykril

See https://github.com/rust-analyzer/rust-analyzer/issues/3538#issuecomment-798920601

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-15 13:18:26 +00:00
Aleksey Kladov
af2366acdf Goto definition works for S { a: } case
What happens here is that we lower `: ` to a missing expression, and
then correctly record that the corresponding field expression resolves
to a specific field. Where we fail is in the mapping of syntax to this
missing expression. Doing it via `ast_field.expr()` fails, as that
expression is `None`. Instead, we go in the opposite direcition and ask
each lowered field about its source.

This works, but has wrong complexity `O(N)` and, really, the
implementation is just too complex. We need some better management of
data here.
2021-03-15 15:12:39 +03:00
Lukas Wirth
41745f48d5 move Semantics::visit_file_defs to ide_db::helpers 2021-03-15 12:18:52 +01:00
Lukas Wirth
a1c96e04be Introduce Semantics::visit_file_defs 2021-03-15 12:14:34 +01:00
Lukas Wirth
6c782a5314 Power up goto_implementation
by allowing it to be invoked on references of names, showing all (trait)
implementations of the given type in all crates including builtin types
2021-03-15 12:10:18 +01:00
bors[bot]
5138baf2ac
Merge #8021 #8022
8021: Enable searching for builtin types r=matklad a=Veykril

Not too sure how useful this is for reference search overall, but for completeness sake it should be there 
![image](https://user-images.githubusercontent.com/3757771/111132711-f69db600-8579-11eb-8c90-22fd6862d11f.png)

Also enables document highlighting for them.


8022: some clippy::performance fixes r=matklad a=matthiaskrgr

use vec![] instead of Vec::new() + push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unnecessary resizing

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
2021-03-15 10:05:49 +00:00
Aleksey Kladov
5dcdf2ceee Move code to the appropriate layer
StructureNodeKind is a type which is specific to a particular feature,
file_structure. It shouldn't be in the "code shared by all ide features"
part.
2021-03-15 12:55:27 +03:00
bors[bot]
cec676d082
Merge #7975
7975: Provide regions in file structure r=ivan770 a=ivan770

Closes #7913 

https://user-images.githubusercontent.com/14003886/110819163-96b3c080-8296-11eb-993e-a7cdb574a12d.mp4



Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2021-03-15 09:26:58 +00:00
Matthias Krüger
cad617bba0 some clippy::performance fixes
use vec![] instead of Vec::new() +  push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unneccessary resizing
2021-03-15 10:19:59 +01:00
Lukas Wirth
9763d9e8c4 Enable searching for builtin types 2021-03-15 09:32:06 +01:00
bors[bot]
de36027541
Merge #7966
7966: Diagnose files that aren't in the module tree r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6377

I'm not sure if this is the best way to do this. It will cause false positives for all `include!`d files (though I'm not sure how much IDE functionality we have for these).

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-15 01:23:29 +00:00
Jonas Schievink
32e1ca54ea Add module comment 2021-03-15 02:23:00 +01:00
Jonas Schievink
40638b16c8 Use pub(crate) 2021-03-15 01:46:59 +01:00
Jonas Schievink
8b4cbbb87c Redo it properly and add a quickfix 2021-03-15 01:39:41 +01:00
Lukas Wirth
f2610cbd7e Don't drop type params in doc-test paths 2021-03-14 20:38:26 +01:00
ivan770
7d48e04f31
Introduce StructureNodeKind 2021-03-14 19:00:41 +02:00
ivan770
8602f9573b
Added region intersection test 2021-03-14 18:53:40 +02:00
ivan770
56ca843695
Shorten trim call 2021-03-14 18:53:40 +02:00
ivan770
71a97a2d8c
Provide regions in file structure 2021-03-14 18:53:37 +02:00
bors[bot]
7accf6bc37
Merge #7799
7799: Related tests r=matklad a=vsrs

![tests](https://user-images.githubusercontent.com/62505555/109397453-a9013680-7947-11eb-8b11-ac03079f7645.gif)
This adds an ability to look for tests for the item under the cursor: function, constant, data type, etc

The LSP part is bound to change. But the feature itself already works and I'm looking for a feedback :)



Co-authored-by: vsrs <vit@conrlab.com>
2021-03-13 13:50:35 +00:00
Josh Mcguigan
9ee3914c61 remove unused CompletionScore enum 2021-03-12 06:16:04 -08:00
Josh Mcguigan
3679821eea add completion relevance score 2021-03-12 06:16:01 -08:00
vsrs
00e52e1f42 Add Feature: Related Tests comment 2021-03-11 17:58:45 +03:00
vsrs
daa2637486 Apply review suggestions 2021-03-11 17:39:41 +03:00
Lukas Wirth
98d2dbb90e Return original text range in PrepareRename responses when inside macro 2021-03-10 22:26:41 +01:00
Jonas Schievink
7b1a0d5fb7 Diagnose files that aren't in the module tree 2021-03-10 20:30:20 +01:00
bors[bot]
83280ea574
Merge #7958
7958: Avoid double text edits when renaming mod declaration r=matklad a=Veykril

Closes https://github.com/rust-analyzer/rust-analyzer/issues/7916

See https://github.com/microsoft/vscode-languageserver-node/issues/752 for context

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-10 15:07:46 +00:00
Lukas Wirth
3af69b5359 Avoid double text edits when renaming mod declaration 2021-03-10 15:49:01 +01:00
Josh Mcguigan
09307be75b add apply ssr assist 2021-03-10 06:02:15 -08:00
Aleksey Kladov
842d8ad9c8 Compilation speed 2021-03-09 22:30:58 +03:00
Lukas Wirth
814d617d34 Show whether a binding is mutable or not on hover 2021-03-09 17:18:50 +01:00
Lukas Wirth
983726a45c Don't show const items initializer expressions on hover 2021-03-09 16:33:23 +01:00
Kirill Bulatov
33c83e72b9 Work towards better import labels 2021-03-08 23:59:20 +02:00
Laurențiu Nicola
fc9eed4836 Use upstream cov-mark 2021-03-08 22:19:44 +02:00
Laurențiu Nicola
42057896bc Fix some warnings 2021-03-05 15:59:50 +02:00
Lukas Wirth
e194f2edc4 Prevent renaming SelfType and BuiltinType 2021-03-03 19:48:53 +01:00
Lukas Wirth
183ba483a9 Reorder functions in rename.rs 2021-03-03 19:48:35 +01:00
bors[bot]
f8152171bb
Merge #7850
7850: Don't add space when joining line to opening quote r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-02 14:19:45 +00:00
Aleksey Kladov
e2fc9411f1 Don't add space when joining line to opening quote 2021-03-02 17:18:45 +03:00
bors[bot]
6a585c6ee2
Merge #7795
7795: Show docs on hover for keywords and primitives r=matklad a=Veykril

![lAWFadkziX](https://user-images.githubusercontent.com/3757771/109369534-eeb4f500-789c-11eb-8f2b-2f9c4e129de3.gif)

It's a bit annoying that this requires the `SyntaxNode` and `Semantics` to be pulled through `hover_for_definition` just so we can get the `std` crate but I couldn't think of a better way.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-02 13:46:50 +00:00
Lukas Wirth
8d305680e6 Show docs on hover for keywords and primitives 2021-03-02 14:41:01 +01:00