Commit Graph

18409 Commits

Author SHA1 Message Date
Aleksey Kladov
be84f85c1d feat: gate custom clint-side commands behind capabilities
Some features of rust-analyzer requires support for custom commands on
the client side. Specifically, hover & code lens need this.

Stock LSP doesn't have a way for the server to know which client-side
commands are available. For that reason, we historically were just
sending the commands, not worrying whether the client supports then or
not.

That's not really great though, so in this PR we add infrastructure for
the client to explicitly opt-into custom commands, via `extensions`
field of the ClientCapabilities.

To preserve backwards compatability, if the client doesn't set the
field, we assume that it does support all custom commands. In the
future, we'll start treating that case as if the client doesn't support
commands.

So, if you maintain a rust-analyzer client and implement
`rust-analyzer/runSingle` and such, please also advertise this via a
capability.
2021-07-30 19:16:33 +03:00
bors[bot]
956e205417
Merge #9730
9730: minor: drop impl-specific stuff from lsp docs r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-30 13:38:38 +00:00
Aleksey Kladov
68836c0dbe minor: drop impl-specific stuff from lsp docs
The lc. prefix is a copy-paste from our typescript code, it doesn't make
sense in the impl-agnostic docs.
2021-07-30 16:37:41 +03:00
bors[bot]
8232804d3e
Merge #9706
9706: minor: perf and grammar fixes r=lnicola a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-07-29 16:14:10 +00:00
bors[bot]
8a6bac3fc8
Merge #9724
9724: internal: Use more strictly typed syntax nodes for analysis in extract_function assist r=Veykril a=Veykril

This also prevents it from looking into local items unnecessarily(which might even cause problems in some cases)
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-29 15:27:03 +00:00
Lukas Wirth
b537cb186e Use more strictly typed syntax nodes for analysis in extract_function assist 2021-07-29 17:26:37 +02:00
bors[bot]
1323dd7957
Merge #9722
9722: fix: Refine extraction targets of extract_function assist r=Veykril a=Veykril

Closes https://github.com/rust-analyzer/rust-analyzer/issues/7748
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-29 13:45:28 +00:00
Lukas Wirth
2b461c50d7 Refine extraction targets of extract_function assist 2021-07-29 15:45:05 +02:00
bors[bot]
8d3b294ef7
Merge #9719
9719: feat: Make flyimport respect `#[doc(hidden)]` r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/7718 (we still don't respect `#[doc(hidden)]` on reexports, but that is tracked by https://github.com/rust-analyzer/rust-analyzer/issues/9197)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-07-28 17:31:17 +00:00
Jonas Schievink
8764cc955f Make flyimport respect #[doc(hidden)] 2021-07-28 19:22:59 +02:00
bors[bot]
54db97af45
Merge #9718
9718: Bump notify to 5.0.0-pre.11 r=lnicola a=deontologician

It looks like the `INotifyWatcher::new` method was removed sometime after `5.0.0-pre.3` and then added back in `5.0.0-pre.11`. Without the `=`, cargo can resolve some version from `5.0.0-pre.4` -> `5.0.0-pre.10` which will not compile.

Co-authored-by: Josh Kuhn <deontologician@gmail.com>
2021-07-28 17:22:40 +00:00
Josh Kuhn
9f5f4c342a
Bump notify to 5.0.0-pre.11 2021-07-28 10:09:58 -07:00
bors[bot]
16f3e2bf6e
Merge #9716
9716: internal: Stop reexporting `hir_def`'s `ItemInNs` from HIR r=jonas-schievink a=jonas-schievink

Resolves a FIXME and simplifies downstream code

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-07-28 15:39:57 +00:00
Jonas Schievink
18f86baa62 Stop reexporting hir_def's ItemInNs from HIR 2021-07-28 17:39:04 +02:00
bors[bot]
1662c3470d
Merge #9715
9715: feat: Make most completions respect `#[doc(hidden)]` r=jonas-schievink a=jonas-schievink

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

This continues https://github.com/rust-analyzer/rust-analyzer/pull/9681 and makes most other completion sources respect `#[doc(hidden)]`. After this, only flyimport is missing support for this.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-07-28 14:00:33 +00:00
Jonas Schievink
0fbf396f0d Make most completions respect #[doc(hidden)] 2021-07-28 15:59:02 +02:00
bors[bot]
33dcc895c1
Merge #9700
9700: fix: Remove the legacy macro scoping hack r=matklad a=jonas-schievink

This stops prepending `self::` to single-ident macro paths, resolving even legacy-scoped macros using the fixed-point algorithm. This is not correct, but a lot easier than fixing this properly (which involves pushing a new scope for every macro definition and invocation).

This allows resolution of macros from the prelude, fixing https://github.com/rust-analyzer/rust-analyzer/issues/9687.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-07-28 12:07:25 +00:00
bors[bot]
068ede0991
Merge #9693
9693: feat: Add the Hover Range capability which enables showing the type of an expression r=matklad a=alexfertel

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

This PR extends the `textDocument/hover` method to allow getting the type of an expression. It looks like this:

![type_of_expression](https://user-images.githubusercontent.com/22298999/126914293-0ce49a92-545d-4005-a59e-9294fa2330d6.gif)

Edit: One thing I noticed is that when hovering a selection that includes a macro it doesn't work, so maybe this would need a follow-up issue discussing what problem that may have.

(PS: What a great project! I am learning a lot! 🚀)

Co-authored-by: Alexander Gonzalez <alexfertel97@gmail.com>
Co-authored-by: Alexander González <alexfertel97@gmail.com>
2021-07-28 11:21:33 +00:00
Alexander González
4d3a0529d5 fix: Revert removing [] from the hover gif 2021-07-28 06:58:19 -04:00
Laurențiu Nicola
636933153d Small grammar fix 2021-07-28 12:40:21 +03:00
bors[bot]
f749e9c546
Merge #9712
9712: minor: simplify r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-28 09:36:01 +00:00
Aleksey Kladov
ea9f6920fb minor: simplify 2021-07-28 12:35:21 +03:00
Alexander Gonzalez
04e3869adb refactor: Reuse the from_proto call in handle_hover 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
5b30d9c4a9 feat: Add the Hover Range server capability 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
e57ad5456c fix: Typos 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
41943f2328 refactor: Apply PR suggestions 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
743c037a34 chore: Remove unnecessary println! call 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
cff2a0fe32 lint: Format the typescript files properly 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
c6fab1993a test: Update lsp_ext.rs hash 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
ca85185bc6 docs: Update the lsp-extensions.md with the Hover Range capability 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
506db1852c test: Add tests for when hovering fails 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
48f43df7d6 docs: Improve the comments in crates/ide/src/hover.rs 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
6310786ca5 test: Add hover_range tests 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
1a0a5da1a4 refactor: Make handle_hover handle ranges too 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
2b5798e927 fix: Unregister the removed command 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
9f21891950 refactor: Remove unnecessary command 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
79860808cb chore: Remove unnecessary log 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
18644720eb feat: Completed the client side implementation of rust-analyzer/hoverRange 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
8ca3bb8fcd feat: Add the hover_range capability 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
20c64cc0e6 feat: Extend the server with the hover_range capability 2021-07-27 18:29:22 -04:00
Laurențiu Nicola
ea0014c500 Remove some redundant clones 2021-07-27 21:32:55 +03:00
bors[bot]
6a2a0b7abb
Merge #9710
9710: fix: Don't qualify self as crate in add_missing_impl_members assist r=Veykril a=Veykril

Fixes #7499

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-27 17:30:37 +00:00
Lukas Wirth
456f5c6d09 Don't qualify self as crate in add_missing_impl_members assist 2021-07-27 19:29:47 +02:00
bors[bot]
2c638a467e
Merge #9709
9709: fix: add capability for "open cargo.toml" lsp extension r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-27 16:41:02 +00:00
Aleksey Kladov
7d6c4142b2 fix: add capability for "open cargo.toml" lsp extension 2021-07-27 19:40:19 +03:00
bors[bot]
9ca81edb7c
Merge #9703
9703: docs: Fix several typos and grammar mistakes r=matklad a=alexfertel

I took some time to clean up the dev docs a bit since I spent the whole week reading them. I am not a native speaker, so if you find something wrong please tell me and I'll fix it 😁 

Co-authored-by: Alexander Gonzalez <alexfertel97@gmail.com>
2021-07-26 22:23:35 +00:00
Alexander Gonzalez
c865b56744 docs: Fix several typos and grammar mistakes 2021-07-26 18:15:40 -04:00
bors[bot]
3a59b56324
Merge #9702
9702: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-26 18:28:32 +00:00
Lukas Wirth
3fab50019c Simplify 2021-07-26 20:26:24 +02:00
bors[bot]
e6bae220b7
Merge #9701
9701: fix: correctly update diagnostics when files are opened and closed r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-26 18:22:29 +00:00