Commit graph

421 commits

Author SHA1 Message Date
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