Commit Graph

4926 Commits

Author SHA1 Message Date
Kirill Bulatov
f4a4fcf275 Remove the leftovers after ImportLocator removal 2020-02-06 19:27:48 +02:00
Aleksey Kladov
755077e372 Doctest autoimport 2020-02-06 18:14:44 +01:00
Aleksey Kladov
d1e8b8d134 Fix tests 2020-02-06 17:42:17 +01:00
Aleksey Kladov
ad204f7562 Mostly remove ImoportLocator infra 2020-02-06 17:17:51 +01:00
Aleksey Kladov
cf812c12d1 Assists are not generic 2020-02-06 17:12:02 +01:00
Aleksey Kladov
f8965ffafd Remove assists TestDB 2020-02-06 16:56:42 +01:00
Aleksey Kladov
2c922ef549 Start switching assists to a root database 2020-02-06 16:56:42 +01:00
Aleksey Kladov
a173e31890 Make assists use ImportsLocator directly 2020-02-06 16:40:28 +01:00
Aleksey Kladov
dfbe96750b Move imports locator to ide_db 2020-02-06 16:26:43 +01:00
Aleksey Kladov
ec23030e16 Add a fixme note 2020-02-06 16:24:14 +01:00
Aleksey Kladov
271017e6bf Move NameKind up 2020-02-06 16:23:28 +01:00
Aleksey Kladov
f8dde21fe9 Simplify 2020-02-06 16:00:39 +01:00
Aleksey Kladov
832dfae250 Tweak goto parent module 2020-02-06 15:47:33 +01:00
bors[bot]
ff2d77bde6
Merge #3029
3029: Docs r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-06 14:14:47 +00:00
Aleksey Kladov
355c98fd08 Docs 2020-02-06 15:10:17 +01:00
Aleksey Kladov
8a39519e1c Cleanup 2020-02-06 15:10:07 +01:00
Aleksey Kladov
ec6fb8da7c Add profiling around add_impl_members
This intention is pretty slow for `impl Interator`, because it has a
ton of default methods which need to be substituted.

The proper fix here is to not compute the actual edit until the user
triggers the action, but that's awkward to do in the LSP right now, so
let's just put a profiling code for now.
2020-02-06 14:55:10 +01:00
Aleksey Kladov
88267c86c0 cleanup imports 2020-02-06 14:03:45 +01:00
Aleksey Kladov
939f05f3e3 Move to a crate 2020-02-06 12:43:56 +01:00
Aleksey Kladov
1bfb111cf9 Move change to ide-db 2020-02-06 12:35:40 +01:00
Aleksey Kladov
ee76e6141e Fix test imports 2020-02-06 12:26:10 +01:00
Aleksey Kladov
0509a0a34e Move Query 2020-02-06 12:24:13 +01:00
Aleksey Kladov
ad247aa670 Move symbol_index 2020-02-06 12:22:35 +01:00
Aleksey Kladov
ec95152a4e Move FeatureFlags 2020-02-06 12:18:52 +01:00
Aleksey Kladov
ee2ee1a8ff Move line_index 2020-02-06 12:17:40 +01:00
Aleksey Kladov
551f33d754 Move ide-db 2020-02-06 12:08:08 +01:00
Aleksey Kladov
896906fea8 Start ide_db 2020-02-06 12:07:06 +01:00
Aleksey Kladov
a4c6e8c4e2 Refactor if-let -> match assist to use ast::make 2020-02-05 14:08:16 +01:00
bors[bot]
83dc22e1fb
Merge #3019
3019: Better cursor placement when merging arms r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-05 12:44:00 +00:00
Aleksey Kladov
f756d5da06 Better cursor placement when merging arms 2020-02-05 13:41:43 +01:00
Aleksey Kladov
28acd01c63 Merge match arms works with many arms 2020-02-05 12:26:43 +01:00
Kirill Bulatov
78092c7c66 Apply the reviews suggestions 2020-02-05 12:47:28 +02:00
Aleksey Kladov
45dd90b0e8 Cleanup 2020-02-05 11:46:05 +01:00
Kirill Bulatov
2b9952625b Normalize dashes in crate names 2020-02-05 11:53:54 +02:00
bors[bot]
c9e1aab880
Merge #2948
2948: Allow add_explicit_type to replace a placeholder type r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-02-04 16:12:05 +00:00
Aleksey Kladov
f5a20014ce minor, if let else -> match 2020-02-04 13:41:56 +01:00
Aleksey Kladov
4ea0c12cf1 Make sure that newly created nodes are the root of the tree 2020-02-04 13:22:32 +01:00
bors[bot]
73c36fdbd2
Merge #2962
2962: Differentiate underscore alias from named aliases r=matklad a=zombiefungus

pre for Fixing Issue 2736 
edited to avoid autoclosing the issue

Co-authored-by: zombiefungus <divmermarlav@gmail.com>
2020-02-04 09:44:31 +00:00
Veetaha
a3e5663ae0 ra_syntax: added tests for tokenization errors 2020-02-04 00:00:55 +02:00
Veetaha
9367b9a292 ra_syntax: add backticks around tokens specimen 2020-02-04 00:00:55 +02:00
Veetaha
c3117eea31 ra_syntax: removed unnecessary init statement from reparsing tests 2020-02-04 00:00:55 +02:00
Veetaha
58e01d8754 ra_syntax: rename first_token() -> lex_first_token() 2020-02-04 00:00:55 +02:00
Veetaha
b1764d85fc ra_syntax: fixed a typo in doc comment 2020-02-04 00:00:55 +02:00
Veetaha
9e7eaa959f ra_syntax: refactored the lexer design as per @matklad and @kiljacken PR review 2020-02-04 00:00:55 +02:00
Veetaha
bf60661aa3 ra_syntax: remove backticks from TokenizeError message since that is not Markdown ;( 2020-02-04 00:00:55 +02:00
Veetaha
c6d0881382 add better docs for tokenize errors 2020-02-04 00:00:55 +02:00
Veetaha
ffe00631d5 ra_syntax: moved ParsedToken derive attribute under the doc comment 2020-02-04 00:00:55 +02:00
Veetaha
a2bc4c2a74 ra_syntax: fixed doc comment 2020-02-04 00:00:55 +02:00
Veetaha
ac37a11f04 Reimplemented lexer with vectors instead of iterators 2020-02-04 00:00:55 +02:00
Veetaha
ad24976da3 ra_syntax: changed added diagnostics information returned from tokenize() (implemented with iterators) 2020-02-04 00:00:55 +02:00
Kirill Bulatov
bfbc5e2d37 Use proper import name in the label 2020-02-03 15:44:28 +02:00
bors[bot]
834fcecd31
Merge #2994
2994: Small cleanup r=matklad a=SomeoneToIgnore

A follow-up to https://github.com/rust-analyzer/rust-analyzer/pull/2990#discussion_r374044482

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-03 13:01:58 +00:00
Kirill Bulatov
4f27155d5c Simplify paths searches 2020-02-03 13:56:03 +02:00
Kirill Bulatov
fcf5bbbbeb Fix inlay hints test snippet compilation 2020-02-03 13:35:14 +02:00
bors[bot]
d400fde66c
Merge #2959
2959: Rework how we send diagnostics to client r=matklad a=kiljacken

The previous way of sending from the thread pool suffered from stale diagnostics due to being canceled before we could clear the old ones.

The key change is moving to sending diagnostics from the main loop thread, but doing all the hard work in the thread pool. This should provide the best of both worlds, with little to no of the downsides.

This should hopefully fix a lot of issues, but we'll need testing in each individual issue to be sure.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-02-03 11:27:31 +00:00
Emil Lauridsen
9f70f443a3 Update snapshot tests due to removed SuggestedFix 2020-02-03 12:24:57 +01:00
Emil Lauridsen
cde20bf8f0 Remove stray todo 2020-02-03 12:18:06 +01:00
Laurențiu Nicola
e0c7ce8417 Allow add_explicit_type to replace a placeholder type 2020-02-03 13:09:38 +02:00
Emil Lauridsen
790788d5f4 Rework how we send diagnostics to client.
The previous way of sending from the thread pool suffered from stale
diagnostics due to being canceled before we could clear the old ones.

The key change is moving to sending diagnostics from the main loop
thread, but doing all the hard work in the thread pool. This should
provide the best of both worlds, with little to no of the downsides.

This should hopefully fix a lot of issues, but we'll need testing in
each individual issue to be sure.
2020-02-03 11:34:24 +01:00
Kirill Bulatov
01d59f4a32 Use name only when searching for an import candidate 2020-02-02 23:27:20 +02:00
Aleksey Kladov
24ad1cce2c Avoid premature pessimization
The extra allocation for message should not matter here at all, but
using a static string is just as ergonomic, if not more, and there's
no reason to write deliberately slow code
2020-02-02 18:56:37 +01:00
bors[bot]
e24829909a
Merge #2982
2982: Merge imports when auto importing r=flodiebold a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-02 13:06:14 +00:00
zombiefungus
f4f71e361e include requested changes 2020-02-02 08:04:24 -05:00
zombiefungus
7d52715945 add new ImportAlias enum to differentiate no alias from an _ alias 2020-02-02 08:04:24 -05:00
Kirill Bulatov
2ee94e3e24
Remove obsolete rustdoc 2020-02-02 14:59:07 +02:00
Kirill Bulatov
c669b2f489 Code review fixes 2020-02-02 14:27:52 +02:00
Kirill Bulatov
6dae5cbb11 Require ModPath for importing 2020-02-02 14:06:51 +02:00
Kirill Bulatov
a9669a5505 Merge imports when auto importing 2020-02-02 10:28:16 +02:00
Kirill Bulatov
d3188769e4 Auto import functions 2020-02-01 22:13:02 +02:00
Aleksey Kladov
5559d6b8a8 Prevent child cargo process from messing with our stdin
By default, `spawn` inherits stderr/stdout/stderr of the parent
process, and so, if child, for example does fcntl(O_NONBLOCK), weird
stuff happens to us.

Closes https://github.com/rust-analyzer/lsp-server/pull/10
2020-02-01 16:25:44 +01:00
bors[bot]
fc0a8c14dc
Merge #2965
2965: Improve auto import message r=kiljacken a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-02-01 11:10:50 +00:00
Laurențiu Nicola
0fdca457df Improve auto import message 2020-01-31 22:12:18 +02:00
Laurențiu Nicola
0829e26354 Fix extra parentheses warnings 2020-01-31 21:07:21 +02:00
Aleksey Kladov
9d5a5211a4 Small cleanup 2020-01-31 13:34:44 +01:00
Aleksey Kladov
c2e3dba8cb Add a FIXME note 2020-01-30 18:01:38 +01:00
bors[bot]
c7e0baf1a8
Merge #2920
2920: Better handle illformed node id from metadata r=matklad a=edwin0cheng

In some rare cases, deps node-id from cargo-metadata do not match its version-id, which cause a panic in `cargo-workspace.rs`. This PR try to ignore these ill-formed node id from `cargo-metadata`. An alternative is return  `Err` in these cases but I think make it resilience is a better choice here.

Related #2767

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-30 16:48:35 +00:00
Aleksey Kladov
c445c72eb3 Simplify fixture parsing 2020-01-30 13:17:56 +01:00
bors[bot]
5dcd9fdf5e
Merge #2895
2895: Rewrite ra_prof's profile printing r=michalt a=michalt

This changes the way we print things to first construct a mapping from
events to the children and uses that mapping to actually print things.
It should not change the actual output that we produce.

The new approach two benefits:

 * It avoids a potential quadratic behavior of the previous approach.
   For instance, for a vector of N elements:
   ```
   [Message{level: (N - 1)}, ..., Message{level: 1}, Message{level: 0}]
   ```
   we would first do a linear scan to find entry with level 0, then
   another scan to find one with level 1, etc.

 * It makes it much easier to improve the output in the future, because
   we now pre-compute the children for each entry and can easily take
   that into account when printing.

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

Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-29 20:09:49 +00:00
Michal Terepeta
644c383f65 A couple of small improvements to ra_prof printing
Based on suggestions from @matklad.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-29 20:55:35 +01:00
bors[bot]
d92a15c163
Merge #2943
2943: Re-sync queries for memory usage measurnment r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-29 15:11:38 +00:00
Aleksey Kladov
f1720d7983 Re-sync queries for memory usage measurnment 2020-01-29 16:10:46 +01:00
Kirill Bulatov
6d219c9a10 Properly select a target for auto importing 2020-01-29 16:23:18 +02:00
Aleksey Kladov
d2fd252f9d Simplify fixture parsing 2020-01-29 14:06:23 +01:00
Aleksey Kladov
7cc0a86528 Fix long loop timeout 2020-01-29 14:04:10 +01:00
Emil Lauridsen
4ec5f6e258 Change error output to make a bit more sense 2020-01-29 13:51:20 +01:00
Emil Lauridsen
8ffbe86dfd Parse cargo output a line at a time.
We previously used serde's stream deserializer to read json blobs from
the cargo output. It has an issue though: If the deserializer encounters
invalid input, it gets stuck reporting the same error again and again
because it is unable to foward over the input until it reaches a new
valid object.

Reading a line at a time and manually deserializing fixes this issue,
because cargo makes sure to only outpu one json blob per line, so should
we encounter invalid input, we can just skip a line and continue.

The main reason this would happen is stray printf-debugging in
procedural macros, so we still report that an error occured, but we
handle it gracefully now.

Fixes #2935
2020-01-29 13:40:27 +01:00
bors[bot]
6fd29651b4
Merge #2931
2931: Added documentation to test_utils r=matklad a=Veetaha

Added some doc comments to test_utils functions while studying this crate. They should be all stable enough to document them.
Also some minor code relocation in `parse_fixture()` closer to its usage according to the advice of @matklad.

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-01-29 11:06:18 +00:00
Aleksey Kladov
9753eb98cc Complain loudly if the main loop is blocked 2020-01-29 11:21:49 +01:00
Aleksey Kladov
aaa4861a0b More uniform naming 2020-01-29 11:15:08 +01:00
Aleksey Kladov
2d2585e03f Don't compute diagnostics on the main thread
closes #2909
2020-01-29 11:03:59 +01:00
Veetaha
5e1ae1d7aa test_utils: move flush!() to its usage as per conversation with @matklad 2020-01-29 03:53:15 +02:00
Veetaha
d3472e8ae4 test_utils: updated documentation and some typos 2020-01-29 03:52:13 +02:00
bors[bot]
3bdf2e0972
Merge #2917
2917: Prefer imports starting with std r=matklad a=SomeoneToIgnore

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

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-01-28 16:22:18 +00:00
Kirill Bulatov
713870ee0c Add the tests 2020-01-28 18:03:24 +02:00
Aleksey Kladov
4b9e5d5dd9 Publicize debug printing of CrateDefMap 2020-01-28 16:29:31 +01:00
Kirill Bulatov
762d293581 Apply the proposed refactoring 2020-01-28 17:19:41 +02:00
Aleksey Kladov
6ca19b2188 Standard formatting for array types 2020-01-28 15:32:20 +01:00
bors[bot]
76e17fe7d8
Merge #2924
2924: Modify ordering of drops in check watcher to only ever have one cargo r=matklad a=kiljacken

Due to the way drops are ordered when assigning to a mutable variable we
were launching a new cargo sub-process before letting the old one quite.

By explicitly replacing the original watcher with a dummy first, we
ensure it is dropped and the process is completed, before we start the
new process.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-01-28 13:54:29 +00:00
Emil Lauridsen
35025f0975 Modify ordering of drops in check watcher to only ever have one cargo
Due to the way drops are ordered when assigning to a mutable variable we
were launching a new cargo sub-process before letting the old one quite.

By explicitly replacing the original watcher with a dummy first, we
ensure it is dropped and the process is completed, before we start the
new process.
2020-01-28 14:48:50 +01:00
Emil Lauridsen
fdc04ef920 Don't do check progress update for fresh crates 2020-01-28 14:33:52 +01:00