Commit graph

631 commits

Author SHA1 Message Date
Lukas Wirth
f7af0b4b96 Add some more marks to rename tests 2021-01-11 00:28:21 +01:00
Lukas Wirth
2347944aae Use local error macros in references/rename 2021-01-10 21:59:44 +01:00
bors[bot]
607b9ea160
Merge #7218
7218: Fix typos r=Veykril a=regexident

Apart from the very last commit on this PR (which fixes a public type's name) all changes are non-breaking.

Co-authored-by: Vincent Esche <regexident@gmail.com>
2021-01-10 18:16:29 +00:00
bors[bot]
b3ae7974af
Merge #7239
7239: Replace SyntaxKind usage with T! macro where applicable r=lnicola a=Veykril

https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/style.md#token-names

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-10 16:31:32 +00:00
Lukas Wirth
e618d12903 Replace SyntaxKind usage with T! macro where applicable 2021-01-10 17:14:01 +01:00
Laurențiu Nicola
10e7fd25fe Fix typo, parentheses is plural 2021-01-10 17:56:53 +02:00
bors[bot]
77362c7173
Merge #6238
6238: Split punctuation semantic highlighting up into more tags r=matklad a=Veykril

Open question would be the name of the delimiter modifiers. I chose them this was as I see them this way but from what I remember people tend to mix the names however they like. So maybe using `delimSquare`, `delimCurly`, `delimRound` would be better. That would also go well with `angle` becoming `delimAngle`?

Closes #6152

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-10 12:45:07 +00:00
Lukas Wirth
78fe6133c4 Split punctuation semantic highlighting up into more tags 2021-01-10 13:33:03 +01:00
bors[bot]
dcbb77cb6c
Merge #7206 #7231
7206: Use hir::GenericParam in ide_db::Definition instead of relisting all 3 r=Veykril a=Veykril

Basically just this:
```diff
 pub enum Definition {
     Macro(MacroDef),
     Field(Field),
     ModuleDef(ModuleDef),
     SelfType(Impl),
     Local(Local),
-    TypeParam(TypeParam),
-    LifetimeParam(LifetimeParam),
-    ConstParam(ConstParam),
+    GenericParam(GenericParam),
     Label(Label),
 }
```

7231: Cleaner API r=matklad a=matklad

bors r+
🤖

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-01-10 11:45:59 +00:00
Aleksey Kladov
fc3fc571d2 Cleaner API 2021-01-10 14:36:15 +03:00
Lukas Wirth
b795128dde Use hir::GenericParam in ide_db::Definition instead of relisting all 3 2021-01-10 12:33:47 +01:00
bors[bot]
1ed1c14b2b
Merge #7229
7229: Cleanup r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-01-10 11:24:52 +00:00
Aleksey Kladov
3a6ae42eac Cleanup 2021-01-10 14:24:01 +03:00
bors[bot]
6a0a47dd14
Merge #6980
6980: Implement to support intra-doc link r=matklad a=sasurau4

Helps with #6168 

This PR is very limited implementation to support intra-doc. It only support links indicate same file function.

I want someone to feedback me about this implementation. If the approach is good, I will continue this PR to support other symbols like enum and struct. 

Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2021-01-10 10:02:10 +00:00
bors[bot]
4fddf40f5b
Merge #7224
7224: Remove unnecessary allocation when checking whether to hide argument name hint r=jhpratt a=jhpratt

The case-insensitive prefix/suffix check can be performed
character-by-character. This allows the check to be done without having
to allocate a new string. As a side effect, it's also no longer
necessary to convert the entire string to lowercase, as it's done as
needed. As the only case equality we're handling is ASCII, this
operation can be further optimized by using byte equality, rather than
character equality.

cc @SomeoneToIgnore, as it's an update on my PR from yesterday.

Co-authored-by: Jacob Pratt <jacob@jhpratt.dev>
2021-01-10 09:34:24 +00:00
Jacob Pratt
5e81892d4d
Skip leading underscores unconditionally 2021-01-10 04:23:32 -05:00
Aleksey Kladov
083986030e Replace state with function 2021-01-10 11:57:17 +03:00
Jacob Pratt
22566ecd1b
Short-circuit boolean operation 2021-01-10 03:05:52 -05:00
Jacob Pratt
bd8a903548
Remove unnecessary allocation
The case-insensitive prefix/suffix check can be performed
character-by-character. This allows the check to be done without having
to allocate a new string. As a side effect, it's also no longer
necessary to convert the entire string to lowercase, as it's done as
needed. As the only case equality we're handling is ASCII, this
operation can be further optimized by using byte equality, rather than
character equality.
2021-01-09 21:36:38 -05:00
Aleksey Kladov
eeceff3179 Refactor highlighting 2021-01-09 23:07:32 +03:00
Lukas Wirth
919a1d7b27 Refactor rename name checking 2021-01-09 16:59:00 +01:00
Vincent Esche
21f8239ac8 Fixed typos in code comments 2021-01-09 15:41:29 +01:00
Aleksey Kladov
92dac67d0c Simplify 2021-01-09 17:31:22 +03:00
Aleksey Kladov
4a8d2c098d Better highlight for fixtures 2021-01-09 16:07:41 +03:00
Aleksey Kladov
62b17bac92 Simplify 2021-01-09 15:54:38 +03:00
Aleksey Kladov
d4fb7476ef Better names 2021-01-09 15:38:32 +03:00
Aleksey Kladov
8a0bd50036 Reduce duplication 2021-01-09 15:12:21 +03:00
Aleksey Kladov
3dfa2768ac Shorten names 2021-01-09 14:48:15 +03:00
Aleksey Kladov
c6150a3706 Reorder modules 2021-01-09 14:45:47 +03:00
Aleksey Kladov
64a6ee4535 Shorten frequent names 2021-01-09 14:44:01 +03:00
Aleksey Kladov
6fb52af521 Rename dummy -> none 2021-01-09 14:41:31 +03:00
Jacob Pratt
38dd9aa284
Hide argument name hint regardless of case 2021-01-09 04:05:59 -05:00
bors[bot]
5fe8cb1fba
Merge #7213
7213: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-08 23:20:54 +00:00
Lukas Wirth
5889bb27d6 Simplify 2021-01-09 00:17:34 +01:00
bors[bot]
056cabf25d
Merge #7212
7212: Simplify highlighting r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-01-08 20:48:30 +00:00
Aleksey Kladov
e30c1c3fbf Simplify highlighting infra
This also fixes the killer whale bug
2021-01-08 23:47:35 +03:00
Daiki Ihara
65c45083cf Support intra_doc links 2021-01-08 22:23:03 +09:00
Phil Ellison
7066bff9c3 Switch test marker 2021-01-07 19:01:33 +00:00
Phil Ellison
554ee6ea02 cargo fmt 2021-01-07 19:01:33 +00:00
Phil Ellison
b2dbe6e43a Add fix to wrap return expression in Some 2021-01-07 19:01:33 +00:00
Aleksey Kladov
f459375f48 Better fixture highlight 2021-01-07 19:11:27 +03:00
Kevaundray Wedderburn
72b9a4fbd3 Change <|> to $0 - Rebase 2021-01-07 12:09:23 +00:00
Aleksey Kladov
c8ace3a295 Remove some stale deprecations 2021-01-07 13:54:18 +03:00
Aleksey Kladov
f8a0561178 Align config's API with usage
The config now is mostly immutable, optimize for that.
2021-01-06 21:22:24 +03:00
Aleksey Kladov
6e87828756 YAGNI active_resolve_capabilities
This leaks a lot of LSP details into ide layer, which we want to avoid:

c9cec381bc/docs/dev (lsp-independence)

Additionally, all what this infra does is providing a toggle for
auto-import completion, but we already have one!
2021-01-06 20:23:53 +03:00
Aleksey Kladov
f7a15b5cd1 More maintainable config
Rather than eagerly converting JSON, we losslessly keep it as is, and
change the shape of user-submitted data at the last moment.

This also allows us to remove a bunch of wrong Defaults
2021-01-06 15:39:28 +03:00
Lukas Wirth
54b9b03ca2 Show GotoTypeAction for TypeParam 2021-01-04 15:54:45 +01:00
Lukas Wirth
bd47e140b6 Show GotoTypeAction for ConstParam 2021-01-04 15:19:09 +01:00
Lukas Wirth
cd6426afe5 Show implementations when hovering over SelfType 2021-01-04 14:57:59 +01:00
Lukas Wirth
5804b3fae8 Fix HoverAction::Implementation typo 2021-01-04 14:38:08 +01:00
Lukas Wirth
0ae0909a16 Implement hover for ConstParam 2021-01-04 14:18:31 +01:00
Lukas Wirth
47900dd3bc Impl hovering for TypeParams 2021-01-04 12:24:47 +01:00
Jesse Bakker
c7e0c7f43a Upgrade expect-test to 1.1 2021-01-03 14:43:29 +01:00
bors[bot]
1cc73d60bb
Merge #7068
7068: Add VSCode command to view the hir of a function body r=theotherphil a=theotherphil

Will fix https://github.com/rust-analyzer/rust-analyzer/issues/7061. Very rough initial version just to work out where I needed to wire everything up.

@matklad would you be happy merging a hir visualiser of some kind? If so, do you have any thoughts on what you'd like it show, and how?

I've spent very little time on this thus far, so I'm fine with throwing away the contents of this PR, but I want to avoid taking the time to make this more polished/interactive/useful only to discover that no-one else has any interest in this functionality.

![image](https://user-images.githubusercontent.com/1974256/103236081-bb58f700-493b-11eb-9d12-55ae1b870f8f.png)


Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
2021-01-03 09:03:15 +00:00
Nick Spain
40cd6cdf67 Fix ConstParam HasSource impl and implement TryToNav not Nav 2021-01-02 22:11:25 +11:00
Nick Spain
3f1b3df65b Move impls of ToNav that use source() to TryToNav 2021-01-02 21:53:52 +11:00
Nick Spain
c936e4b86f source_old -> source for cases that can be handled by simple bubbling 2021-01-02 21:53:52 +11:00
Nick Spain
14d0db0759 HasSource::source_old -> HasSource::source for places where proc-macros were special cased
In #6901 some special case handling for proc-macros was introduced to
prevent panicing as they have no AST. Now the new HasSource::source
method is used that returns an option.

Generally this was a pretty trivial change, the only thing of much
interest is that `hir::MacroDef` now implements `TryToNav` not `ToNav`
as this allows us to handle `HasSource::source` now returning an option.
2021-01-02 21:53:52 +11:00
Nick Spain
ea4708c444 Mark HasSource::source_old as deprecated but allow at all call sites 2021-01-02 21:53:51 +11:00
Nick Spain
27cadcd531 HasSource::source -> HasSource::source_old
To start migrating HasSource::source to return an Option.
2021-01-02 21:53:51 +11:00
Phil Ellison
db53db8046 Address review suggestion, fix tidy tests 2021-01-01 19:25:18 +00:00
Mara Bos
273d2f9123 Formatting. 2021-01-01 17:31:32 +01:00
Mara Bos
4833972067 Add support for Rust 2021. 2021-01-01 17:22:23 +01:00
Lukas Wirth
bbc0b41c37 Show lifetimes and labels on hover 2021-01-01 15:19:47 +01:00
bors[bot]
0e5fe47153
Merge #7080
7080: Implement ConstParams for HIR r=Veykril a=Veykril

r? @flodiebold 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-01 13:45:10 +00:00
Lukas Wirth
18bf2e5af5 Add ConstParams to the ide layer 2021-01-01 14:43:16 +01:00
kjeremy
dc1396eec7 Update crates 2020-12-30 10:39:50 -05:00
AdnoC
58c1949a7b test for new behavior 2020-12-29 22:52:47 -07:00
AdnoC
6eeec5d75f Smarter bracketed use diagnostic 2020-12-29 22:46:34 -07:00
Laurențiu Nicola
42c24ff25f Avoid a couple of allocations 2020-12-29 14:35:49 +02:00
Phil Ellison
077592a12f Initial implementation of view-hir command 2020-12-28 18:29:58 +00:00
Aleksey Kladov
2f22675537 Simplify assists resolution API
Assist vs UnresolvedAssist split doesn't really pull its weight. This
is especially bad if we want to include `Assist` as a field of
diagnostics, where we'd have to make the thing generic.
2020-12-26 14:11:42 +03:00
bors[bot]
14ee9f539c
Merge #7036
7036: Don't split path separators apart in doctest runnables r=Veykril a=Veykril

Fixes #7035

bors r+ 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-25 10:25:58 +00:00
Lukas Wirth
3ab4f3adbd Don't split path separators apart in doctest runnables 2020-12-25 11:22:11 +01:00
Aleksey Kladov
5d914834a9 Simplify more 2020-12-24 19:37:46 +03:00
Aleksey Kladov
29ed2e0e73 Simplify 2020-12-24 17:54:44 +03:00
bors[bot]
581419fd78
Merge #7030
7030: Support labels in reference search r=matklad a=Veykril

Implements general navigation for labels, goto def, rename and gives labels their own semantic highlighting class.

Fixes #6966

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-24 14:46:41 +00:00
Lukas Wirth
42e3f97c30 Support labels in reference search 2020-12-24 15:40:18 +01:00
Aleksey Kladov
33384d289e pit-of-success API for unresolved code actions 2020-12-24 15:32:29 +03:00
unexge
bfae2634b4 Prevent multiple incorrect case diagnostics in functions 2020-12-23 22:18:31 +03:00
Jeremy Kolb
4f989cfa08 Implement workspace/willRenameFiles for single-level file moves
Renames modules during file rename if they're in the same directory.
2020-12-23 07:47:31 -05:00
Jonas Schievink
26f604b907 Store invocation site for eager macros 2020-12-22 15:02:03 +01:00
bors[bot]
b98ee075ee
Merge #6746
6746: Feature/add assist extract module to file r=matklad a=sasurau4

Fix #6522 

## Screenshot

<img src="https://user-images.githubusercontent.com/13580199/102748269-33a44300-43a5-11eb-9e37-f5fcb8e62f73.gif" width=600 />


## TODO

- [x] Remove all TODO comment
- [x] Pass the doc test



Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2020-12-22 10:04:24 +00:00
Lukas Wirth
a4f34e2c8c Acquire original text range when searching for references 2020-12-21 17:28:47 +01:00
Daiki Ihara
2b4a7848a8 Update test diagnostics in ide 2020-12-21 15:55:40 +09:00
Daiki Ihara
7a2eebde22 Add initial_contents field for CreateFile 2020-12-21 15:55:40 +09:00
bors[bot]
eefbae7ed4
Merge #6921
6921: Higher-ranked trait bounds for where clauses r=flodiebold a=Veykril

There is a slight problem with this which is also noted in a FIXME now but `LifetimeParameters` of these ForLifetime where clauses allocate the lifetimes in the corresponding arena as if they were lifetimes of the item itself and not just the clause they belong to. I wasn't entirely sure what I could do about this but given nothing really uses lifetimes like that currently I figured it might be fine? Open to suggestions for that problem.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-20 11:47:01 +00:00
Aleksey Kladov
f6ed16674c Align code_model name with ungrammar 2020-12-20 10:05:24 +03:00
bjorn3
9fe85e1fdf Add test_rename_bind_pat 2020-12-19 19:55:44 +01:00
Aleksey Kladov
9f6d76da77 Make sure that HighlightModifier::ALL is synchronized with enum 2020-12-19 18:47:36 +03:00
Aleksey Kladov
113688cef0 Clarify the meaning of no-op highlight tag 2020-12-19 17:16:05 +03:00
Aleksey Kladov
a13947abe6 Use more Rustic highlighting specifiers
*Method* works for OO languages, but in rust we can also have
associated constants & types, so let's move this to a modifier.
2020-12-19 17:10:47 +03:00
Aleksey Kladov
c45221907a Deduplicate highlight tags and symbol kinds
Curiously, LSP uses different enums for those, and unsurprising and
annoyingly, there are things which exist in one but not in the other.

Let's not repeat the mistake and unify the two things
2020-12-18 23:04:26 +03:00
Aleksey Kladov
ade2f5cd12 Reduce test verbosity 2020-12-18 21:26:47 +03:00
Aleksey Kladov
0e3581e823 NavTarget doesn't assume that it points to a symbol 2020-12-18 21:15:48 +03:00
Aleksey Kladov
55ba353b39 Don't expose SyntaxKind from IDE API
SyntaxKind is somewhat of an internal type, but IDE is using it to
basically specify an icon. Let's have a dedicated entity for this
instead.
2020-12-18 19:28:48 +03:00
Aleksey Kladov
2465fa02b7 Cleaup imports
ide should re-export everything it needs.
2020-12-18 18:02:11 +03:00
bors[bot]
f4929fa9cc
Merge #6901
6901: Temp fixes panic caused by no ast for proc-macro r=maklad a=edwin0cheng

There are some panic when hover/goto definition for proc-macro. It is because in current design, we don't have `ast-node` for proc-macro and then it trigger [this](479d1f7eec/crates/hir/src/has_source.rs (L116)) line to panic.

This PR is a temp fix for all of these similar to bd4c352831/crates/completion/src/render/macro_.rs (L42)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-18 02:30:51 +00:00
Edwin Cheng
60a3785ac2 Temp fixes panic caused by no ast for proc-macro 2020-12-18 10:26:17 +08:00
Lukas Wirth
fa65d6ba85 Higher-ranked trait bounds for where clauses 2020-12-17 22:01:42 +01:00
Aleksey Kladov
c888f1de6f Rewrite doctest runnables
Handle more cases in a generic way without copy-pasting code.
2020-12-17 20:11:40 +03:00
Aleksey Kladov
0da1532ef2 Minor code style 2020-12-17 20:10:39 +03:00
Jonas Schievink
9231821c03 Make Attrs::from_attrs_owner private 2020-12-17 15:45:26 +01:00
Aleksey Kladov
2ae31e34b1 Rename ImplDef -> Impl
We used to have `Def` suffix for all symbols, but we moved off from
that. `FunctionDef` isn't better than `Function`. Looks like we've
forgot to change `Impl` though!
2020-12-17 14:36:15 +03:00
Lukas Wirth
55faa2daa3 Lifetime reference search 2020-12-16 22:21:01 +01:00
Lukas Wirth
dd496223f5 Node-ify lifetimes 2020-12-16 14:16:09 +01:00
Jonas Schievink
b238ddd21a Make macro def krate mandatory
Refactors builtin derive support to go through proper name resolution
2020-12-15 20:33:05 +01:00
Jonas Schievink
c1cb595382 Move to upstream macro_rules! model 2020-12-15 15:37:37 +01:00
Daiki Ihara
36a9daac70 Add find usages for enum constructors 2020-12-15 00:39:42 +09:00
Lukas Wirth
8ed8e4f25a Use Attrs::docs in NavigationTarget instead of DocCommentsOwner 2020-12-11 21:19:58 +01:00
bors[bot]
91bf15a2f5
Merge #6834
6834: Use Attrs::docs in runnables instead of DocCommentsOwner r=kjeremy a=Veykril

I figured that we should probably move as much of the doc usage to the HIR as possible hence this PR. If we should keep this AST-based feel free to close.

This change does have the nice(but not really useful as I doubt anyones gonna write doc tests like these) side effect that these two doc string snippets allow being run now.
![image](https://user-images.githubusercontent.com/3757771/101945607-bf241400-3bee-11eb-96ce-ccae80028b1f.png)
![image](https://user-images.githubusercontent.com/3757771/101946375-2e9a0380-3bef-11eb-9950-e35168fdd048.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-11 19:57:08 +00:00
Lukas Wirth
ac19a71459 Use Attrs::docs in runnables instead of DocCommentsOwner 2020-12-11 20:11:03 +01:00
Lukas Wirth
37c5b82938 Don't highlight parent nodes of comments on hover 2020-12-11 16:00:52 +01:00
bors[bot]
44978acf51
Merge #6769
6769: Add native "remove this semicolon" diagnostics r=matklad a=ivan770

Closes #6739 
![demo2](https://user-images.githubusercontent.com/14003886/101530533-b76c3180-399a-11eb-9d18-5c8457721655.gif)


Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2020-12-10 16:18:49 +00:00
ivan770
bbb0bc7b04
Cast to ExprStmt, style fixes 2020-12-10 18:10:39 +02:00
Jonas Schievink
f57ce36988 Fix FileId computation in IncorrectCase fix 2020-12-10 14:16:34 +01:00
Aleksey Kladov
6e24321e45 Introduce anchored_path
They allow to represent paths like `#[path = "C:\path.rs"] mod foo;`
in a lossless cross-platform & network-transparent way.
2020-12-09 19:07:05 +03:00
bors[bot]
ef989880ff
Merge #6771
6771: Properly attach inner attributes in Attrs::new r=matklad a=Veykril

Properly attach inner and outer attributes to the things they actually belong to in the HIR. ~~I can add some tests for this if wanted once I know where to put them/how to test for this.~~ Put some tests into `hover.rs`.
 
So the following snippet
```rust
mod foo {
	//! Hello
}
```
now shows `Hello` on hover 🎉

Fixes #2148


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-09 13:16:39 +00:00
bors[bot]
8fbaa8e495
Merge #6775
6775: Fix MissingFields DiagnosticFix trigger range r=lnicola a=Veykril

Fixes #5950

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-09 12:12:43 +00:00
Lukas Wirth
1d54c49271 Fix MissingFields DiagnosticFix trigger range 2020-12-09 12:45:39 +01:00
Lukas Wirth
da3b5e35a6 Test inner and outer doc comments in hover 2020-12-09 09:42:15 +01:00
ivan770
7738467e0a Format code 2020-12-08 19:25:21 +00:00
ivan770
f2950a1350
Remove unused use 2020-12-08 20:50:40 +02:00
ivan770
cb66bb8ff9
Remove this semicolon 2020-12-08 20:47:20 +02:00
Jonas Schievink
4943ef085d Make original_range a method on InFile<&SyntaxNode> 2020-12-08 19:01:27 +01:00
bors[bot]
2aa7f2ece5
Merge #6750
6750: Remove documentation query, move doc handling to attributes r=matklad a=Veykril

Fixes #3182

Removes the documentation query in favor of `Attrs::docs`. Attrs already handlded doc comments partially but the alloc saving check was wrong so it only worked when other attributes existed as well. Unfortunately the `new` constructor has to do an intermediate allocation now because we need to keep the order of mixed doc attributes and doc comments.

I've also partially adjusted the `hover` module to have its tests check the changes, it still has some `HasSource` trait usage due to the `ShortLabel` trait usage, as that is only implemented on the Ast parts and not the Hir, should this ideally be implemented for the Hir types as well?(would be a follow up PR of course)

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-08 13:23:12 +00:00
Kirill Bulatov
19cfa5802e Simplify 2020-12-07 23:41:08 +02:00
Kirill Bulatov
deda74edd8 Use stateless completion resolve 2020-12-07 23:41:08 +02:00
Kirill Bulatov
93bc009a59 Remove the state 2020-12-07 23:41:08 +02:00
Kirill Bulatov
74c3bbacc9 Make completion resolve async 2020-12-07 23:41:08 +02:00
Kirill Bulatov
f6d2540df0 Simplify import edit calculation 2020-12-07 23:41:08 +02:00
Kirill Bulatov
47464e556c Properly fill client completion resolve capabilities data 2020-12-07 23:41:08 +02:00
Kirill Bulatov
6d2d279389 Working resolve completion imports prototype 2020-12-07 23:41:08 +02:00
Lukas Wirth
1caaa201fa Remove hir_def/docs.rs module 2020-12-07 19:58:17 +01:00
bors[bot]
03b886de53
Merge #6719
6719: Use items can also have doc comments r=matklad a=Veykril

Prior to this change modules show more docs than they have cause they inherit the docs from documented use items inside of them.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-07 18:48:35 +00:00
Lukas Wirth
93262c750e Don't insert blank lines between doc attributes 2020-12-07 16:10:46 +01:00
bors[bot]
2756abb167
Merge #6721
6721: Use METHOD semantic token type r=kjeremy a=lnicola

Closes #6685

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-12-04 18:46:44 +00:00
Laurențiu Nicola
72f013b3b9 Use METHOD semantic token type 2020-12-04 18:27:10 +02:00
Lukas Wirth
a1c8bdecfd Use items can also have doc comments 2020-12-04 17:09:40 +01:00
Jonas Schievink
6e1c87eb92 Don't diagnose #[cfg] in macros 2020-12-03 20:46:16 +01:00
bors[bot]
1db60512b6
Merge #6673
6673: Show type of Self on hover r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-02 13:06:34 +00:00
Aleksey Kladov
6f51f728a1 Type-safer API for dealing with parameter lists with optional self 2020-12-01 13:53:39 +03:00
Lukas Wirth
9349d9ee48 Show type of Self on hover 2020-11-29 22:49:12 +01:00
bors[bot]
ac30710ada
Merge #6665
6665: Support self in reference search r=matklad a=Veykril

The approach here is simply checking the descendants of the function body for `PathExpr` then checking whether it only contains a single `self` `PathSegment`, this is to prevent us from picking up `self` tokens from local `UseTree`s.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-29 20:03:44 +00:00
Lukas Wirth
de4ada22d4 Support self in reference search 2020-11-29 20:54:17 +01:00
bors[bot]
25ebcca224
Merge #6599
6599: Add attribute highlight modifier to all tokens inside attributes r=matklad a=Veykril

This has the side effect that we also emit `attribute.attribute` highlights now, as in, the tokens that get the attribute semantic type also get the attribute modifier. I personally don't think it's really a problem but maybe it is to some? It's just that it was really simple to implement it this way, which is why I just went this route for now.

Fixes #6536

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-29 19:35:12 +00:00
Lukas Wirth
4c33ae33e9 Reject more cases of invalid parameter to self renames 2020-11-29 19:02:59 +01:00
Lukas Wirth
f4a77f34da Fix renaming owned self to parameter emitting ref 2020-11-29 17:56:44 +01:00
bors[bot]
05f75d601f
Merge #6666
6666: Support 'go to definition' for self r=jonas-schievink a=Veykril

Also reverts #6660, instead of showing the type it now works like it does for names by returning the declaration we are already on. This for example enables VSCode to show all references(#6665) when executing `go to definition` on the declaration.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-29 14:35:38 +00:00
Lukas Wirth
37438c3335 Support 'go to definition' for self 2020-11-29 12:28:47 +01:00
bors[bot]
c8a2ff6ecc
Merge #6664
6664: Show type of self param on hover r=jonas-schievink a=Veykril

Show the type of `self` when hovering the token in a `SelfParam`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-28 23:38:18 +00:00
Lukas Wirth
ee8afff714 Show type of self param on hover 2020-11-28 22:59:24 +01:00
bors[bot]
a6f26ded00
Merge #6660
6660: Support "go to definition" for SelfParams r=jonas-schievink a=Veykril

Fixes #6657

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-28 16:04:35 +00:00
bors[bot]
7f3ba7d57f
Merge #6645
6645: Publish diagnostics for macro expansion errors r=matklad a=jonas-schievink

This adds 2 new diagnostics, emitted during name resolution:

* `unresolved-proc-macro`, a weak warning that is emitted when a proc macro is supposed to be expanded, but was not provided by the build system. This usually means that proc macro support is turned off, but may also indicate setup issues when using rust-project.json. Being a weak warning, this should help set expectations when users see it, while not being too obstructive. We do not yet emit this for attribute macros though, just custom derives and `!` macros.
* `macro-error`, which is emitted when any macro (procedural or `macro_rules!`) fails to expand due to some error. This is an error-level diagnostic, but currently still marked as experimental, because there might be spurious errors and this hasn't been tested too well.

This does not yet emit diagnostics when expansion in item bodies fails, just for module-level macros.

Known bug: The "proc macro not found" diagnostic points at the whole item for custom derives, it should just point at the macro's name in the `#[derive]` list, but I haven't found an easy way to do that.

Screenshots:

![screenshot-2020-11-26-19:54:14](https://user-images.githubusercontent.com/1786438/100385782-f8bc2300-3023-11eb-9f27-e8f8ce9d6114.png)
![screenshot-2020-11-26-19:55:39](https://user-images.githubusercontent.com/1786438/100385784-f954b980-3023-11eb-9617-ac2eb0a0a9dc.png)


Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-11-28 15:10:00 +00:00
Lukas Wirth
b006856381 Support goto definition for ADT-SelfParams 2020-11-28 16:07:07 +01:00
Kirill Bulatov
3f612d37c6 Move the helpers into ide_db 2020-11-28 16:30:39 +02:00
Kirill Bulatov
f4ae3650d8 Extract the import code into the shared module 2020-11-27 18:28:41 +02:00
Jonas Schievink
d171838d63 More accurately place proc-macro diagnostic 2020-11-27 16:29:40 +01:00
Jonas Schievink
0432aa0ed7 Publish diagnostics for macro expansion errors 2020-11-27 13:50:22 +01:00
Jonas Schievink
6a9338e979 Use ExpandResult instead of MacroResult
`MacroResult` is redundant
2020-11-26 16:48:17 +01:00
Jonas Schievink
9559bce311 Rename parse_macro to parse_macro_expansion
This does not parse macros, it expands a macro and parses the *result*
2020-11-24 21:57:51 +01:00
Jonas Schievink
d5e9bf80f9 hir_expand: propagate expansion errors 2020-11-24 19:00:23 +01:00
Aleksey Kladov
2c083c993f Minor, import style 2020-11-23 21:19:37 +03:00
Lukas Wirth
1f87a41989 Add attribute highlight modifier to all tokens inside attributes 2020-11-21 12:51:05 +01:00
bors[bot]
f4b4f17662
Merge #6582
6582: Fill the diagnostic code field in publish_diagnostics r=kjeremy a=Veykril

Fixes #6580
Before:
![Code_znn6VgLLH9](https://user-images.githubusercontent.com/3757771/99408084-213f7100-28f0-11eb-8317-3f5c2b93313d.png)
After:
![Code_c4jJsvzOEA](https://user-images.githubusercontent.com/3757771/99408096-23093480-28f0-11eb-9bb2-8ebf2fb3d5a1.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-17 15:47:36 +00:00
Lukas Wirth
c868f0255f Fill the diagnostic code field in publish_diagnostics 2020-11-17 16:23:53 +01:00
Aleksey Kladov
9a30707281 Add **Ignore Test** assist 2020-11-17 14:22:04 +01:00
bors[bot]
e17d604888
Merge #6558
6558: format string highlighting: handle hex + debug type specifier r=matklad a=ruabmbua

Should fix https://github.com/rust-analyzer/rust-analyzer/issues/6427


Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
2020-11-16 11:07:29 +00:00
Roland Ruckerbauer
a15dda48c6 format string highlighting: handle hex + debug type specifier 2020-11-15 17:43:14 +01:00
Lukas Wirth
f3e297331c Cleanup edit_text_range_for_record_field_expr_or_pat 2020-11-15 16:11:06 +01:00
Lukas Wirth
cb60708274 Use shorthand field syntax in destructures 2020-11-14 21:08:20 +01:00
Lukas Wirth
924eecf4af Properly handle shorthands in destructure patterns when renaming 2020-11-14 19:11:09 +01:00
Lukas Wirth
e55a44a831 Use shorthand record syntax when renaming struct initializer field 2020-11-14 17:51:09 +01:00
Aleksey Kladov
f0f13d8cfa cleanup 2020-11-13 16:32:57 +01:00
Anatol Liu
b1b7727e04 add open Cargo.toml action 2020-11-12 17:48:07 -08:00
bors[bot]
0a715cfbd2
Merge #6472
6472: Add `static` modifier for associated functions r=matklad a=p3achyjr

Adds static semantic token modifier to associated functions, resolves #6194 

## Info

- Associated functions are more-or-less equivalent to static methods in other languages. This PR checks, for each function, whether that function has a self_param, and whether it's enclosed in a trait/impl.

## Changes

- Added method ```is_associated``` to code_model::Function. This basically gets the source from the ast, and checks whether the enclosing scope is an impl or trait.
- Added `static` to HighlightModifiers
- Added unit test

## Tests

- Ran ```cargo test```

Co-authored-by: Anatol Liu <axlui@anatols-mbp.lan>
2020-11-09 21:13:51 +00:00
Anatol Liu
6b950d24d4 Add static semantic token modifier for associated functions with no &self
refactor logic into code_model.rs

address comments
2020-11-09 13:09:20 -08:00
Aleksey Kladov
9634521abd . is an operator
closes #6498
2020-11-09 18:12:28 +01:00
Anatol Liu
90031a267a Add static semantic token modifier for associated functions with no &self
refactor logic into code_model.rs

address comments
2020-11-08 00:01:02 -08:00
Aleksey Kladov
6158304f8b Simplify 2020-11-06 22:30:58 +01:00
Aleksey Kladov
5ba4f949c2 Kill RAW_ literals
Syntactically, they are indistinguishable from non-raw versions, so it
doesn't make sense to separate then *at the syntax* level.
2020-11-06 22:23:14 +01:00
Anatol Liu
771c0d8c08 Add static semantic token modifier for associated functions with no &self
refactor logic into code_model.rs
2020-11-04 21:55:44 -08:00
Anatol Liu
3baa526fb0 Add static semantic token modifier for associated functions with no &self 2020-11-04 20:08:46 -08:00
Lukas Wirth
6145234450 Support struct variants in extract_struct_from_enum_variant 2020-11-03 20:57:04 +01:00
Lukas Wirth
74c82ca8ce Only show self ident when showing parameter self hints 2020-11-02 21:56:16 +01:00
bors[bot]
173e45f872
Merge #6365
6365: Do insertion lookahead in algo::diff r=matklad a=Veykril

This is the last blocker for #6287 after this I can update that PR to properly fix things through using `SyntaxRewriter`.

This PR also shuffles tests around a bit and adds some more.

Ideally this is just a hack until we implement a "proper" diff algorithm that approximates a minimal diff. Maybe something like [gumtree](https://github.com/GumTreeDiff/gumtree)?

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-02 17:47:08 +00:00
bors[bot]
d021dbeb4f
Merge #6393 #6399
6393: Remove repetitive inlay hints (take 2) r=matklad a=lnicola



6399: Keep generic annotations when qualifying things r=matklad a=Veykril

The `qualify_path` assists currently eats up already annotated generics in all but one cases which can be annoying if one already pre-fills generics of a type before it's been qualified.

Co-authored-by: Matthew Sanetra <matthewsanetra@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-02 17:40:47 +00:00
Aleksey Kladov
ba8d6d1e4e Remove more unreachable pubs 2020-11-02 16:58:33 +01:00
bors[bot]
e34183218c
Merge #6387
6387: do not use associated types placeholder for inlay hint  r=flodiebold a=bnjjj


close #6191

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-28 14:54:00 +00:00
bors[bot]
85cda15b62
Merge #6384
6384: add doctest runnables on struct r=lnicola a=bnjjj

I will check for how to do the same on trait implementation on another PR.

#6356

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-28 13:15:28 +00:00
Benjamin Coenen
ef2f7bb243 do not use associated types placeholder for inlay hint
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-28 14:07:12 +01:00
Matthew Sanetra
05723cb50d Add check if param name is similar to fn name 2020-10-28 14:45:45 +02:00
bors[bot]
53c7aead8f
Merge #6379
6379: Highlight never type as BuiltinType r=matklad a=Veykril

Fixes #6374

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-27 14:49:37 +00:00
Benjamin Coenen
3bbc2e95e4 add doctest runnables on struct #6356
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-27 14:11:27 +01:00
Benjamin Coenen
94b2330f55 add doctest runnables on struct #6356
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-27 10:07:33 +01:00
Lukas Wirth
269e67312d Highlight never type as BuiltinType 2020-10-26 22:27:30 +01:00
GrayJack
ae6376d74c
Fix test 2020-10-26 17:23:29 -03:00
GrayJack
40a875ab7a
Add test to avoid regression 2020-10-26 15:28:56 -03:00
Lukas Wirth
750ab54573 Do insertion lookahead in algo::diff 2020-10-26 16:03:37 +01:00
Lukas Wirth
c9af469b85 Fix unary minus highlighting 2020-10-25 23:05:30 +01:00
bors[bot]
bf84e4958e
Merge #6331 #6342
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 <joshmcg88@gmail.com>
Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-10-24 19:08:12 +00:00
Igor Aleksanov
19cce08662 Re-export base_db from ide_db 2020-10-24 11:39:57 +03:00
Igor Aleksanov
b6ea56ea09 Make call_info a part of ide_db 2020-10-24 11:07:10 +03:00
Josh Mcguigan
4e76e884bd correct hover for items with doc attribute with raw strings 2020-10-23 19:36:30 -07:00
bors[bot]
2fa942ad30
Merge #6251 #6310
6251: Semantic Highlight: Add Callable modifier for variables r=matklad a=GrayJack

This PR added the `HighlightModifier::Callable` variant and assigned it to variables and parameters that are fn pointers, closures and implements FnOnce trait.

This allows to colorize these variables/parameters when used in call expression.



6310: Rewrite algo::diff to support insertion and deletion r=matklad a=Veykril

This in turn also makes `algo::diff` generate finer diffs(maybe even minimal diffs?) as insertions and deletions aren't always represented as as replacements of parent nodes now.

Required for #6287 to go on.

Co-authored-by: GrayJack <gr41.j4ck@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-23 22:12:15 +00:00
bors[bot]
81609960fa
Merge #6324
6324: Improve #[cfg] diagnostics r=jonas-schievink a=jonas-schievink

Unfortunately I ran into https://github.com/rust-analyzer/rust-analyzer/issues/4058 while testing this on https://github.com/nrf-rs/nrf-hal/, so I didn't see much of it in action yet, but it does seem to work.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-10-23 10:38:30 +00:00
bors[bot]
3d349597fd
Merge #6326
6326: hide paramater inlay hints for cloned vars if applicable r=SomeoneToIgnore a=Veykril

This causes `foo.clone()` parameters to be handled as if they were just `foo` parameters for inlay hint logic.

Fixes #6315 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-22 18:09:43 +00:00
Lukas Wirth
78c3e4a23c Hide paramater inlay hints for cloned vars if applicable 2020-10-22 19:44:52 +02:00
Jonas Schievink
3421b645e6 Emit better #[cfg] diagnostics 2020-10-22 19:19:18 +02:00
Lukas Wirth
d86863aeb4 Rewrite algo::diff to support insertion and deletion 2020-10-22 09:51:11 +02:00
Zac Pullar-Strecker
68c67efa68 Fix opening module documentation opening parent documentation instead
The whole path/URL joining code is kind of ugly which is what led to
this, but at the same time I don't really want to rewrite it right
now...
2020-10-22 17:33:52 +13:00
GrayJack
a35ff6edf4
Add tests for callable modifier 2020-10-21 01:54:51 -03:00
bors[bot]
20d369a826
Merge #6299
6299: Diagnose items that are #[cfg]d out r=jonas-schievink a=jonas-schievink

This emits a hint-level diagnostic with `Unnecessary` tag to "gray out" any items whose `#[cfg]` attributes remove the item before name resolution.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-10-20 16:35:05 +00:00
Jonas Schievink
74ac83a5ac Fixup botched rename 2020-10-20 18:29:47 +02:00
Aleksey Kladov
a3a8ad8bc4 Don't rely on display names in inlay_hints 2020-10-20 18:14:14 +02:00
Jonas Schievink
80d2741401 Add a (hint) diagnostic for unconfigured items 2020-10-20 17:53:04 +02:00
Jonas Schievink
a54e481646 Simplify diagnostic construction, add unused field 2020-10-20 17:53:04 +02:00
Aleksey Kladov
3b1a648539 More type safety around names 2020-10-20 17:09:03 +02:00
Aleksey Kladov
af4e75533f Rename declaration_name -> display_name
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).
2020-10-20 15:38:11 +02:00
Igor Aleksanov
9e7c952bbd Extract call_info and completion into separate crates 2020-10-18 13:09:00 +03:00
Aleksey Kladov
13451d3dc4 Complete methods when receiver is a macro 2020-10-17 23:43:13 +02:00
Igor Aleksanov
99c435939c Scan all ancestors for the impl trait block check 2020-10-17 11:17:58 +03:00
Igor Aleksanov
6f573bd84f Allow hints after 'fn' keyword if it's an impl trait block 2020-10-17 11:03:07 +03:00
Igor Aleksanov
8f303daf45 Add test for new pattern functions 2020-10-17 10:56:00 +03:00
Igor Aleksanov
6ae4c70a0a Improve test_no_completions_required test 2020-10-17 10:47:35 +03:00
Igor Aleksanov
70157f07d9 Remove redundant completions 2020-10-17 10:27:59 +03:00
GrayJack
a483b5545d
Add Callable modifier for variables that implements Fnonce 2020-10-16 07:52:18 -03:00
GrayJack
83d6bc7113
Add HighlightModifier::Callable and add it for locals 2020-10-16 06:38:32 -03:00
Aleksey Kladov
c5868a4879 Clarify the names one more time 2020-10-15 17:38:51 +02:00
Aleksey Kladov
56e67e3a39 More idiomatic classification API 2020-10-15 17:38:17 +02:00
Aleksey Kladov
f9c1336873 More clarifications 2020-10-15 17:37:55 +02:00
Aleksey Kladov
bc287b8f9b Unconfuse expression and pattern field init shorthands 2020-10-15 17:37:36 +02:00
Aleksey Kladov
fa3c449d8f Clarify NameClass names a bit 2020-10-15 17:37:36 +02:00
bors[bot]
7fadc78ebb
Merge #6242
6242: Diagnost shorthand in patterns r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-15 15:11:36 +00:00
Aleksey Kladov
3086fb2ef4 Move field_shorthand to a separate module 2020-10-15 17:10:06 +02:00
Aleksey Kladov
1022672af0 Diagnose shorthand in patterns as well 2020-10-15 17:03:52 +02:00
Aleksey Kladov
e9903a91cd flatten 2020-10-15 16:51:55 +02:00
Aleksey Kladov
c8cbd398e4 Prepare for pat_field_shorthand 2020-10-15 16:48:25 +02:00
bors[bot]
8090799aa2
Merge #6234
6234: Fix hover over field pattern shorthand r=matklad a=Vlad-Shcherbina

Instead of the information about the field, it now shows the information
about the local.

Fixes #6146

Co-authored-by: Vlad Shcherbina <vlad.shcherbina@gmail.com>
2020-10-15 13:09:27 +00:00
bors[bot]
3a38554f86
Merge #6231
6231: Factor macro_rules and format-string highlighting out into submodules r=Veykril a=Veykril

This moves `format`-like macro string highlighting and macro_rules highlight skipping out of the main module.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-14 20:52:41 +00:00
Lukas Wirth
bab29e65eb Default::default the highlighters 2020-10-14 22:50:26 +02:00
Vlad Shcherbina
e6fbb94edd Fix hover over field pattern shorthand
Instead of the information about the field, it now shows the information
about the local.

Fixes #6146
2020-10-14 21:22:00 +03:00
Lukas Wirth
8c6dc5f28a Factor macro_rules! highlighting out 2020-10-14 19:23:59 +02:00
Lukas Wirth
df87be88d8 Factor format string highlighting out 2020-10-14 19:23:45 +02:00
Laurențiu Nicola
8cc175ee9b Add docs for dbgr and call 2020-10-14 16:23:51 +03:00
Laurențiu Nicola
e559066bed Bump pulldown-cmark 2020-10-13 20:41:49 +03:00
bors[bot]
c518fe7f6c
Merge #6130 #6135
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 <popzxc@yandex.ru>
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-12 16:00:13 +00:00
bors[bot]
ef33953c70
Merge #6205
6205: Fix iterator hint shortening heuristic r=SomeoneToIgnore a=Veykril

Turns out I made a mistake with the heuristic check which is always true, so all iterators exposed from `core` were shortened, including things like ranges. 😅 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-12 15:53:32 +00:00
bors[bot]
05faeb50f3
Merge #6153
6153: Improve prime_caches and display its progress r=matklad a=jonas-schievink

It now computes the `CrateDefMap` of all crates, which is generally a reasonable approximation for "IDE features ready". There is still some delay after this finishes, I suspect mostly due to impl collection, which takes a while, but this should be an improvement already.

For more accurate progress reports, this topologically sorts all crates before starting this operation. ~~Because that is also the ordering in which parallelization makes sense (which was previously attempted in https://github.com/rust-analyzer/rust-analyzer/pull/3529), I decided to throw that into the mix as well. It still doesn't provide *that* much of a performance boost, but it does scale beyond the current single-core architecture, and adding it was very easy.~~

~~Unfortunately, as written, this will not tell the user which crate is actually causing slowdowns, since the displayed crate is the last one that was *started*, not the one we are currently *blocked* on, but that seems fairly difficult to implement unless I'm missing something.~~

(I have removed rayon for now since it does not work correctly with cancellation.)

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-10-12 15:21:39 +00:00
Lukas Wirth
ed59512d02 Fix iterator hint shortening heuristic 2020-10-12 17:18:21 +02:00