Commit graph

1000 commits

Author SHA1 Message Date
Aleksey Kladov
b85042601d Goto type definition works for self 2020-07-10 14:08:35 +02:00
yihuang
17ff67dd7e
Only take first 500 syntax errors
Too many syntax errors make some editor/ide slow, fix #3434.
2020-07-10 17:30:57 +08:00
Aleksey Kladov
68706b59c9 Don't mess with cursor position when adding hashes 2020-07-09 19:21:41 +02:00
bors[bot]
1fb92d791e
Merge #5284
5284: Fold struct literals r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-09 16:49:44 +00:00
Aleksey Kladov
ca8969a104 Fold struct literals 2020-07-09 18:49:17 +02:00
bors[bot]
89c7c55995
Merge #5270
5270: Add argument count mismatch diagnostic r=matklad a=jonas-schievink

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

This currently has one false positive on this line, where `max` is resolved to `Iterator::max` instead of `Ord::max`:

8aa10c00a4/crates/expect/src/lib.rs (L263)

(I have no idea why it thinks that `usize` is an `Iterator`)

TODO:
* [x] Tests
* [x] Improve diagnostic text for method calls

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-09 15:34:43 +00:00
Aleksey Kladov
65d9966a4f Always put config first 2020-07-09 16:12:53 +02:00
Jonas Schievink
73327c647d Remove unnecessary DiagnosticSink handlers 2020-07-09 15:50:35 +02:00
Aleksey Kladov
117392e879 Remove insta from ra_ide 2020-07-09 14:33:57 +02:00
Aleksey Kladov
fb0bc941a5 Cleanup diagnostics tests 2020-07-09 14:33:03 +02:00
Aleksey Kladov
ea68a1d0c9 Reduce code duplication 2020-07-09 13:59:49 +02:00
Jonas Schievink
63ce2c7b5f Add argument count mismatch diagnostic 2020-07-09 12:16:29 +02:00
Aleksey Kladov
4399eff2d0 Re-enable IDE features for incomplete impl blocs 2020-07-09 12:14:26 +02:00
Aleksey Kladov
2aa27d612e expect should be a dev dep 2020-07-09 10:59:41 +02:00
Aleksey Kladov
c66812193e Prettier rendering 2020-07-09 10:31:12 +02:00
Aleksey Kladov
e7c47eb7f5 Streamline 2020-07-09 10:19:37 +02:00
Aleksey Kladov
3a26752c66 Reduce API 2020-07-09 10:03:28 +02:00
Aleksey Kladov
22269c67b8 Cleanup 2020-07-09 09:56:15 +02:00
Aleksey Kladov
3ef9ef34c6 Reduce API 2020-07-09 09:42:01 +02:00
Aleksey Kladov
ed12bd2791 Rename 2020-07-09 09:39:53 +02:00
Aleksey Kladov
abbb539f97 Refactor hover tests 2020-07-09 00:10:49 +02:00
Aleksey Kladov
9ce9a4ae0d Simplify tests 2020-07-08 23:06:15 +02:00
Aleksey Kladov
e8bb153b19 Add Markup type 2020-07-08 22:37:35 +02:00
Aleksey Kladov
16dcf020c4 simplify 2020-07-08 20:35:54 +02:00
Aleksey Kladov
d74a77efb1 Minimize API 2020-07-08 20:35:54 +02:00
Aleksey Kladov
7238acab78 Dead code 2020-07-08 20:35:54 +02:00
Aleksey Kladov
86aac4303f Reduce visibility 2020-07-08 19:41:57 +02:00
Aleksey Kladov
5b8a5bfb15 Modernize unqualified reference completion tests 2020-07-07 12:52:09 +02:00
Aleksey Kladov
9b2847885d cleanup 2020-07-07 11:44:16 +02:00
Aleksey Kladov
4bbc385277 Switch to fully dynamically dispatched salsa
This improves compile times quite a bit
2020-07-07 10:14:48 +02:00
Aleksey Kladov
453167b492 Modernise item completion tests 2020-07-04 23:25:33 +02:00
Aleksey Kladov
943fa46395 Alight details in comkplation list 2020-07-04 19:03:58 +02:00
Aleksey Kladov
c14a3b4a20 Modernize qual path completion tests 2020-07-04 18:53:30 +02:00
Aleksey Kladov
824a24c710 Modernize snippet completion tests 2020-07-04 18:03:34 +02:00
Aleksey Kladov
ba9c398144 Modernize postfix completion tests 2020-07-04 15:44:21 +02:00
Aleksey Kladov
7a7fd6d239 Modernize pattern completion tests 2020-07-04 15:10:55 +02:00
Aleksey Kladov
9dacd2338c Fix lookup in tests 2020-07-04 15:05:33 +02:00
Aleksey Kladov
216e093f90 Macro tests 2020-07-04 15:04:57 +02:00
Aleksey Kladov
03ca33406e Modernize tests 2020-07-04 14:53:43 +02:00
Aleksey Kladov
f2f6a46aa4 Cleanup dot completiont tests 2020-07-04 10:41:50 +02:00
Aleksey Kladov
caeddff543 Comments 2020-07-04 10:03:27 +02:00
Aleksey Kladov
5c68dd6b59 Better tests for completion scoring 2020-07-04 09:53:54 +02:00
Aleksey Kladov
aaba2300fb Modernize completion presentation tests 2020-07-04 09:36:53 +02:00
Aleksey Kladov
65768feaff Unify naming 2020-07-04 09:08:51 +02:00
Aleksey Kladov
6518f18f80 Cleanup tests 2020-07-04 09:07:18 +02:00
Aleksey Kladov
cda1a6c638 Cleanup more completion tests 2020-07-04 00:01:45 +02:00
Aleksey Kladov
9f9b38bdb4 Cleanup presentation tests 2020-07-03 23:15:44 +02:00
Aleksey Kladov
f4a3bc30b8 Fix module renaming 2020-07-03 18:47:26 +02:00
Aleksey Kladov
4c347a9f65 Compress rename tests 2020-07-03 18:39:36 +02:00
Aleksey Kladov
2656c415c8 Use expect for rename tests 2020-07-03 18:35:43 +02:00
Aleksey Kladov
ee7ab0104d Adhere to code style in rename tests 2020-07-03 18:29:37 +02:00
bors[bot]
88a602f305
Merge #5205
5205: Refactor attribut completion tests r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-03 14:06:13 +00:00
Aleksey Kladov
314efae29d Refactor attribut completion tests 2020-07-03 15:59:37 +02:00
Aleksey Kladov
f1671f460b Compress attribute completion tests 2020-07-03 15:38:53 +02:00
bors[bot]
f51b0cfdd6
Merge #5116
5116: Categorize assists r=matklad a=kjeremy

Categorize assists so that editors can use them. Follows the LSP spec pretty close (and some things may need adjustments) but this populates the Refactor menu in vscode and pushes quickfixes through again.

This is a prerequisite to filtering out assists that the client doesn't care about.

Fixes #4147

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-07-03 12:44:09 +00:00
Aleksey Kladov
503de8e229 Add function to test completion edit 2020-07-03 13:21:48 +02:00
Aleksey Kladov
e2b04621f9 Refactor keyword completion tests 2020-07-03 12:51:18 +02:00
Aleksey Kladov
0e23175a07 Cleanup record completion tests 2020-07-03 11:48:48 +02:00
Jeremy Kolb
b98c16a034 Categorize assists 2020-07-02 17:13:02 -04:00
bors[bot]
57ed622ec4
Merge #5089 #5161 #5184 #5185 #5186
5089: Disable auto-complete on comments r=matklad a=BGluth

Resolves #4907 by disabling any auto-completion on comments.

As flodiebold [pointed out](https://github.com/rust-analyzer/rust-analyzer/issues/4907#issuecomment-648439979), in the future we may want to support some form of auto-completion within doc comments, but for now it was suggested to just disable auto-completion on them entirely.

The implementation involves adding a new field `is_comment` to `CompletionContext` and checking if the immediate token we auto-completed on is a comment. I couldn't see a case where we need to check any of the ancestors, but let me know if this is not sufficient. I also wasn't sure if it was necessary to add a new field to this struct, but I decided it's probably the best option if we want to potentially do auto-completion on doc comments in the future.

Finally, the three tests I added should I think ideally not filter results by `CompletionKind::Keyword`, but if I want to get unfiltered results, I need access to a non-public function [get_all_completion_items](9a4d02faf9/crates/ra_ide/src/completion/test_utils.rs (L32-L39)) which I don't know if I should make public just for this.



5161: SSR: Add initial support for placeholder constraints r=matklad a=davidlattimore



5184: Always install required nightly extension if current one is not nightly r=matklad a=Veetaha

This is weird, but having switched back to stable by uninstalling the extension appears that vscode doesn't destroy the `PersistentState` and thus changing to `nightly` channel doesn't work because the last check for nightly extension was less than 1 hour ago. The simple solution is to skip this check if we know that the current extension version is not nightly.

5185: Force showing extension activation error pop-up notification r=matklad a=Veetaha

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/5091

5186: fix: correct pd/ppd/tfn/tmod completion doc r=matklad a=fannheyward

a33eefa3b2/crates/ra_ide/src/completion/complete_snippet.rs (L23-L24)

Co-authored-by: BGluth <gluthb@gmail.com>
Co-authored-by: David Lattimore <dml@google.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
Co-authored-by: Heyward Fann <fannheyward@gmail.com>
2020-07-02 09:12:46 +00:00
Heyward Fann
f1986be8fd fix: correct pd/ppd/tfn/tmod completion doc
a33eefa3b2/crates/ra_ide/src/completion/complete_snippet.rs (L23)
2020-07-02 11:06:00 +08:00
BGluth
cc77bdf59a Auto-completion no longer occurs on comments 2020-07-01 15:20:07 -06:00
BGluth
0bbd6428ad Added tests for no auto-completion on comments 2020-07-01 15:16:47 -06:00
bors[bot]
43dfd29d8d
Merge #5174
5174: Colorize more test fixtures r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-01 17:20:02 +00:00
bors[bot]
ad1a0e626b
Merge #5175
5175: More memory-efficient impl collection r=matklad a=jonas-schievink

This saves roughly 90 MB in `ImplsFromDepsQuery`, which used to copy the list of all impls from libcore into *every* crate in the graph. It also stops collecting inherent impls from dependencies entirely, as those can only be located within the crate defining the self type.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-01 17:12:06 +00:00
bors[bot]
8943c2cb97
Merge #5178
5178: Fold multiline calls r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-01 16:35:16 +00:00
Aleksey Kladov
8295dc42a0 Fold multiline calls 2020-07-01 18:27:58 +02:00
Laurențiu Nicola
dbb940fa7d Colorize more test fixtures 2020-07-01 19:05:34 +03:00
Aleksey Kladov
53e3a7aeb4 Update file structure tests 2020-07-01 17:59:44 +02:00
Aleksey Kladov
bebbbb61a7 Update expand macro tests 2020-07-01 17:52:22 +02:00
Jonas Schievink
6bde542a39 Split CrateImplDefs in inherent and trait impls
This makes the intention of inherent vs. trait impls somewhat more
clear and also fixes (?) an issue where trait impls with an unresolved
trait were added as inherent impls instead (hence the test changes).
2020-07-01 17:15:20 +02:00
Laurențiu Nicola
9710ad8c48 Reuse Semantics instances 2020-07-01 15:27:01 +03:00
Jeremy Kolb
20d864807d Use the selection range when resolving call hierarchy items
Add a test in call_hierarchy that already passed

Fixes #5103
2020-07-01 07:56:15 -04:00
Aleksey Kladov
05d67a9a0e Move test data to test_data directory 2020-07-01 11:26:09 +02:00
Aleksey Kladov
adf624b433 Add file support to expect 2020-07-01 11:19:40 +02:00
David Lattimore
3d9997889b SSR: Add initial support for placeholder constraints 2020-07-01 18:44:11 +10:00
bors[bot]
686e115e73
Merge #5158
5158: Use CrateName correctly r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-01 08:03:47 +00:00
Aleksey Kladov
80386ca5be Use Strings for display names 2020-07-01 10:03:07 +02:00
Laurențiu Nicola
5953cbd7ae Make SemanticsScope non-generic 2020-07-01 09:34:45 +03:00
Aleksey Kladov
8b725a2f77 Switch to expect for the rest of inlay tests 2020-06-30 21:55:21 +02:00
Aleksey Kladov
442c13ba17 Simplify most of the inlay hints tests 2020-06-30 18:04:25 +02:00
Aleksey Kladov
de464f5e4a Refactor runnable tests 2020-06-30 14:12:55 +02:00
Aleksey Kladov
af7e300041 Remove confusing API 2020-06-30 13:29:53 +02:00
Aleksey Kladov
34072d53b6 Rewrite goto implementation tests 2020-06-30 13:20:16 +02:00
Aleksey Kladov
4484908a86 Rewrite goto definition tests 2020-06-30 13:03:08 +02:00
bors[bot]
e87cba85ef
Merge #5132
5132: Fix some typos r=matklad a=davidlattimore



Co-authored-by: David Lattimore <dml@google.com>
2020-06-30 08:45:16 +00:00
bors[bot]
d13ded6cbc
Merge #5101
5101: Add expect -- a light-weight alternative to insta r=matklad a=matklad

This PR implements a small snapshot-testing library. Snapshot updating is done by setting an env var, or by using editor feature (which runs  a test with env-var set). 

Here's workflow for updating a failing test:

![expect](https://user-images.githubusercontent.com/1711539/85926956-28afa080-b8a3-11ea-9260-c6d0d8914d0b.gif)

Here's workflow for adding a new test:

![expect-fresh](https://user-images.githubusercontent.com/1711539/85926961-306f4500-b8a3-11ea-9369-f2373e327a3f.gif)

Note that colorized diffs are not implemented in this PR, but should be easy to add (we already use them in test_utils). 

Main differences from insta (which is essential for rust-analyzer development, thanks @mitsuhiko!):
* self-updating tests, no need for a separate tool
* fewer features (only inline snapshots, no redactions)
* fewer deps (no yaml, no persistence)
* tighter integration with editor
* first-class snapshot object, which can be used to write test functions (as opposed to testing macros)
* trivial to tweak for rust-analyzer needs, by virtue of being a workspace member. 

I think eventually we should converge to a single snapshot testing library, but I am not sure that `expect` is exactly right, so I suggest rolling with both insta and expect for some time (if folks agree that expect might be better in the first place!). 

# Editor Integration Implementation 

The thing I am most excited about is the ability to update a specific snapshot from the editor. I want this to be available to other snapshot-testing libraries (cc @mitsuhiko, @aaronabramov), so I want to document how this works. 

The ideal UI here would be a code action (💡). Unfortunately, it seems like it is impossible to implement without some kind of persistence (if you save test failures into some kind of a database, like insta does, than you can read the database from the editor plugin). Note that it is possible to highlight error by outputing error message in rustc's format. Unfortunately, one can't use the same trick to implement a quick fix. 

For this reason, expect makes use of another rust-analyzer feature -- ability to run a single test at the cursor position. This does need some expect-specific code in rust-analyzer unfortunately. Specifically, if rust-analyzer notices that the cursor is on `expect!` macro, it adds a special flag to runnable's JSON. However, given #5017 it is possible to approximate this well-enough without rust-analyzer integration. Specifically, an extension can register a special runner which checks (using regexes) if rust-anlyzer runnable covers text with specific macro invocation and do special magic in that case. 

closes #3835 


Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-30 08:34:08 +00:00
David Lattimore
ef49bbeec4 Fix some typos 2020-06-30 10:43:37 +10:00
bors[bot]
ca31b1d63a
Merge #5105
5105: Simlify with matches!() r=matklad a=Veetaha



Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-06-28 22:37:25 +00:00
Aleksey Kladov
7cf1981a2d Don't show ra_fixture param hints 2020-06-28 13:11:41 +02:00
Veetaha
e75e2ae5b6 Simlify with matches!() 2020-06-28 04:03:59 +03:00
Aleksey Kladov
be265ece02 Add example expect test for goto definition 2020-06-27 19:22:31 +02:00
Paul Daniel Faria
b1992b469c Remove unneeded code, filename from tests, fix rebasing issues 2020-06-27 11:38:34 -04:00
Paul Daniel Faria
2ca52bbb32 Revert ide highlighting changes (addressing on another branch) 2020-06-27 10:16:19 -04:00
Paul Daniel Faria
f678e0d837 Add HighlightTag::Operator, use it for unsafe deref. Move unsafe validation to its own file 2020-06-27 10:13:14 -04:00
Paul Daniel Faria
6c1682396c Account for deref token in syntax highlighting of unsafe, add test for that case 2020-06-27 10:11:10 -04:00
Paul Daniel Faria
c622551ec2 Fix typo in test 2020-06-27 10:09:42 -04:00
Paul Daniel Faria
daf1cac9f8 Move diagnostics back into expr, add tests for diagnostics, fix logic to account for derefs of raw ptrs 2020-06-27 10:09:29 -04:00
Paul Daniel Faria
0b95bed83f Add unsafe diagnostics and unsafe highlighting 2020-06-27 10:08:14 -04:00
Aleksey Kladov
491d000c27 Add :: to label for crate:: completion 2020-06-27 12:26:25 +02:00