Commit graph

7125 commits

Author SHA1 Message Date
bors[bot]
4f9506416c
Merge #2887
2887: Initial auto import action implementation r=matklad a=SomeoneToIgnore

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

Adds an auto import action implementation.

This implementation is not ideal and has a few limitations:

* The import search functionality should be moved into a separate crate accessible from ra_assists.
This requires a lot of changes and a preliminary design. 
Currently the functionality is provided as a trait impl, more on that here: https://github.com/rust-analyzer/rust-analyzer/issues/2180#issuecomment-575690942

* Due to the design desicion from the previous item, no doctests are run for the new aciton (look for a new FIXME in the PR)

* For the same reason, I have to create the mock trait implementaion to test the assist

* Ideally, I think we should have this feature as a diagnostics (that detects an absense of an import) that has a corresponding quickfix action that gets evaluated on demand.
Curretly we perform the import search every time we resolve the import which looks suboptimal.
This requires `classify_name_ref` to be moved from ra_ide, so not done currently.

A few improvements to the imports mechanism to be considered later:

* Constants like `ra_syntax::SyntaxKind::NAME` are not imported, because they are not present in the database

* Method usages are not imported, they are found in the database, but `find_use_path` does not return any import paths for them

* Some import paths returned by the `find_use_path` method end up in `core::` or `alloc::` instead of `std:`, for example: `core::fmt::Debug` instead of `std::fmt::Debug`.
This is not an error techically, but still looks weird.

* No detection of cases where a trait should be imported in order to be able to call a method

* Improve `auto_import_text_edit` functionality: refactor it and move away from the place it is now, add better logic for merging the new import with already existing imports

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-01-27 13:04:53 +00:00
Kirill Bulatov
9be1ab7ff9 Code review fixes 2020-01-27 14:42:45 +02:00
bors[bot]
a108f22d83
Merge #2908
2908: Update crates r=matklad a=kjeremy

Updates insta to 0.13 and bumps everything else.

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-01-27 11:21:54 +00:00
Kirill Bulatov
9a6b5c6183 Enforce alphabetical import sorting 2020-01-27 01:53:59 +02:00
Kirill Bulatov
1a78991df6 Adjust the tests 2020-01-27 00:57:24 +02:00
Kirill Bulatov
d0a782ef1c Have a better trait interface 2020-01-27 00:17:10 +02:00
Kirill Bulatov
bef5cf0b99 Raise the import search query cap 2020-01-27 00:16:29 +02:00
Kirill Bulatov
f57239729c Remove unnecessary lifetime parameter 2020-01-27 00:16:29 +02:00
Kirill Bulatov
316795e074 Initial auto import action implementation 2020-01-27 00:16:29 +02:00
Jeremy Kolb
6967472703 Move snaps to new naming scheme 2020-01-26 13:29:01 -05:00
Jeremy Kolb
b89991daed Update crates 2020-01-26 10:46:45 -05:00
bors[bot]
d1330a4a65
Merge #2906
2906: Fix thread priority problems on windows r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-26 13:17:19 +00:00
Aleksey Kladov
9faebd9d64 Gate CI on windows build 2020-01-26 14:15:57 +01:00
Aleksey Kladov
493a903f22 Bump main thread priority on windows 2020-01-26 14:15:57 +01:00
bors[bot]
13743d1073
Merge #2907
2907: fixed inline_local_variable bug #2900 r=matklad a=TomasKralCZ

This also affects issues like #2666.

Co-authored-by: Tomáš <tomas@kral.hk>
2020-01-26 11:23:22 +00:00
Tomáš
ec6a7f0710 fixed inline_local_variable bug 2020-01-25 21:07:21 +01:00
Aleksey Kladov
40109941db Use default threadpool size 2020-01-25 13:27:36 +01:00
bors[bot]
adda6dbdf8
Merge #2899
2899: Provide more runners for potential tests r=matklad a=SomeoneToIgnore

Based on the https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Runners.20for.20custom.20test.20annotations discussion.

Adds a test runner for every method that has an annotation that contains `test` word in it, allowing to run tests annotated with custom testing annotations such as `#[tokio::test]`, `#[test_case(...)]` and others at costs of potentially emitting some false-positives.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-01-25 11:10:28 +00:00
bors[bot]
fb81726ee5
Merge #2903
2903: Add print_time helper r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-25 10:59:46 +00:00
Aleksey Kladov
6577a7622d Add print_time helper 2020-01-25 11:59:11 +01:00
Aleksey Kladov
f44aee27d3 Disable env_logger humantime feature
We rarely care about timings of events, and, when we care, we need
millisecond precision
2020-01-25 11:53:40 +01:00
bors[bot]
c6dbf406a9
Merge #2901
2901: Cancel requests during shutdown r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-24 15:37:11 +00:00
Aleksey Kladov
b90ea640e6 Cancel requests during shutdown 2020-01-24 16:35:37 +01:00
Kirill Bulatov
3137215e8d Provide more runners for potential tests 2020-01-23 13:40:21 +02:00
bors[bot]
8a4c248c48
Merge #2898
2898: Remove RWLock from check watcher. r=matklad a=kiljacken

@matklad mentioned this might be a good idea.

So the general idea is that we don't really need the lock, as we can
just clone the check watcher state when creating a snapshot. We can then
use `Arc::get_mut` to get mutable access to the state from `WorldState`
when needed.

Running with this it seems to improve responsiveness a bit while cargo
is running, but I have no hard numbers to prove it. In any case, a
serialization point less is always better when we're trying to be
responsive.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-01-23 11:35:31 +00:00
Emil Lauridsen
05aa5b854b Remove RWLock from check watcher.
@matklad mentioned this might be a good idea.

So the general idea is that we don't really need the lock, as we can
just clone the check watcher state when creating a snapshot. We can then
use `Arc::get_mut` to get mutable access to the state from `WorldState`
when needed.

Running with this it seems to improve responsiveness a bit while cargo
is running, but I have no hard numbers to prove it. In any case, a
serialization point less is always better when we're trying to be
responsive.
2020-01-23 09:26:08 +01:00
bors[bot]
2fb8a46122
Merge #2896
2896: Update crates r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-01-22 20:49:35 +00:00
kjeremy
ee7dd4b9ae Update crates 2020-01-22 15:40:35 -05:00
bors[bot]
9b1465af32
Merge #2894
2894: Omit default parameters for references r=matklad a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-01-22 15:00:21 +00:00
Kirill Bulatov
4029e44102 Omit default parameters for reference types 2020-01-22 16:55:09 +02:00
bors[bot]
a5407ddc05
Merge #2891
2891: ra_syntax: removed code duplication and token reevaluation r=Veetaha a=Veetaha

Just a small refactoring along the way of reading the codebase

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-01-22 11:23:21 +00:00
Veetaha
fa31841f1f Fixed a typo 2020-01-22 13:02:21 +02:00
Veetaha
1ac105056a Fixed a typo 2020-01-22 13:02:21 +02:00
Veetaha
b6be1b6f61 Preserved a comment on the bug previously present in ast::Literal::kind() 2020-01-22 13:02:21 +02:00
Veetaha
3ec781d4f2 ra_syntax: remove code duplication and token reevaluation from ast::Literal::kind() 2020-01-22 13:02:21 +02:00
Aleksey Kladov
b982d60a4d Don't fail fast on CI 2020-01-22 11:53:47 +01:00
bors[bot]
e95794da43
Merge #2893
2893: Add syntax guide r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-22 10:13:41 +00:00
Aleksey Kladov
fd69f62976 Add syntax guide 2020-01-22 11:13:11 +01:00
bors[bot]
ad10d0c8b9
Merge #2884
2884: vscode-languageclient 6.0.1 r=matklad a=kjeremy



Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-01-21 08:24:37 +00:00
Jeremy Kolb
a0494c7237 vscode-languageclient 6.0.1 2020-01-20 19:48:32 -05:00
bors[bot]
de2409702b
Merge #2877
2877: "Insert explicit type " assist fix #2869, fix typo r=matklad a=TomasKralCZ

So this was quite straightforward. I basically looked at how the other assists work and tried doing something simillar. I also fixed a typo in the other assist.

Co-authored-by: TomasKralCZ <tomas@kral.hk>
2020-01-20 10:16:06 +00:00
TomasKralCZ
72792f6bc5 changed 'descendants()' to 'children()' 2020-01-20 10:19:33 +01:00
TomasKralCZ
f67ee69777 added eq_token() method to LetStmt 2020-01-19 18:55:56 +01:00
bors[bot]
648241ee93
Merge #2878
2878: Fix a corner case when printing unaccounted time r=matklad a=michalt

Previously `ra_prof` wouldn't actually print the unaccounted time in
some cases.

We would print, for instance, this:
```
    5ms - foo
        2ms - bar
```
instead of:
```
    5ms - foo
        2ms - bar
        3ms - ???
```

The fix is to properly handle the case when an entry has 0 children
instead of using the `last` variable.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-19 17:51:06 +00:00
Michal Terepeta
e8acf49088 Fix a corner case when printing unaccounted time
Previously `ra_prof` wouldn't actually print the unaccounted time in
some cases.

We would print, for instance, this:
```
    5ms - foo
        2ms - bar
```
instead of:
```
    5ms - foo
        2ms - bar
        3ms - ???
```

The fix is to properly handle the case when an entry has 0 children
instead of using the `last` variable.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-19 18:34:40 +01:00
TomasKralCZ
514df15d9e Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer 2020-01-19 17:51:03 +01:00
TomasKralCZ
c3b9a19eb7 fix 'add_explicit_type' assist range 2020-01-19 17:40:53 +01:00
TomasKralCZ
8dc94a452c fix typo in 'inline_local_variable' 2020-01-19 17:39:53 +01:00
bors[bot]
3a7724e441
Merge #2875
2875: Improve parameter hints a bit & add emacs support r=matklad a=flodiebold

 - just include the name, not e.g. `mut`
 - don't return empty hints (or `_`)

CC @brotzeit for the Emacs change

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-01-18 13:00:43 +00:00
Florian Diebold
18ec4e3403 Improve parameter hints a bit & add emacs support
- just include the name, not e.g. `mut`
 - don't return empty hints (or `_`)
2020-01-18 13:40:32 +01:00