Commit graph

804 commits

Author SHA1 Message Date
Jonas Schievink
285960aa6b Fix coalescing of prime_caches updates
The previous implementation could try to create a progress bar when one
was  already registered
2020-11-02 18:49:54 +01:00
Jonas Schievink
58e3fd8e8e Remove unnecessary clone 2020-11-02 18:33:46 +01:00
Jonas Schievink
a968cb6aef Remove debug print 2020-11-02 17:24:35 +01:00
Jonas Schievink
6e8ddac165 Coalesce prime_caches updates 2020-11-02 17:24:35 +01:00
Aleksey Kladov
ba8d6d1e4e Remove more unreachable pubs 2020-11-02 16:58:33 +01:00
Aleksey Kladov
3b9548e163 Respond with JSON-RPC error if we failed to deserialize request
Historically, we intentinally violated JSON-RPC spec here by hard
crashing. The idea was to poke both the clients and servers to fix
stuff.

However, this is confusing for server implementors, and falls down in
one important place -- protocol extension are not always backwards
compatible, which causes crashes simply due to version mismatch. We
had once such case with our own extension, and one for semantic
tokens.

So let's be less adventerous and just err on the err side!
2020-10-30 19:57:52 +01:00
Jeremy A. Kolb
8982c0610f Update tests 2020-10-26 09:57:46 -04:00
kjeremy
2d4be2ef2a Request a refresh of semantic tokens if things are loaded up 2020-10-26 09:23:34 -04:00
kjeremy
5cb6fafd36 Latest proposed LSP 3.16.0
Needs: https://github.com/gluon-lang/lsp-types/pull/183
2020-10-26 09:23:34 -04:00
Florian Diebold
39dfca23f1 Add tracing to main rust-analyzer binary 2020-10-25 13:53:38 +01:00
bors[bot]
bf84e4958e
Merge #6331 #6342
6331: correct hover text for items with doc attribute with raw strings r=matklad a=JoshMcguigan

Fixes #6300 by improving the handling of raw string literals in attribute style doc comments.

This still has a bug where it could consume too many `"` at the start or end of the comment text, just as the original code had. Not sure if we want to fix that as part of this PR or not? If so, I think I'd prefer to add a unit test for either the `as_simple_key_value` function (I'm not exactly sure where this would belong / how to set this up) or create a `fn(&SmolStr) -> &SmolStr` to unit test by factoring out the `trim` operations from `as_simple_key_value`. Thoughts on this? 

6342: Shorter dependency chain r=matklad a=popzxc

Continuing implementing suggestions from the `Completion refactoring` zulip thread.

This PR does the following:

- Removes dependency of `completions` on `assists` by moving required functionality into `ide_db`.
- Moves completely `call_info` crate into `ide_db` as it looks like it fits perfect there.
- Adds a bunch of new tests and docs.
- Adds the re-export of `base_db` to the `ide_db` and removes direct dependency on `base_db` from other crates.

The last point is controversial, I guess, but I noticed that in places where `ide_db` is used, `base_db` is also *always* used. Thus I think the dependency on the `base_db` is implied by the fact of `ide_db` interfaces, and thus it makes sense to just provide `base_db` out of the box.


Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-10-24 19:08:12 +00:00
Laurențiu Nicola
09468ce370 Bump deps 2020-10-24 17:10:36 +03:00
Igor Aleksanov
19cce08662 Re-export base_db from ide_db 2020-10-24 11:39:57 +03:00
bors[bot]
2fa942ad30
Merge #6251 #6310
6251: Semantic Highlight: Add Callable modifier for variables r=matklad a=GrayJack

This PR added the `HighlightModifier::Callable` variant and assigned it to variables and parameters that are fn pointers, closures and implements FnOnce trait.

This allows to colorize these variables/parameters when used in call expression.



6310: Rewrite algo::diff to support insertion and deletion r=matklad a=Veykril

This in turn also makes `algo::diff` generate finer diffs(maybe even minimal diffs?) as insertions and deletions aren't always represented as as replacements of parent nodes now.

Required for #6287 to go on.

Co-authored-by: GrayJack <gr41.j4ck@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-23 22:12:15 +00:00
bors[bot]
dd8a75b2cf
Merge #6335
6335: Fix panic context r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-23 13:19:09 +00:00
Aleksey Kladov
1a74f25f90 Fix panic context 2020-10-23 15:18:33 +02:00
bors[bot]
81609960fa
Merge #6324
6324: Improve #[cfg] diagnostics r=jonas-schievink a=jonas-schievink

Unfortunately I ran into https://github.com/rust-analyzer/rust-analyzer/issues/4058 while testing this on https://github.com/nrf-rs/nrf-hal/, so I didn't see much of it in action yet, but it does seem to work.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-10-23 10:38:30 +00:00
adamrk
3dbbcfca67 Insert ref for completions 2020-10-22 22:45:14 +02:00
Jonas Schievink
3421b645e6 Emit better #[cfg] diagnostics 2020-10-22 19:19:18 +02:00
Jonas Schievink
2bc4c1ff31 Simplify cfg representation 2020-10-21 13:57:12 +02:00
Jonas Schievink
a54e481646 Simplify diagnostic construction, add unused field 2020-10-20 17:53:04 +02:00
Aleksey Kladov
af4e75533f Rename declaration_name -> display_name
Declaration names sounds like a name of declaration -- something you
can use for analysis. It empathically isn't, and is just a label
displayed in various UI. It's important not to confuse the two, least
we accidentally mix semantics with UI (I believe, there's already a
case of this in the FamousDefs at least).
2020-10-20 15:38:11 +02:00
Aleksey Kladov
6c7769a2e3 update deps 2020-10-18 01:53:01 +02:00
GrayJack
83d6bc7113
Add HighlightModifier::Callable and add it for locals 2020-10-16 06:38:32 -03:00
Laurențiu Nicola
017a04f424 Bump crossbeam-channel and lsp-server in rust-analyzer 2020-10-13 18:05:06 +03:00
Jonas Schievink
cde7392ec8 Improve prime_caches and display its progress 2020-10-12 13:35:01 +02:00
bors[bot]
518f6d7724
Merge #5917
5917: Add a command to open docs for the symbol under the cursor r=matklad a=zacps

#### Todo

- [ ] Decide if there should be a default keybind or context menu entry
- [x] Figure out how to get the documentation path for methods and other non-top-level defs
- [x] Design the protocol extension. In future we'll probably want parameters for local/remote documentation URLs, so that should maybe be done in this PR?
- [x] Code organisation
- [x] Tests


Co-authored-by: Zac Pullar-Strecker <zacmps@gmail.com>
2020-10-12 07:38:24 +00:00
Rüdiger Herrmann
e90931a204 Show reason for failed rename refactoring
Return an error with a meaningful message for requests to
`textDocument/rename` if the operation cannot be performed.
Pass errors raised by rename handling code to the LSP runtime.

As a consequence, the VS Code client shows and logs the request
as if a server-side programming error occured.

Resolves https://github.com/rust-analyzer/rust-analyzer/issues/3981
2020-10-10 13:46:10 +02:00
Zac Pullar-Strecker
a14194b428 Changes from review 2020-10-08 15:01:30 +13:00
Zac Pullar-Strecker
bfda0d2583 WIP: Command to open docs under cursor 2020-10-08 14:59:31 +13:00
Aleksey Kladov
6219142c96 Better progress API
Percentage is a UI concern, the physical fact here is fraction. It's
sad that percentage bleeds into the protocol level, we even duplicated
this bad API ourselves!
2020-10-07 12:15:37 +02:00
bors[bot]
57735f2a32
Merge #6140
6140: honour hover.content_format client capability r=lnicola a=robinvd

This removes all markdown when the client does not support the markdown MarkupKind.

Otherwise the output on the editor will have some markdown boilerplate, making it less readable.

For example kak_lsp does not currently support markdown.
![image](https://user-images.githubusercontent.com/22073483/95112949-ef0ff080-0741-11eb-82a7-0594fa2cd736.png)

after:
![image](https://user-images.githubusercontent.com/22073483/95113089-2bdbe780-0742-11eb-94fa-bcfec6d7347a.png)



Co-authored-by: Robin van Dijk <robin@robinjint.nl>
2020-10-06 17:51:20 +00:00
bors[bot]
87cb840a4e
Merge #6124
6124: Better normalized crate name usage r=jonas-schievink a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/5343 
Closes https://github.com/rust-analyzer/rust-analyzer/issues/5932

Uses normalized name for code snippets (to be able to test the fix), hover messages and documentation rewrite links (are there any tests for those?).
Also renamed the field to better resemble the semantics.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-10-06 11:51:15 +00:00
Robin van Dijk
c3cc361294 honor content_format clientcap
This removes all markdown when the client does not support the markdown MarkupKind

Otherwise the output on the editor will have some markdown boilerplate, making it less readable
2020-10-05 19:27:29 +02:00
Lukas Wirth
8699331014 Make ImportPrefix a configuration option 2020-10-05 17:41:49 +02:00
Kirill Bulatov
9d19e5b962 Properly name the field 2020-10-02 21:38:22 +03:00
Aleksey Kladov
8716c4cec3 Move ide::AnalysisChange -> base_db::Change
This seems like a better factoring logically; ideally, clients shouldn't touch
`set_` methods of the database directly. Additionally, I think this
should remove the unfortunate duplication in fixture code.
2020-10-02 16:45:08 +02:00
Igor Aleksanov
4ebacf9024 Fix failing test 2020-10-02 12:35:25 +03:00
Igor Aleksanov
4a1b4b23bb Replace 'cargo_prefix' option with 'override_cargo' 2020-10-02 12:34:27 +03:00
Igor Aleksanov
2c125f3c63 Add support of runnables arguments in Rust Analyzer 2020-10-02 12:34:27 +03:00
Aleksey Kladov
af8063fe37 Extend **Status** command to also show dep info for the file
This should help with troubleshooting wrong project configuration
2020-09-29 22:13:23 +02:00
Aleksey Kladov
e7df0ad2fb Remove periodic gc stub 2020-09-29 21:22:48 +02:00
Aleksey Kladov
8e34c0fb73 More panic_context 2020-09-29 20:49:48 +02:00
Aleksey Kladov
d3a2b21a8c Add panic_context module for better panic messages 2020-09-29 20:20:47 +02:00
vsrs
91da41b3b1 Replace "No references" with "0 references". 2020-09-29 15:29:20 +03:00
vsrs
06fbd69050 Make method references CodeLens lazy. 2020-09-29 15:29:20 +03:00
vsrs
b7fda5f936 Make method references CodeLens off by default. 2020-09-29 15:29:20 +03:00
vsrs
eeb40dbece Add method references CodeLens 2020-09-29 15:29:20 +03:00
flw
e73ee9dfa2
Add hover config linksInHover to suppress links 2020-09-29 19:47:18 +08:00
Jonas Schievink
1a28f30ba4 Spawn a flycheck instance per workspace 2020-09-27 19:41:54 +02:00
kjeremy
95d7e3ce49 lsp-types 0.82 2020-09-23 15:41:55 -04:00
bors[bot]
e70cf706bb
Merge #6018
6018: Correct project_root path for ProjectJson. r=jonas-schievink a=woody77

It was already the folder containing the rust-project.json file, not the file itself.  This also removes the Option-ness of it, since it's now an infallible operation to set the member value.

Co-authored-by: Aaron Wood <aaronwood@google.com>
2020-09-20 19:25:09 +00:00
bors[bot]
fb1b0a4bff
Merge #6036
6036: Don't re-read open files from disk when reloading a workspace r=kjeremy a=lnicola

Fixes #5742
Fixes #4263

or so I hope.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-09-18 21:29:47 +00:00
Laurențiu Nicola
5a0bad7754 Don't re-read open files from disk when reloading a workspace 2020-09-18 22:15:44 +03:00
kjeremy
c7243e4a59 Support active parameters at the per-signature level
Update crates
2020-09-18 11:39:25 -04:00
Jonas Schievink
d328ee647f Use log::error! in a few more places 2020-09-17 17:37:52 +02:00
bors[bot]
d84c18d989
Merge #6017
6017: Don't return any TextEdit if formatting is unchanged r=jonas-schievink a=cuviper

I found that `textDocument/formatting` was always returning a full
`TextEdit` replacement, even when there are no changes, which caused Vim
(w/ vim-lsp) to always indicate a modified buffer after formatting. We
can easily compare whether there were changes and return `null` if not,
so the client knows there's nothing to do.

Co-authored-by: Josh Stone <cuviper@gmail.com>
2020-09-17 13:08:09 +00:00
Aaron Wood
2fbb09a73f Correct project_root path for ProjectJson.
It was already the folder containing the rust-project.json file, not the file itself.
2020-09-16 12:09:44 -07:00
Josh Stone
29c3421391 Don't return any TextEdit if formatting is unchanged
I found that `textDocument/formatting` was always returning a full
`TextEdit` replacement, even when there are no changes, which caused Vim
(w/ vim-lsp) to always indicate a modified buffer after formatting. We
can easily compare whether there were changes and return `null` if not,
so the client knows there's nothing to do.
2020-09-16 10:05:41 -07:00
Aaron Wood
74c26a785a Add support for custom flycheck commands with JSON project workspaces
Enable flychecks with JSON project workspaces if an override command was provided as part
of the client configuration.
2020-09-15 18:51:57 -07:00
Lukas Wirth
adc4c6b9d7 Make MergeBehaviour configurable 2020-09-12 12:11:16 +02:00
Jonas Schievink
681ac6294a Report better errors in project.json/sysroot 2020-09-11 14:48:56 +02:00
Igor Aleksanov
023e3a1dea Highlight errors in macros 2020-09-06 09:22:01 +03:00
Andy Russell
24805d1d80
default checkOnSave.enable to true in server 2020-09-02 17:44:21 -04:00
kjeremy
36692bdffa Switch to upstream ENUM_MEMBER 2020-09-02 09:40:59 -04:00
kjeremy
b527257330 Move to vscode-languageclient 7.0.0-next.9
Stabilizes call hierarchy and semantic tokens features.
2020-09-02 09:40:59 -04:00
Kirill Bulatov
3ac9732ca3 Fix some typos 2020-08-28 21:55:24 +03:00
Aleksey Kladov
c692b5d76d ⬆️ expect-test 2020-08-28 14:47:14 +02:00
Jonas Schievink
964219f0be Allow running a test as a binary 2020-08-26 17:33:03 +02:00
León Orell Valerian Liehr
63caef372a Improve support for code block attributes 2020-08-26 15:55:06 +02:00
Aleksey Kladov
7431ec82c9 Simplify 2020-08-26 13:40:45 +02:00
Aleksey Kladov
ed6304131a Simplify 2020-08-26 13:20:46 +02:00
Aleksey Kladov
bb50614d88 Simplify help 2020-08-26 13:20:46 +02:00
Aleksey Kladov
a53c6f6fee Allow redirecting logs to a specific file
There's a surprising lack of crates which are like env_logger, but
also allow writing to a file. Let's write our own then!
2020-08-26 13:20:46 +02:00
Aleksey Kladov
c6dffe479b Cleanup heavy tests 2020-08-25 19:26:45 +02:00
bors[bot]
59c77ff062
Merge #5866
5866: Improve logging
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-25 09:46:21 +00:00
Aleksey Kladov
3a72afed8c Improve logging 2020-08-25 11:43:21 +02:00
Zac Pullar-Strecker
b835f06cec Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links 2020-08-25 16:44:36 +12:00
Pavan Kumar Sunkara
b2d43daeb4 Allow rust-analyzer auto publishing 2020-08-24 17:27:17 +02:00
Zac Pullar-Strecker
7bbca7a1b3 Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links 2020-08-24 21:20:13 +12:00
Pavan Kumar Sunkara
a8fa5cd42e Add version to deps in cargo.toml 2020-08-24 11:10:41 +02:00
Aleksey Kladov
b0fd3faf36 Switch to expect_test from crates.io 2020-08-21 13:19:31 +02:00
bors[bot]
529ca7e5e0
Merge #5643
5643: Add new consuming modifier, apply consuming and mutable to methods r=matklad a=Nashenas88

This adds a new `consuming` semantic modifier for syntax highlighters.

This also emits `mutable` and `consuming` in two cases:

- When a method takes `&mut self`, then it now has `function.mutable` emitted.
- When a method takes `self`, and the type of `Self` is not `Copy`, then `function.consuming` is emitted.

CC @flodiebold 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-19 11:27:02 +00:00
bors[bot]
0df9ecedb4
Merge #5798
5798: Introduce Label
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 14:51:10 +00:00
Aleksey Kladov
aa1a7a5414 Introduce Label 2020-08-18 16:50:07 +02:00
bors[bot]
0e66dc690e
Merge #5796
5796: Align diagnostics config with the rest of rust-analyzer
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 14:12:00 +00:00
Aleksey Kladov
0866b1be89 Align diagnostics config with the rest of rust-analyzer 2020-08-18 16:03:15 +02:00
bors[bot]
a3947129c5
Merge #5794
5794: Simplify building a symbol hierarchy
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 12:32:32 +00:00
Aleksey Kladov
e01cfe2b45 Simplify building a symbol hierarchy 2020-08-18 14:29:31 +02:00
bors[bot]
b8dfc331ab
Merge #5682
5682: Add an option to disable diagnostics r=matklad a=popzxc

As far as I know, currently it's not possible to disable a selected type of diagnostics provided by `rust-analyzer`.

This causes an inconvenient situation with a false-positive warnings: you either have to disable all the diagnostics, or you have to ignore these warnings.

There are some open issues related to this problem, e.g.: https://github.com/rust-analyzer/rust-analyzer/issues/5412, https://github.com/rust-analyzer/rust-analyzer/issues/5502

This PR attempts to make it possible to selectively disable some diagnostics on per-project basis.

Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-08-18 12:04:49 +00:00
bors[bot]
2252a65f23
Merge #5687
5687: Fix document symbols order r=matklad a=magurotuna

Resolves #5655 
And adds tests for `handle_document_symbol`, both with `hierarchical_symbols` enabled and with it disabled.

Previously document symbols were displayed in reverse order  in sublime text with its LSP plugin, but this patch fixes it like this:

![image](https://user-images.githubusercontent.com/23649474/89709020-fbccce00-d9b6-11ea-83b0-c88dc9f7977f.png)


Co-authored-by: Yusuke Tanaka <yusuktan@maguro.dev>
2020-08-18 11:58:02 +00:00
Igor Aleksanov
34847c8d96 Move analysis config structure to the config.rs 2020-08-18 13:35:36 +03:00
Igor Aleksanov
b56cfcca10 Make disabled diagnostics an argument of corresponding function 2020-08-18 13:32:29 +03:00
Aleksey Kladov
6cff076513 Revive cache cleaning
The idea here is that, on CI, we only want to cache crates.io
dependencies, and not local crates. This keeps the size of the cache
low, and also improves performance, as network and moving files on
disk (on Windows) can be slow.
2020-08-18 11:07:21 +02:00
bors[bot]
6826dd044a
Merge #5782
5782: Fix StatusNotification r=matklad a=vsrs

This PR fixes the following:

As per specification `params` property in [NotificationMessage ](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#notificationMessage) should be `array | object` while RA uses `"loading" | "ready" | "invalid" | "needsReload"`.

Co-authored-by: vsrs <vit@conrlab.com>
2020-08-17 14:23:03 +00:00
Aleksey Kladov
6a4c9fc9fd Don't make fields private unless you have to 2020-08-17 16:11:29 +02:00
vsrs
1eed036a6e Fix StatusNotification 2020-08-17 14:56:27 +03:00
Yusuke Tanaka
e8e1eb4263
Remove test for handle_document_symbol 2020-08-17 00:19:29 +09:00
Paul Daniel Faria
7009d5ee2b Add new HighlightModifier variant, Consuming 2020-08-16 10:22:51 -04:00
Igor Aleksanov
c26c911ec1 Merge branch 'master' into add-disable-diagnostics 2020-08-14 07:34:07 +03:00