Commit Graph

1457 Commits

Author SHA1 Message Date
Alex Muscar
41856e2682 fix: make signature info response conform to spec
This addreses
https://github.com/rust-analyzer/rust-analyzer/issues/10464.

This patch picks up `lsp-types` 0.90.1, which serialises the
`SignatureInformation` and `ParameterInformation` with the right casing.
It also adds `activeSignature` field as part of the top-level signature
response. It keeps `activeParameter` at the top-level for backwards
compatibility.
2021-10-11 20:42:16 +01:00
Quentin Gliech
824b7a8564
Add toolInfo in MetaData vertex in LSIF dumps
This helps with uploading LSIF dumps to Sourcegraph without having to
specify an indexer name.
2021-10-11 14:45:58 +02:00
Lukas Wirth
d14c9be321 Show cargo check failures to the user 2021-10-11 14:09:20 +02:00
bors[bot]
64ca0f63bf
Merge #10504
10504: Remove needless clone r=lnicola a=k-nasa

## Why

Delete clones for efficiency

## What

- I erased unnecessary clones


Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:17:52 +00:00
k-nasa
b50cb5c261 Remove neesless clone 2021-10-10 10:50:51 +09:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03:00
rainy-me
aaa0771719 Fix: compare pkg via manifest 2021-10-07 23:44:25 +09:00
bors[bot]
5ff992465e
Merge #10447
10447: Add enum variant references CodeLens. r=Veykril a=ericsampson



Co-authored-by: Eric Sampson <esampson@eaze.com>
2021-10-05 22:03:23 +00:00
bors[bot]
c409cf0e26
Merge #10458
10458: feat: Implement custom user snippets r=Veykril a=Veykril

![Y24dX7fOWX](https://user-images.githubusercontent.com/3757771/136059454-ceccfc2c-2c90-46da-8ad1-bac9c2e83ec1.gif)

Allows us to address the following issues:
    - `.arc / .rc / .pin, similar to .box?` https://github.com/rust-analyzer/rust-analyzer/issues/7033
    - `Add unsafe snippet` https://github.com/rust-analyzer/rust-analyzer/issues/10392, would allow users to have this without the diagnostic)
    - `.ok() postfix snippet is annoying` https://github.com/rust-analyzer/rust-analyzer/issues/9636, allows us to get rid of the `ok` postfix and similar ones
    - `Postfix vec completion` https://github.com/rust-analyzer/rust-analyzer/issues/7773

cc https://github.com/rust-analyzer/rust-analyzer/issues/772

Zulipd discussion: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Custom.20Postfix.20snippets

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-05 16:41:11 +00:00
Lukas Wirth
77cbf4adbc Bring the implementation closer to VSCode snippet definitions 2021-10-05 17:18:40 +02:00
Aramis Razzaghipour
9583dd5725
Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
Lukas Wirth
ca1fdd75f1 Regen docs 2021-10-04 22:13:12 +02:00
Lukas Wirth
454ecd167c Make multiple import edits work for completions 2021-10-04 21:44:33 +02:00
Lukas Wirth
046c85ef0c Add custom non-postfix snippets 2021-10-04 19:22:41 +02:00
Lukas Wirth
88f213eadd Initial implementation of custom postfix snippets 2021-10-04 17:49:21 +02:00
Eric Sampson
a0bb31587e Add enum variant references CodeLens. 2021-10-04 02:18:31 -05:00
Aramis Razzaghipour
55c0b86cde
Add semicolons for consistency
`clippy::semicolon_if_nothing_returned`
2021-10-03 23:39:43 +11:00
rainy-me
39044fe39c Allow locate parent module action in cargo toml 2021-10-03 11:58:10 +09:00
Aleksey Kladov
12103b16de internal: untangle usages of ReferenceCategory somewhat
Not everything that can be read or write is a reference, let's try to
use more precise types.
2021-10-02 13:02:06 +03:00
Aleksey Kladov
46eb03d99a internal: use naming that matches intended use-case 2021-10-02 12:18:18 +03:00
lhvy
dbb02370a4
Add semantic token modifier for crate root 2021-10-01 20:52:13 +10:00
Lukas Wirth
0c7ea0c9a1 Fix add missing semantic token modifier in SUPPORTED_MODIFIERS 2021-09-30 20:38:05 +02:00
lhvy
f713cfb818
Remove unneeded semantic token definition 2021-10-01 01:55:29 +10:00
lhvy
2b3baa8503
Give defaultLibrary semantic token modifier to items from standard library 2021-10-01 01:19:24 +10:00
bors[bot]
ee12b0f173
Merge #10181
10181: Begining of lsif r=HKalbasi a=HKalbasi

This PR adds a `lsif` command to cli, which can be used as `rust-analyzer lsif /path/to/project > dump.lsif`. It now generates a valid, but pretty useless lsif (only supports folding ranges). The propose of this PR is to discussing about the structure of lsif generator, before starting anything serious.

cc `@matklad` #8696 #3098


Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-09-29 13:13:03 +00:00
hamidreza kalbasi
5bd0f50111 remove glob import and cancellables 2021-09-29 16:25:10 +03:30
Laurențiu Nicola
81891f7abe Enable attribute proc macros by default 2021-09-27 18:11:31 +03:00
hamidreza kalbasi
13d36e96c2 use crates io version 2021-09-26 10:39:23 +03:30
hamidreza kalbasi
48bebeaa32 support goto definition and find references 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
f2775ac2e9 reuse hover results with resultset 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
70061d2b7e move lsif types to lsp types crate 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
e803bd25c4 add hover 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
1103e390e0 cfg unix for tests with unix path 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
5163201847 use utf16 instead of utf8 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
557210a688 Begining of lsif 2021-09-26 10:04:02 +03:30
Nixon Enraght-Moony
720a3da4ac Give rustfmt spawn error context. 2021-09-24 17:51:47 +01:00
bors[bot]
eb17e90eba
Merge #10105
10105: RfC: Use `todo!()` instead of `()` for missing fields r=jonas-schievink a=jo-so

Most commonly a field of a struct can be initialized with its default value than an empty tuple.

Co-authored-by: Jörg Sommer <joerg@jo-so.de>
2021-09-24 15:12:17 +00:00
bors[bot]
377476ac45
Merge #10332
10332: minor: Allow overwriting RUST_BACKTRACE for the server manually r=jonas-schievink a=Veykril

Trying to figure out why we aren't getting backtraces for windows builds from CI, this let's one set the backtraces to `FULL`
Might be cc https://github.com/rust-lang/rust/issues/87481
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-24 14:59:02 +00:00
Lukas Wirth
983e19c868 Allow setting RUST_BACKTRACE for the server manually 2021-09-24 15:38:00 +02:00
Carlos Menezes
0c49e3883c
Fix link to "Auto Import" 2021-09-24 13:59:44 +01:00
Lukas Wirth
e60f3d265f Split the hover module up 2021-09-23 20:36:15 +02:00
Lukas Wirth
8b2be8572f Rename some assists 2021-09-21 00:54:09 +02:00
Dawer
0ff271d38f fix completion handler trying to seek outside of character boundaries.
With this patch, in these examples
```rust
fn main() {
    "⊞$0";
}
```

```rust
struct S {
д$0 u8
}
```
entering ':' character in `$0` places shouldn't cause panics.
2021-09-17 23:04:20 +05:00
bors[bot]
6eecd84771
Merge #10126
10126: feat: Speculatively expand attributes in completions r=Veykril a=Veykril

![j1OjBt5Nca](https://user-images.githubusercontent.com/3757771/133163858-91930072-1441-4ce4-9979-b0ad2727b47f.gif)

Fixes #9866

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-13 22:22:08 +00:00
Lukas Wirth
dfb94d09d4 Exclude test file from rust tidy check 2021-09-14 00:21:16 +02:00
bors[bot]
bcf0072bb4
Merge #10199
10199: fix: Fix Cargo.toml change detection r=lnicola a=lnicola

Maybe fixes #9546

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-09-13 18:14:20 +00:00
Laurențiu Nicola
4d7a3bb5c7 Shuffle code around to avoid an allocation 2021-09-13 21:06:31 +03:00
Lukas Wirth
edc915fbb6 Add proc-macro fixture directive 2021-09-13 18:37:50 +02:00
Laurențiu Nicola
8875f2c8aa Fix Cargo.toml change detection 2021-09-13 19:15:17 +03:00
Giles Cope
15312aab58
removing seemingly unused dev deps. 2021-09-11 16:26:36 +01:00
Giles Cope
4ccd90af81
remove unused deps 2021-09-11 16:20:04 +01:00
Jörg Sommer
c87b860d3d Use todo!() instead of () for missing fields
The generated code with `()` doesn't compile in most of the cases. To signal
the developer there's something to do, fill in `todo!()`.

Because the file *missing_fields.rs* contains the string `todo!()` it needs
an exception for the test *check_todo*.
2021-09-09 18:04:50 +02:00
Jonas Schievink
e241015a75 Rename is_member to is_local 2021-09-07 17:29:58 +02:00
David Barsky
184fbf24f0 update to tracing-tree 0.1.10, which does not pull in syn. 2021-09-06 10:33:08 -04:00
bors[bot]
5fb2eb2314
Merge #10147
10147: fix: don't panic if the client sends invalid request r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-04 13:56:47 +00:00
Aleksey Kladov
2d2c4e7c22 internal: deduplicate 2021-09-04 16:56:23 +03:00
Aleksey Kladov
33199b7e43 fix: don't panic if the client sends invalid request 2021-09-04 12:27:27 +03:00
Ali
1fd153a24e
fix error message for when DidChangeTextDocument path doesn't exist 2021-09-02 15:19:47 -07:00
Jonas Schievink
bdba35cc93 fix: multi-token mapping aware find references 2021-09-01 19:19:16 +02:00
Aleksey Kladov
81602f8a5d internal: reduce coupling
tt is a data structure, data structures cant' go wrong, they shouldn't
have the knowledge that the world outside of them has all kinds of
errors.
2021-08-31 19:14:33 +03:00
Aleksey Kladov
d8a3d6f378 internal: cleanup proc macro server error handlig
When dealing with proc macros, there are two very different kinds of
errors:

* first, usual errors of "proc macro panicked on this particular input"
* second, the proc macro server might day if the user, eg, kills it

First kind of errors are expected and are a normal output, while the
second kind are genuine IO-errors.

For this reason, we use a curious nested result here: `Result<Result<T,
E1>, E2>` pattern, which is 100% inspired by http://sled.rs/errors.html
2021-08-31 19:01:39 +03:00
Aleksey Kladov
722a2a4690 minor: improve readability
naming, layout & comments help!
2021-08-31 15:46:00 +03:00
Aleksey Kladov
8dbf3832b2 internal: split database loading time in anaysis-stats into components 2021-08-31 14:38:52 +03:00
Aleksey Kladov
53d2050085 feat: improve CPU usage
closes #9922

Turned out to be trivial after preliminary refactor.

The intended behavior is that we schedule cache priming once ws become
quiescent (that is, we fully load cargo project), and we continue to
rschedule it until it completes (priming might get cancelled by user
typing into a file).
2021-08-30 19:48:16 +03:00
Aleksey Kladov
9e0203bd69 internal: make scheduling control flow more obvious
There should be only one place where we need to check if we want to
start background activities.
2021-08-30 19:39:08 +03:00
Aleksey Kladov
a59f344c4f internal: improve consistency
Let's have only one place where we start delayed ops
2021-08-30 19:24:31 +03:00
Aleksey Kladov
6317292cd5 internal: more obviously correct code for cache priming progerss
It doesn't make sense for the prime_caches itself send begin/end events
-- the caller knows perfectly fine when they happen!
2021-08-30 19:18:48 +03:00
bors[bot]
1636f61a15
Merge #10005
10005: Extend `CargoConfig.unset_test_crates`  r=matklad a=regexident

This is to allow for efficiently disabling `#[cfg(test)]` on all crates (by passing `unset_test_crates: UnsetTestCrates::All`) without having to first load the crate graph, when using rust-analyzer as a library.

(FYI: The change doesn't seem to be covered by any existing tests.)

Co-authored-by: Vincent Esche <regexident@gmail.com>
2021-08-30 08:42:13 +00:00
bors[bot]
ceecf853ee
Merge #10080
10080: internal: don't shut up the compiler when it says the code's buggy r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 07:58:59 +00:00
Aleksey Kladov
a833fba98a internal: don't shut up the compiler when it says the code's buggy
Wrapping state-modifying functions into a `catch_unwind` is wrong -- to
do retry after failure, you need to have transactional semantics!
2021-08-30 10:58:39 +03:00
bors[bot]
b3452dd379
Merge #10079
10079: internal: make upstream bug less annoying r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 07:39:34 +00:00
Aleksey Kladov
3a055a6b1f internal: make upstream bug less annoying 2021-08-30 10:32:59 +03:00
Dezhi Wu
ba0947dded switch log crate to tracing 2021-08-30 15:11:42 +08:00
Aleksey Kladov
cb3d04c818 minor: nicer way to defeat disjoint closure captures
Thanks https://internals.rust-lang.org/t/feature-idea-edition-dependent-names-replacing-standard-library-items/15198/27?u=matklad!
2021-08-26 22:13:50 +03:00
Vincent Esche
74880a10ae Extend CargoConfig.unset_test_crates to allow for efficiently disabling #[cfg(test)] on all crates without having to first load the crate graph 2021-08-26 13:10:14 +02:00
Jonas Schievink
0ff2c81bb9 Fix reporting of build script errors 2021-08-25 17:56:39 +02:00
Jonas Schievink
095df7bc39 Don't fetch build script output twice 2021-08-25 17:56:24 +02:00
bors[bot]
49c02b93b3
Merge #9993
9993: feat: join lines merges assignments r=matklad a=unexge

Closes https://github.com/rust-analyzer/rust-analyzer/issues/9967.
![Peek 2021-08-22 21-46](https://user-images.githubusercontent.com/16212576/130366571-3ebb1753-f8d5-4884-be8f-222cda71a2a7.gif)


Co-authored-by: unexge <unexge@gmail.com>
2021-08-24 12:14:25 +00:00
Aleksey Kladov
1660820e51 internal: use idiomatic form of assertions
Ideally, we should just return an InvalidParameter dialog here, but that
shows error message to the end user, and we generally avoid that
2021-08-24 14:09:34 +03:00
unexge
3a9ba0e506 feat: join lines merges assignments 2021-08-22 21:28:39 +03:00
Aleksey Kladov
85fbbc5372 internal: incentivize rust-analyzed developers to fix panics
It's good that rust-analyzer doesn't belly-up on a panic in some random
assist.

It is less good that rust-analyzer devs only know that the assists are
buggy when they are actively looking at the logs.
2021-08-22 17:54:50 +03:00
Aleksey Kladov
e86388689f internal: remove unreasonable crate dependency
Proc macro expansion shouldn't know about salsa at all.
2021-08-22 14:05:12 +03:00
Aleksey Kladov
881d71a489 internal: reduce crate interdependence
I don't think there's anything wrong with project_model depending on
proc_macro_api directly -- fundamentally, both are about gluing our pure
data model to the messy outside world.

However, it's easy enough to avoid the dependency, so why not.

As an additional consideration, `proc_macro_api` now pulls in `base_db`.
project_model should definitely not depend on that!
2021-08-22 13:32:00 +03:00
Aleksey Kladov
1850849325 internal: prep to 2021 edition 2021-08-20 16:20:18 +03:00
Aleksey Kladov
92da7e9ffa internal: optimize compile time
cargo llvm-lines shows that path_to_error bloats the code. I don't think
I've needed this functionality recently, seems that we've fixed most of
the serialization problems. So let's just remove it. Should be easy to
add back if we ever need it, and it does make sense to keep the
`from_json` function around.
2021-08-15 13:24:37 +03:00
André Oliveira
11bbaecca0 Formatting issues 2021-08-10 13:43:57 +00:00
André Oliveira
b29508949d Remove debug logs 2021-08-10 13:43:57 +00:00
André Oliveira
8a563e4a46 Use local node_modules to allow the graph to load offline
- Fix some warnings
2021-08-10 13:43:08 +00:00
André Oliveira
f4f68e62c2 Use d3-graphviz for rendering crates graph on the extension side 2021-08-10 13:40:49 +00:00
bors[bot]
a739a579cd
Merge #9841
9841: internal: print total size of source code in analysis-stats r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-10 12:31:35 +00:00
Aleksey Kladov
a379bd715f
Update crates/rust-analyzer/src/cli/analysis_stats.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2021-08-10 15:31:12 +03:00
Aleksey Kladov
5d5d5182c1 internal: print total size of source code in analysis-stats 2021-08-10 15:28:48 +03:00
bors[bot]
e652545472
Merge #9830
9830: Enable more assists to generate default trait body impls r=Veykril a=yoshuawuyts

Enable more assists to benefit from trait body generation. Follow-up to #9825 and #9814.

__edit:__ I'd like to move the existing tests to this new file too, but I'll do that in a follow-up PR.

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-08-10 10:27:55 +00:00
Yoshua Wuyts
326890753c implement feedback from review 2021-08-10 12:21:48 +02:00
Aleksey Kladov
9cf5914c45 internal: unify subcommand handling between ra and xtask 2021-08-10 12:49:55 +03:00
Aleksey Kladov
e8a67b67bf internal: prepare to use standard .run pattern for subcommands 2021-08-10 12:25:47 +03:00
Yoshua Wuyts
d6b788a9ee Add trait codegen to add_missing_impl_members assist 2021-08-10 10:27:52 +02:00
Aleksey Kladov
ce8400bbfd internal: drop latest requests tracking
From the dawn of time, when dinosaurs roamed the and we didn't have
hierarchical profiling, there was the `latest_requests` infra we used to
track the time of ten last requests.

Today, no one is actually using it and, what's more, it itself became
pretty useless -- LSP grew way more chatty, and 10 requests don't really
paint any kind of picture.

Personally, it's been years since I last looked at latest requests in
the status output.

So, let's remove a tiny bit of state from the big ball of complexity
that is `GlobalState` and `main_loop`!
2021-08-09 18:56:19 +03:00
Aleksey Kladov
9aa6be71a5 internal: remove useless helpers
We generally avoid "syntax only" helper wrappers, which don't do much:
they make code easier to write, but harder to read. They also make
investigations harder, as "find_usages" needs to be invoked both for the
wrapped and unwrapped APIs
2021-08-09 15:58:21 +03:00
Yoshua Wuyts
5a3c3a029c exclude files from tidy check 2021-08-08 18:44:54 +02:00