Commit Graph

737 Commits

Author SHA1 Message Date
unexge
48b6dd0b33 Use explicit match for extracting def from classify_name 2020-06-08 15:38:10 +03:00
unexge
c5d5d21858 Add FieldShorthand variant to NameClass 2020-06-08 14:46:58 +03:00
unexge
73684a4ae2 Add goto def for enum variant field 2020-06-06 22:16:59 +03:00
Florian Diebold
a4a4a1854e Fix type parameter defaults
They should not be applied in expression or pattern contexts, unless there are
other explicitly given type args.
2020-06-05 20:09:13 +02:00
bors[bot]
4029628f15
Merge #4729 #4748
4729: Hover actions r=matklad a=vsrs

This PR adds a `hoverActions` LSP extension and a `Go to Implementations` action as an example:
![hover_actions_impl](https://user-images.githubusercontent.com/62505555/83335732-6d9de280-a2b7-11ea-8cc3-75253d062fe0.gif)



4748: Add an `ImportMap` and use it to resolve item paths in `find_path` r=matklad a=jonas-schievink

Removes the "go faster" queries I added in https://github.com/rust-analyzer/rust-analyzer/pull/4501 and https://github.com/rust-analyzer/rust-analyzer/pull/4506. I've checked this PR on the rustc code base and the assists are still fast.

This should fix https://github.com/rust-analyzer/rust-analyzer/issues/4515.

Note that this does introduce a change in behavior: We now always refer to items defined in external crates using paths through the external crate. Previously we could also use a local path (if for example the extern crate was reexported locally), as seen in the changed test. If that is undesired I can fix that, but the test didn't say why the previous behavior would be preferable.

Co-authored-by: vsrs <vit@conrlab.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-05 15:14:35 +00:00
vsrs
92cfc0f2a1 Add enum hover action test. 2020-06-05 15:00:31 +03:00
vsrs
5d0c1aa162 Rebase on the latest master. 2020-06-05 15:00:30 +03:00
vsrs
b147e6eb95 Code formatting 2020-06-05 15:00:30 +03:00
vsrs
7d0dd17b09 Add hover actions as LSP extension 2020-06-05 14:59:26 +03:00
Aleksey Kladov
522d24a607 Inlay Hints: more directly account for self param 2020-06-05 13:58:52 +02:00
Mikhail Rakhmanov
6a0083a519 Merge branch 'master' into compute-lazy-assits
# Conflicts:
#	crates/rust-analyzer/src/main_loop/handlers.rs
#	crates/rust-analyzer/src/to_proto.rs
2020-06-03 19:26:01 +02:00
bors[bot]
e644f64f2a
Merge #4678
4678: Unsquish parameter types in tooltips for macro-generated functions r=aloucks a=aloucks

Note the missing whitespace between `:` and the parameter type.

Before:
![image](https://user-images.githubusercontent.com/221559/83364680-faf13d80-a370-11ea-96b7-a041969a4954.png)

After:
![image](https://user-images.githubusercontent.com/221559/83364685-03e20f00-a371-11ea-9668-4e6ebcb81947.png)


Co-authored-by: Aaron Loucks <aloucks@cofront.net>
2020-06-03 11:27:10 +00:00
Aaron Loucks
f06b2bcd91 Use split1 when formatting function signature params 2020-06-03 07:26:15 -04:00
Aaron Loucks
85c4edb0af Consolidate documentation expansion and merging
Removes the duplicated `expand_doc_attrs` and `merge_doc_comments_and_attrs`
functions from `ra_ide` and exposes the same functionality via
`ra_hir::Documentation::from_ast`.
2020-06-03 06:54:41 -04:00
Aaron Loucks
5837acce53 Add basic hover and completion doc tests for macro generated items 2020-06-03 06:46:07 -04:00
Aaron Loucks
4c655c01f3 Enable hover and autocomplete docs on macro generated items 2020-06-03 06:46:07 -04:00
Paul Daniel Faria
a9cb2933fb Add highlight support for unsafe fn calls and raw ptr deref 2020-06-02 18:54:00 -04:00
Mikhail Rakhmanov
cb482e6351 Merge remote-tracking branch 'upstream/master' into compute-lazy-assits
# Conflicts:
#	crates/rust-analyzer/src/to_proto.rs
2020-06-02 23:22:45 +02:00
Mikhail Rakhmanov
57cd936c52 Preliminary implementation of lazy CodeAssits 2020-06-02 23:10:53 +02:00
Aleksey Kladov
bc3db7c1de Fix tests 2020-06-02 18:09:12 +02:00
Aleksey Kladov
0303982119 New runnables API 2020-06-02 17:22:42 +02:00
bors[bot]
fe6508bd78
Merge #4658
4658: Fix problem with format string tokenization r=matklad a=ruabmbua

Fixed by just not handling closing curlybrace escaping.

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

Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
2020-06-02 12:13:02 +00:00
Aaron Loucks
1211a46826 Unsquish parameter types in tooltips for macro-generated functions 2020-05-31 18:58:54 -04:00
Brennan Vincent
d39cbeef91 add test 2020-05-31 12:21:45 -04:00
bors[bot]
09df51dab8
Merge #4664
4664: Generate feature documentation from code r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-31 10:50:11 +00:00
Aleksey Kladov
1c6a2eb14a Move the rest of the features to generated docs 2020-05-31 11:29:19 +02:00
Aleksey Kladov
b795a07320 Doc more features 2020-05-31 10:14:36 +02:00
Aleksey Kladov
8915183d7d Don't require module docs for Features and Assists 2020-05-31 09:59:38 +02:00
Aleksey Kladov
f593393ebb Specify actions 2020-05-31 09:45:41 +02:00
Aleksey Kladov
c8f27a4a88 Generate features docs from source 2020-05-31 01:54:54 +02:00
Roland Ruckerbauer
780c89959a Test case for format string highlighting of closing curlybrace 2020-05-30 18:35:11 +02:00
Roland Ruckerbauer
18aa4bcb03 Add semantic highlight to QUESTION token
Made it an operator with controlFlow modifier.
2020-05-29 21:17:14 +02:00
Cadu
c011f04f55 Fixed missing newline on each field on "Missing structure fields". 2020-05-27 13:15:19 -03:00
bors[bot]
94889b6472
Merge #4592
4592: fix textedit range returned for completion when left token is a keyword r=bnjjj a=bnjjj

close #4545

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-27 13:22:26 +00:00
Benjamin Coenen
846cefa491 fix textedit range returned for completion when left token is a keyword
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-27 15:15:19 +02:00
bors[bot]
59adc7bfb6
Merge #4596
4596: Strip leading underscores of argument names in function/method r=matklad a=kuy

Closes #4510 

### Goal

When I select a function/method from completions, I get a snippet that doesn't contain leading underscores of argument names.

### Solution

- Option 1: All signatures don't contain underscores
- Option 2: Keep same signature, but inserted snippet doesn't contain underscores

I choose Option 2 because I think that leading underscores is a part of "signature". Users should get correct signatures. On the other hand, trimming underscores is an assist by IDE.

### Other impls.

rls: Complete argument names with underscores (same as actual ra)
IntelliJ Rust: Doesn't complete argument names
VSCode (TypeScript): Doesn't complete argument names

### Working example

![Screen Shot 2020-05-25 at 0 03 21](https://user-images.githubusercontent.com/151614/82757771-a05e5b80-9e1d-11ea-9dbc-1263c960e2ae.png)


Co-authored-by: Yuki Kodama <endflow.net@gmail.com>
2020-05-27 12:41:38 +00:00
bors[bot]
3c5112b079
Merge #4625 #4629
4625: Partially fix displaying inlay hints in Github PR diff views r=matklad a=Veetaha

See the comment in https://github.com/rust-analyzer/rust-analyzer/issues/4608#issuecomment-63424257

It partially fixes the left side of diff view (the one where old code is displayed), but the diff editor with new code changes still has `file` scheme and will proceed displaying inlay hints...

4629: Fix the `should_panic` snippet r=matklad a=eminence

Closes #4628

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Andrew Chin <achin@eminence32.net>
2020-05-27 12:34:03 +00:00
Andrew Chin
36f97d39a4 Fix the should_panic snippet
Closes #4628
2020-05-26 18:45:14 -04:00
kjeremy
bee4f8f9fe Pass trivially copy types as copy 2020-05-26 14:12:13 -04:00
bors[bot]
e3280eb4ae
Merge #4534
4534: Add call postfix completion r=matklad a=vain0x

To make it easier to wrap an expression with Ok/Some/Rc::new etc.

Note I agree with conclusion of the discussion in #1431 that adding many completions is not the way to go. However, this PR still could be justified due to versatility of use.

Co-authored-by: vain0x <vainzerox@gmail.com>
2020-05-26 12:12:52 +00:00
Aaron Loucks
a047f10839 Hover tooltip module name is monospace once again
The line separator is moved below the function signature to split
regions between the docs. This is very similar to how IntelliJ
displays tooltips. Adding an additional separator between the module
name and function signature currently has rendering issues.

Fixes #4594
Alternative to #4615
2020-05-25 23:18:45 -04:00
Jeremy Kolb
a5cc9a8a9b Fix some clippy perf warnings 2020-05-25 13:35:52 -04:00
Yuki Kodama
fd83f469e9 Trim at presentation layer 2020-05-26 01:06:25 +09:00
Yuki Kodama
41d0f7f24e Fix test to consider multiple underscores 2020-05-26 01:06:25 +09:00
Yuki Kodama
408d04764c Use built-in method 2020-05-26 01:06:25 +09:00
Yuki Kodama
378bfc3c8f Separate assertions 2020-05-26 01:06:25 +09:00
Yuki Kodama
4d13691ad1 Reflect test case 2020-05-26 01:06:25 +09:00
Yuki Kodama
6c676909dd Strip leading underscore 2020-05-26 01:06:25 +09:00
bors[bot]
30f058dfea
Merge #4602 #4603
4602: Add boolean literal semantic token type to package.json r=matklad a=lnicola

Closes #4583.

CC @GrayJack

4603: Add self keyword semantic token type r=matklad a=lnicola

Not sure if this is warranted a new token type or just a modifier.

---

CC #4583, @GrayJack

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-25 14:08:21 +00:00
Aleksey Kladov
76e170c3d0 Less rust-analyzer specific onEnter 2020-05-25 14:28:47 +02:00