Commit Graph

1542 Commits

Author SHA1 Message Date
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
Jonas Schievink
a310d74536 Don't publish diagnostics in library source roots 2021-08-06 16:14:54 +02:00
Jonas Schievink
5386dc648e Bless tests 2021-08-06 15:59:58 +02:00
Jonas Schievink
30e472a12a Don't include empty suggestions 2021-08-06 15:58:55 +02:00
Jonas Schievink
efe662d474 Include suggested replacement in diagnostics 2021-08-06 15:52:47 +02:00
bors[bot]
1b02cafa43
Merge #9734
9734: semantic highlighting: add reference hlmod r=matklad a=jhgg

This PR adds the "reference" highlight modifier! 

I basically went around and looked for `HlMod::Mutable` to find the callsites to add a reference. I think these all make sense! 

Co-authored-by: Jake Heinz <jh@discordapp.com>
Co-authored-by: Jake <jh@discordapp.com>
2021-08-04 09:37:30 +00:00
Vincent Esche
fee3507b71 Make LoadCargoConfig, fn load_workspace_at & fn load_workspace public again 2021-08-01 19:12:04 +02:00
Jake Heinz
2baef17bb1 semantic highlighting: add reference hlmod 2021-07-31 04:42:47 +00:00
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]
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]
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
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
41943f2328 refactor: Apply PR suggestions 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
1a0a5da1a4 refactor: Make handle_hover handle ranges too 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
Aleksey Kladov
7d6c4142b2 fix: add capability for "open cargo.toml" lsp extension 2021-07-27 19:40:19 +03:00
Aleksey Kladov
891867b1f1 fix: correctly update diagnostics when files are opened and closed
Basically, this tracks the changes to `subscriptions` we use when
issuing a publish_diagnostics.
2021-07-26 21:22:06 +03:00
Aleksey Kladov
410679285b internal: prepare to track changes to mem_docs 2021-07-26 20:17:10 +03:00
bors[bot]
f0db648cb6
Merge #9558
9558: Do not erase Cargo diagnostics from the closed documents r=matklad a=SomeoneToIgnore

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

The LSP specification at https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_publishDiagnostics states that


> Diagnostics notification are sent from the server to the client to signal results of validation runs.
> 
> Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics:
> 
>  *  if a language is single file only (for example HTML) then diagnostics are cleared by the server when the file is closed.
>  *  if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache).
> 
> When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. If the computed set is empty it has to push the empty array to clear former diagnostics. Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side.


So for projects we should not clear any diagnostics from cargo/json projects.
Our "standalone file" mode is in a way a project too, with sysroot attached and a potential support for dynamic standalone files.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-07-26 14:53:05 +00:00
Laurențiu Nicola
d9ec9d95c5 Bump deps 2021-07-24 11:16:32 +03:00
Kevin DeLorey
7797c59f18 Updated docs. 2021-07-22 19:35:47 -06:00
Kevin DeLorey
b75e0e7bb1 Initial commit of highlight related configuration w/ implementation. 2021-07-22 19:35:47 -06:00
bors[bot]
2fbecccc71
Merge #9634
9634: minor update to excludeDirs doc r=lnicola a=dae

I saw reference to globs in #7755, but it doesn't look like they're
actually supported, and I had to dig through the source to discover
that the folders are relative to the workspace root. Further digging
was required to get VS Code from hanging for long periods trying to
watch giant Bazel folders that had already been excluded from Rust
Analyzer. Hopefully this tweak will save others the confusion :-)

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2021-07-22 11:43:05 +00:00
Damien Elmes
d22b830ed1 mention files.watcherExclude
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2021-07-22 21:25:23 +10:00
Laurențiu Nicola
efcc487dff Fix a couple of clippy nits 2021-07-22 09:03:54 +03:00
Aleksey Kladov
efa4a36a50 docs: publish Explaining Rust Analyzer series 2021-07-19 23:41:15 +03:00
Aleksey Kladov
493ed2c17b internal: use types to remove some unwraps 2021-07-19 21:20:10 +03:00
bors[bot]
c595676f7e
Merge #9625
9625: internal: simplify handling of the build scripts r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-19 15:28:36 +00:00
Aleksey Kladov
700210d8b4 remove debug prints 2021-07-19 16:38:36 +03:00
Aleksey Kladov
b97eec8c0e fix tests 2021-07-19 16:38:36 +03:00
KOLANICH
f00206331a Added some metadata for rust-analyser package sufficient to build it using cargo deb
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2021-07-19 16:35:16 +03:00
Damien Elmes
106ea7ad85 minor update to excludeDirs doc
I saw reference to globs in #7755, but it doesn't look like they're
actually supported, and I had to dig through the source to discover
that the folders are relative to the workspace root. Further digging
was required to get VS Code from hanging for long periods trying to
watch giant Bazel folders that had already been excluded from Rust
Analyzer. Hopefully this tweak will save others the confusion :-)
2021-07-19 23:30:00 +10:00
Aleksey Kladov
b8b166e674 fix: potential bugs when build scripts do not match the current project 2021-07-18 13:13:03 +03:00
Aleksey Kladov
f4de2ece0d internal: simplify handling of the build scripts 2021-07-18 11:29:22 +03:00
Aleksey Kladov
8d8c26e6f5 internal: a bit more of cwd safety for flycheck 2021-07-17 18:13:35 +03:00
Lukas Wirth
d837a5d5a7 Show test mod runnable in outline modules 2021-07-14 11:30:51 +02:00
Aleksey Kladov
5c26523e94 drop unused fields 2021-07-11 13:51:52 +03:00
Aleksey Kladov
a04775060c simplify 2021-07-11 13:49:38 +03:00
Aleksey Kladov
ddce16a126 drop unused field 2021-07-11 13:48:26 +03:00
Aleksey Kladov
beb81a40eb simplify 2021-07-11 13:45:58 +03:00
Aleksey Kladov
fa6f78c95b better name 2021-07-11 13:43:43 +03:00
Aleksey Kladov
0dc186f612 Let the client care about presentation 2021-07-11 13:42:19 +03:00
Aleksey Kladov
148e11aa9e prepare to move run/debug splitting to handlers 2021-07-11 13:34:22 +03:00
bors[bot]
325140a165
Merge #9449
9449: feat: Emit test names in `Run test` runnables if they come from a macro expansion r=matklad a=Veykril

Fixes #8964
Before:
![Code_D1Tu5Iuh5I](https://user-images.githubusercontent.com/3757771/124174685-f552b380-daac-11eb-9086-c97db014b77c.png)
After:
![image](https://user-images.githubusercontent.com/3757771/124174493-bb81ad00-daac-11eb-96c7-3de6545a62e1.png)

Basically when a macro emits more than one test we name the test functions/modules name in the runnable instead to not emit a bunch of equally named `Run Test` annotations which don't really tell much.

Note that the `Run fibonacci_test Tests` line is below the attributes due to the fact that the function name span is being reused for the generated module in rstest's expansion.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-11 09:37:33 +00:00
Kirill Bulatov
8ed9724413 Do not erase Cargo diagnostics from the closed documents 2021-07-11 00:04:11 +03:00
Lukas Wirth
f1b3446844 Emit test name in Run test runnables if it comes from a macro expansion 2021-07-09 14:35:42 +02:00
Aleksey Kladov
0db4f3f6a4 internal: ensure consistent passing for config params
We pass "context" parametes first, so configs should be on the left.
"Bigger" context wins, so configs goes after db.
2021-07-06 00:00:39 +03:00
Aleksey Kladov
b8a6ea5ab5 feat: make join lines behavior configurable
closes #9492
2021-07-05 23:47:20 +03:00
mahdi-frms
60e304c7b6 refactor logger flushing 2021-07-05 21:37:17 +04:30
mahdi-frms
799ec79f18 make the logs line buffered 2021-07-05 19:49:21 +04:30
Aleksey Kladov
86720f2953 minor: drop dummy authors field 2021-07-05 14:19:41 +03:00
Aleksey Kladov
fbb9d69758 feat: always prefer postfix snippets if there's exact textual match
Note that, while we don't currently have a fuzzy-matching score, it
makes sense to special-case postfix templates -- it's very annoying when
`.not()` gets sorted before `.not`. We might want to move this infra to
fuzzy matching, once we have that!
2021-07-04 16:50:02 +03:00
Aleksey Kladov
6e9780c005 internal: make CompletionItem and SourceChange consistent
Before this PR, SourceChange used a bool and CompletionItem used an enum
to signify if edit is a snippet. It makes sense to use the same pattern
in both cases. `bool` feels simpler, as there's only one consumer of
this API, and all producers are encapsulated anyway (we check the
capability at the production site).
2021-07-04 15:44:03 +03:00
Aleksey Kladov
f34762abb7 internal: better factoring for to_proto::completion
One source completion can produce up to two lsp completions.
Additionally, `preselct` and `sort_text` are global properties of the
whole set of completions, so the right granularity here is to convert
many completions.

As a side-benefit, we no loger allocate intermediate vec.
2021-07-04 14:08:33 +03:00
Aleksey Kladov
3be9ebe2c3 minor: style 2021-07-04 12:48:29 +03:00
Aleksey Kladov
90e27d6289 internal: make xtask lighter
Moving tests to `rust-analyzer` crate allows removing walkdir dependency
from `xtask`. It does seem more reasonable to keep tidy tests outside of
the "build system" and closer to other integration tests.
2021-07-04 12:47:56 +03:00
Aleksey Kladov
58d2ece88a internal: overhaul code generation
* Keep codegen adjacent to the relevant crates.
* Remove codgen deps from xtask, speeding-up from-source installation.

This regresses the release process a bit, as it now needs to run the
tests (and, by extension, compile the code).
2021-07-03 22:11:03 +03:00
Jonas Schievink
5f13fb9db9 Add "View Crate Graph (Full)" 2021-07-02 00:10:33 +02:00
bors[bot]
11b9233fc4
Merge #9269
9269: Recreate status page r=lnicola a=Milo123459

I'm working on redesigning the status page.

Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2021-06-29 19:53:19 +00:00
Laurențiu Nicola
f1f3d5cb84 Watch for Cargo.toml and .lock changes 2021-06-29 14:38:50 +03:00
Lukas Wirth
9a1b9b3c78 Resolve attribute paths in attribute highlighting 2021-06-28 21:53:17 +02:00
bors[bot]
264716e827
Merge #9375
9375: feat: Highlight exit and yield points r=Veykril a=Veykril

![Code_YBHOCF3DbU](https://user-images.githubusercontent.com/3757771/123128986-e1270a80-d44b-11eb-9854-065459a2dd50.png)
![Code_YyMhqES0LX](https://user-images.githubusercontent.com/3757771/123128988-e1bfa100-d44b-11eb-9c81-6a6031aad740.png)

Fixes #4691
Fixes #9365

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-24 15:23:25 +00:00
Lukas Wirth
066bc4f3a4 Simplify 2021-06-24 01:32:56 +02:00
bors[bot]
b656751536
Merge #9380
9380: feat: Implement goto_declaration support r=matklad a=Veykril

This is just a simple implementation that falls back to `goto_definition` for everything but modules where it goes to the actual module declaration if possible.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-23 22:33:05 +00:00
Lukas Wirth
37d417868e move goto_declaration fall back into handlers 2021-06-24 00:26:08 +02:00
Lukas Wirth
14b66bb458 Rename 'document_highlight' to 'highlight_related' 2021-06-23 15:13:48 +02:00
Lukas Wirth
b26a8ecca1 Move document highlighting computation from rust-analyzer to ide 2021-06-23 15:02:49 +02:00
Aramis Razzaghipour
3e7472f76c
Add public semantic token modifier for public items 2021-06-23 09:40:04 +10:00
Lukas Wirth
5a74e93c33 Implement goto_declaration support 2021-06-22 20:49:07 +02:00
bors[bot]
37dc2dfada
Merge #9348
9348: output to log file if RA_LOG_FILE is defined in environment r=rezural a=rezural

This adds a check for RA_LOG_FILE, and logs to that if defined. It currently overrides flags.log_file. If this is undesirable, I will add a check.

Co-authored-by: rezural <rezural@protonmail.com>
2021-06-21 21:42:02 +00:00
Lukas Wirth
65d683df36 Collapse documentation and markdown config settings into an enum 2021-06-21 21:57:01 +02:00
Lukas Wirth
99c95b8fa1 Split hover actions config into its own config struct 2021-06-21 21:47:54 +02:00
bors[bot]
25bf451c84
Merge #9264
9264: feat: Make documentation on hover configurable r=Veykril a=Veykril

This also implements deprecation support for config options as this renames `hoverActions_linksInHover` to `hover_linksInHover`.

Fixes #9232

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-21 14:15:49 +00:00
Lukas Wirth
43098d99ae Remove deprecation support in config 2021-06-21 16:15:25 +02:00
rezural
baa060a994 output to log file if RA_LOG_FILE is defined in environment 2021-06-21 09:33:57 +10:00
Milo
044e21ae08 remove num_format 2021-06-19 10:14:15 +01:00
Jade
8b77e2692c Implement a config override for the default #[cfg(test)] in cargo crates
Fixes crates which vanish when the 'test' cfg atom is set.

Fix #7243.
Fix #9203.
Fix #7225.
2021-06-19 01:09:19 -07:00
Milo
d8209e6378 fmt 2021-06-19 08:12:58 +01:00
Milo
664cc8c754 use num_format 2021-06-19 08:12:46 +01:00
Milo
7aaadf929d make workspaces look better 2021-06-18 23:20:30 +01:00
Lukas Wirth
2ee090faaf Allow to disable import insertion on single path glob imports 2021-06-18 23:11:56 +02:00
Milo
7d502c7f08 Recreate PR. 2021-06-18 19:22:03 +01:00
Lukas Wirth
b6cb6d5abe simplify 2021-06-17 17:58:26 +02:00
bors[bot]
f6e73d510d
Merge #9258
9258: minor: Give `ImportPrefix` variants better config names r=matklad a=Veykril

I feel like `crate` and `self` work better than `by_crate` and `by_self`. The only reason for the current names were that `Self` doesn't work for the variant name on the rust side so I forgot about setting proper config names on serde layer.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-16 14:53:06 +00:00
Aleksey Kladov
f521e41853 internal: introduce minicore -- a subset of libcore for testing 2021-06-15 21:03:08 +03:00
Laurențiu Nicola
41949748a6 Use objects instead of bools for markers in package.json 2021-06-15 09:40:43 +03:00
Lukas Wirth
178b5ffba3 Add configuration deprecation 2021-06-14 15:49:57 +02:00
Lukas Wirth
a93d166f0f Make documentation on hover configurable 2021-06-14 15:25:10 +02:00
bors[bot]
5a8ddb4b2d
Merge #9260
9260: tree-wide: make rustdoc links spiky so they are clickable r=matklad a=lf-

Rustdoc was complaining about these while I was running with --document-private-items and I figure they should be fixed.

Co-authored-by: Jade <software@lfcode.ca>
2021-06-14 07:16:48 +00:00
Jade
20b325c7d5 tree-wide: make rustdoc links spiky so they are clickable 2021-06-13 21:58:05 -07:00
Lukas Wirth
b58c1c9eb2 Give ImportPrefix variants better config names 2021-06-13 22:00:39 +02:00
Aleksey Kladov
500c909c76 internal: diagnostic code is mandatory 2021-06-13 22:17:36 +03:00
Maan2003
c50b4579ec
clippy::useless_return 2021-06-13 09:35:29 +05:30
Maan2003
75370312fb
clippy::redundant_closure 2021-06-13 09:29:36 +05:30
Maan2003
c9b4ac5be4
clippy::redudant_borrow 2021-06-13 09:24:16 +05:30
Kirill Bulatov
339448157c Only prefill caches in the completion benchmark 2021-06-11 09:27:25 +03:00
Kirill Bulatov
b24f816c0d Fix visibility issues 2021-06-11 02:00:05 +03:00
Kirill Bulatov
ba65d259de Prime caches on workspace load 2021-06-11 02:00:03 +03:00
Lukas Wirth
88bc4f17fd Fix incorrect config usage in hover references 2021-06-07 12:32:25 +02:00
Laurențiu Nicola
18484365e6 Enable proc macros and build scripts by default in CLI 2021-06-05 15:20:41 +03:00
Florian Diebold
d174b919dc Enable attribute macro expansion in analysis-stats
Before:
```
> $ rust-analyzer -q analysis-stats --with-proc-macro --load-output-dirs .
Database loaded:     19.08s, 277minstr
  crates: 34, mods: 688, decls: 13202, fns: 10412
Item Collection:     16.21s, 76ginstr
  exprs: 290580, ??ty: 2508 (0%), ?ty: 1814 (0%), !ty: 947
Inference:           27.46s, 108ginstr
Total:               43.67s, 184ginstr
```
After:
```
> $ ./target/release/rust-analyzer -q analysis-stats --with-proc-macro --load-output-dirs .
Database loaded:     1.09s, 277minstr
  crates: 34, mods: 688, decls: 14790, fns: 11006
Item Collection:     18.20s, 78ginstr
  exprs: 297826, ??ty: 493 (0%), ?ty: 558 (0%), !ty: 342
Inference:           28.34s, 111ginstr
Total:               46.54s, 190ginstr
```
2021-06-05 11:29:24 +02:00
Lukas Wirth
07394316ff Add function references hover action 2021-06-04 15:54:55 +02:00
Jonas Schievink
9fdb8f9037 Make it opt-in 2021-06-03 18:09:21 +02:00
Matthias Krüger
9452dfaac7 NFC: remove redundant clones (clippy::perf) 2021-06-03 15:32:46 +02:00
Lukas Wirth
d304352407 Document that addCallArgumentSnippets requires `addCallParenthesis 2021-06-02 22:10:09 +02:00
bors[bot]
e6ec860363
Merge #9039
9039: feat: Complete fields and methods with `self.` prefixed when inside methods r=matklad a=Veykril


![w65NbjkZiG](https://user-images.githubusercontent.com/3757771/119984385-a0111700-bfc1-11eb-9dbf-52fdaa4d72b5.gif)
Closes #7173

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-31 13:21:31 +00:00
Lukas Wirth
fb7105a580 Add config setting for self-on-the-fly 2021-05-31 15:14:56 +02:00
bors[bot]
e9a797748d
Merge #8866
8866: Update salsa r=matklad a=jonas-schievink

This updates salsa to include https://github.com/salsa-rs/salsa/pull/265, and removes all cancellation-related code from rust-analyzer

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-31 12:42:32 +00:00
bors[bot]
3cb3f1d17b
Merge #9025
9025: internal: Display unknown types in `analysis-stats` r=flodiebold a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-31 08:20:28 +00:00
Lucas Schwiderski
9a057c0ff4
Fix incorrect setting descriptions
Descriptions for diagnostic warning hint and info display were swapped.

Fixes #8485.

Signed-off-by: Lucas Schwiderski <lucas@lschwiderski.de>
2021-05-29 18:08:14 +02:00