Commit Graph

794 Commits

Author SHA1 Message Date
Jonas Schievink
45b8b3d57f
Apply suggestions from code review
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-12-06 14:23:55 +01:00
Jonas Schievink
2a6c246184 Update expect tests 2020-12-06 01:39:52 +01:00
Jonas Schievink
9d96a6d7af Emit additional diagnostics for hints/help/etc 2020-12-06 01:24:37 +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
Jonas Schievink
e45ab7e0ec Fix diagnostics subcommand, look at all modules 2020-12-04 19:37:37 +01:00
Laurențiu Nicola
72f013b3b9 Use METHOD semantic token type 2020-12-04 18:27:10 +02:00
Jonas Schievink
6da651f5da Don't prime caches when just opening a file 2020-12-02 20:18:28 +01:00
kjeremy
e4ffd70c91 Fix OptionalVersionedTextDocumentIdentifier type
Fixes #6654
2020-12-01 08:33:21 -05:00
Florian Diebold
21d256de72 Align default importMergeBehaviour with VSCode 2020-11-29 16:43:46 +01:00
bors[bot]
b7ece77af4
Merge #6650
6650: Make completion and assists module independent r=matklad a=SomeoneToIgnore

A follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/6553#discussion_r524402907

Move the common code for both assists and completion modules into a separate crate.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-11-28 14:33:57 +00:00
Kirill Bulatov
3f612d37c6 Move the helpers into ide_db 2020-11-28 16:30:39 +02:00
Jonas Schievink
f52abbe62d Coalesce flycheck events 2020-11-27 22:52:22 +01:00
Jonas Schievink
e49ba0d1df Downgrade "failed to load" error to warning 2020-11-27 18:35:22 +01:00
Kirill Bulatov
f4ae3650d8 Extract the import code into the shared module 2020-11-27 18:28:41 +02:00
Laurențiu Nicola
a5477d7f29 Remove unused import 2020-11-26 19:25:59 +02:00
Jonas Schievink
9ed883f373 Publish diagnostics on file open
Diagnostics are sometimes only showing up when typing.
This should fix that.
2020-11-26 13:33:47 +01:00
Kirill Bulatov
4c95c6e25d Gate autoimports begind experimental completions flag 2020-11-25 00:30:28 +02:00
kjeremy
e981485b76 New lsp-types to fix versioning
Fixes #6603
2020-11-24 08:52:24 -05:00
Matt Jibson
117c793e80 Don't assume DidChangeTextDocument paths exist
Fixes #5933
2020-11-23 16:35:34 -07:00
Lukas Wirth
91a1a83601 Fill code_description for rust_analyzer diagnostics 2020-11-18 08:54:52 +01:00
Lukas Wirth
56a0021e61 update diagnostics test_data with code_description changes 2020-11-18 08:50:27 +01:00
Lukas Wirth
863fdcfa24 Link clippy lint codes in diagnostics 2020-11-18 08:50:27 +01:00
Lukas Wirth
132063ad96 Link rustc error codes in diagnostics 2020-11-18 08:50:27 +01:00
bors[bot]
156f7d6963
Merge #6553
6553: Auto imports in completion r=matklad a=SomeoneToIgnore

![completion](https://user-images.githubusercontent.com/2690773/99155339-ae4fb380-26bf-11eb-805a-655b1706ce70.gif)

Closes https://github.com/rust-analyzer/rust-analyzer/issues/1062 but does not handle the completion order, since it's a separate task for https://github.com/rust-analyzer/rust-analyzer/issues/4922 , https://github.com/rust-analyzer/rust-analyzer/issues/4922 and maybe something else.

2 quirks in the current implementation:

* traits are not auto imported during method completion

If I understand the current situation right, we cannot search for traits by a **part** of a method name, we need a full name with correct case to get a trait for it.

* VSCode (?) autocompletion is not as rigid as in Intellij Rust as you can notice on the animation.

Intellij is able to refresh the completions on every new symbol added, yet VS Code does not query the completions on every symbol for me.
With a few debug prints placed in RA, I've observed the following behaviour: after the first set of completion suggestions is received, next symbol input does not trigger a server request, if the completions contain this symbol.
When more symbols added, the existing completion suggestions are filtered out until none are left and only then, on the next symbol it queries for completions.
It seems like the only alternative to get an updated set of results is to manually retrigger it with Esc and Ctrl + Space.

Despite the eerie latter bullet, the completion seems to work pretty fine and fast nontheless, but if you have any ideas on how to make it more smooth, I'll gladly try it out.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-11-17 17:50:08 +00: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
0d19ee1d70 Simplify 2020-11-17 15:25:57 +01:00
Kirill Bulatov
16f0b2fdde Actually enable eager completion 2020-11-17 13:19:56 +02:00
kjeremy
233fdb12ce Latest LSP 3.16 protocol
Pulls in https://github.com/gluon-lang/lsp-types/pull/186
2020-11-16 15:10:13 -05:00
Kirill Bulatov
d776c67226 Properly fill the completion settings 2020-11-16 21:19:06 +02:00
Aleksey Kladov
682dd4dac0 Prepare to recompute completions on every keystroke
If we set `is_incomplete: true`, VS Code will re-query completions
after every keypress.
2020-11-16 17:27:36 +01:00
Aleksey Kladov
4dfda64b39 Cleanup workspace loading a tiny bit 2020-11-13 17:38:26 +01:00
bors[bot]
b0ad492e3d
Merge #6519
6519: Add "Open Cargo.toml" action r=matklad a=p3achyjr

## What is it?

This adds an "open cargo.toml" action from the vscode shell, resolves #6462 

## Test

Ran ```cargo xtask install --server``` and ```cargo xtask install --client```, then ```Developer: Reload Window```.

![image](https://user-images.githubusercontent.com/8763808/98614382-2a578f00-22ad-11eb-9811-4a72a54ff6fb.png)

When clicked:

![image](https://user-images.githubusercontent.com/8763808/98618176-77d7fa00-22b5-11eb-8788-35256542f3a6.png)


Co-authored-by: Anatol Liu <axlui@anatols-mbp.lan>
2020-11-13 15:25:26 +00:00
Anatol Liu
b1b7727e04 add open Cargo.toml action 2020-11-12 17:48:07 -08:00
bors[bot]
ddccaecb79
Merge #6524
6524: Add support for loading rustc private crates r=matklad a=xldenis

This PR presents a solution to the problem of making`rustc_private` crates visible to `rust-analyzer`. 
Currently developers add dependencies to those crates behind a `cfg(NOT_A_TARGET)` target to prevent `cargo` from building them.
This solution is unsatisfactory since it requires modifying `Cargo.toml` and causes problems for collaboration or CI. 

The proposed solution suggested by @matklad is to allow users to give RA a path where the `rustc` sources could be found and then load that like a normal workspace. 

This PR implements this solution by adding a `rustcSource` configuration item and adding the cargo metadata to the crate graph if it is provided. 

------

I have no idea how this should be tested, or if this code is generally tested at all. I've locally run the extension with these changes and it correctly loads the relevant crates on a `rustc_private` project of mine. 

Co-authored-by: Xavier Denis <xldenis@gmail.com>
2020-11-12 17:55:32 +00:00
Aleksey Kladov
f73b874157 Update tests 2020-11-12 11:19:26 +01:00
Xavier Denis
8716087919 Add support for loading rustc private crates 2020-11-11 12:45:40 +01:00
Aleksey Kladov
0caa491893 Be more pedantic when checking codeAction/resolve support 2020-11-10 20:38:34 +01:00
Aleksey Kladov
7d2eb000b0 Switch to upstream protocol for resolving code action
Note that we have to maintain custom implementation on the client
side: I don't see how to marry bulitin resolve support with groups and
snippets.
2020-11-10 18:48:46 +01:00
Anatol Liu
3baa526fb0 Add static semantic token modifier for associated functions with no &self 2020-11-04 20:08:46 -08:00
Jonas Schievink
285960aa6b Fix coalescing of prime_caches updates
The previous implementation could try to create a progress bar when one
was  already registered
2020-11-02 18:49:54 +01:00
Jonas Schievink
58e3fd8e8e Remove unnecessary clone 2020-11-02 18:33:46 +01:00
Jonas Schievink
a968cb6aef Remove debug print 2020-11-02 17:24:35 +01:00
Jonas Schievink
6e8ddac165 Coalesce prime_caches updates 2020-11-02 17:24:35 +01:00
Aleksey Kladov
ba8d6d1e4e Remove more unreachable pubs 2020-11-02 16:58:33 +01:00
Aleksey Kladov
3b9548e163 Respond with JSON-RPC error if we failed to deserialize request
Historically, we intentinally violated JSON-RPC spec here by hard
crashing. The idea was to poke both the clients and servers to fix
stuff.

However, this is confusing for server implementors, and falls down in
one important place -- protocol extension are not always backwards
compatible, which causes crashes simply due to version mismatch. We
had once such case with our own extension, and one for semantic
tokens.

So let's be less adventerous and just err on the err side!
2020-10-30 19:57:52 +01:00
Jeremy A. Kolb
8982c0610f Update tests 2020-10-26 09:57:46 -04:00
kjeremy
2d4be2ef2a Request a refresh of semantic tokens if things are loaded up 2020-10-26 09:23:34 -04:00
kjeremy
5cb6fafd36 Latest proposed LSP 3.16.0
Needs: https://github.com/gluon-lang/lsp-types/pull/183
2020-10-26 09:23:34 -04:00
Florian Diebold
39dfca23f1 Add tracing to main rust-analyzer binary 2020-10-25 13:53:38 +01:00